Skip to content

Commit

Permalink
pw_system: Add tracing to the demo system
Browse files Browse the repository at this point in the history
Adds a sample implementation of the trace service with built on top of
the flat filesystem and transfer services. The trace data is backed by a
persistent buffer, again as an sample implementation.

Also fixes an issue with pw_transfer failing to compile on systems with
different periods.

Note:
- the bazel build doesn't link due to tracing not being supported in the
  bazel build(b/260641850), so tracing is disabled in the sample bazel build.
- the cmake build doesn't compile, but it was updated we new targets so
as not to dig the hole any deeper.

Change-Id: I483d049d486647c10be3db8f104ea2419a31a312
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/168834
Commit-Queue: Dave Roth <davidroth@google.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
  • Loading branch information
davexroth authored and CQ Bot Account committed Nov 13, 2023
1 parent 281a46a commit effa6cb
Show file tree
Hide file tree
Showing 33 changed files with 1,159 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,7 @@ yarn-error.log

# Emboss
*.emb.h

# Console Logs
pw_console-logs.txt
pw_console-device-logs.txt
114 changes: 113 additions & 1 deletion pw_system/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,25 @@ package(default_visibility = ["//visibility:public"])

licenses(["notice"])

constraint_setting(
name = "system_example_tracing_setting",
)

constraint_value(
name = "system_example_tracing",
constraint_setting = ":system_example_tracing_setting",
)

pw_cc_library(
name = "config",
hdrs = [
"public/pw_system/config.h",
],
defines = select({
"//conditions:default": [
"PW_SYSTEM_ENABLE_TRACE_SERVICE=0",
],
}),
)

pw_cc_library(
Expand Down Expand Up @@ -98,6 +112,7 @@ pw_cc_library(
"//pw_hdlc:rpc_channel_output",
"//pw_sync:mutex",
"//pw_thread:thread_core",
"//pw_trace",
],
)

Expand Down Expand Up @@ -136,16 +151,26 @@ pw_cc_library(
],
includes = ["public"],
deps = [
":file_manager",
":log",
":rpc_server",
":target_hooks",
":thread_snapshot_service",
":transfer_service",
":work_queue",
"//pw_metric:global",
"//pw_metric:metric_service_pwpb",
"//pw_rpc/pwpb:echo_service",
"//pw_thread:thread",
],
] + select({
":system_example_tracing": [
":file_service",
":trace_service",
"//pw_trace",
],
"//conditions:default": [
],
}),
)

pw_cc_library(
Expand Down Expand Up @@ -191,6 +216,90 @@ pw_cc_library(
],
)

pw_cc_library(
name = "transfer_handlers",
srcs = [
"transfer_handlers.cc",
],
hdrs = [
"public/pw_system/transfer_handlers.h",
],
includes = ["public"],
deps = [
"//pw_persistent_ram",
"//pw_trace_tokenized:config",
"//pw_transfer",
],
)

pw_cc_library(
name = "file_manager",
srcs = [
"file_manager.cc",
],
hdrs = [
"public/pw_system/file_manager.h",
],
includes = ["public"],
deps = [
":config",
":transfer_handlers",
"//pw_file:flat_file_system",
"//pw_persistent_ram:flat_file_system_entry",
] + select({
":system_example_tracing": [
":trace_service",
],
"//conditions:default": [
],
}),
)

pw_cc_library(
name = "transfer_service",
srcs = [
"transfer_service.cc",
],
hdrs = [
"public/pw_system/transfer_service.h",
],
includes = ["public"],
deps = [
":file_manager",
"//pw_transfer",
],
)

pw_cc_library(
name = "file_service",
srcs = [
"file_service.cc",
],
hdrs = [
"public/pw_system/file_service.h",
],
includes = ["public"],
deps = [
":file_manager",
],
)

pw_cc_library(
name = "trace_service",
srcs = [
"trace_service.cc",
],
hdrs = [
"public/pw_system/trace_service.h",
],
includes = ["public"],
deps = [
":transfer_handlers",
"//pw_persistent_ram",
"//pw_trace_tokenized:trace_service_pwpb",
],
)

pw_cc_library(
name = "target_hooks",
hdrs = [
Expand Down Expand Up @@ -220,7 +329,9 @@ pw_cc_library(
srcs = [
"stl_target_hooks.cc",
],
includes = ["public"],
deps = [
":config",
"//pw_thread:thread",
"//pw_thread_stl:thread",
],
Expand All @@ -239,6 +350,7 @@ pw_cc_library(
"//pw_build/constraints/rtos:freertos",
],
deps = [
":config",
"//pw_thread:thread",
"//pw_thread_freertos:thread",
],
Expand Down
61 changes: 61 additions & 0 deletions pw_system/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,20 @@ pw_source_set("init") {
public = [ "public/pw_system/init.h" ]
sources = [ "init.cc" ]
deps = [
":file_manager",
":file_service",
":log",
":rpc_server",
":target_hooks.facade",
":thread_snapshot_service",
":trace_service",
":transfer_service",
":work_queue",
"$dir_pw_metric:global",
"$dir_pw_metric:metric_service_pwpb",
"$dir_pw_rpc/pwpb:echo_service",
"$dir_pw_thread:thread",
"$dir_pw_trace",
]
}

Expand All @@ -165,6 +170,7 @@ pw_source_set("hdlc_rpc_server") {
"$dir_pw_hdlc:rpc_channel_output",
"$dir_pw_log",
"$dir_pw_sync:mutex",
"$dir_pw_trace",
]
}

Expand Down Expand Up @@ -196,6 +202,58 @@ pw_source_set("socket_target_io") {
]
}

pw_source_set("transfer_handlers") {
public = [ "public/pw_system/transfer_handlers.h" ]
public_configs = [ ":public_include_path" ]
public_deps = [
"$dir_pw_persistent_ram",
"$dir_pw_trace_tokenized:config",
"$dir_pw_transfer",
]
sources = [ "transfer_handlers.cc" ]
deps = []
}

pw_source_set("file_manager") {
public = [ "public/pw_system/file_manager.h" ]
public_configs = [ ":public_include_path" ]
public_deps = [
":config",
":transfer_handlers",
"$dir_pw_file:flat_file_system",
"$dir_pw_persistent_ram:flat_file_system_entry",
]
sources = [ "file_manager.cc" ]
deps = [ ":trace_service" ]
}

pw_source_set("transfer_service") {
public = [ "public/pw_system/transfer_service.h" ]
public_configs = [ ":public_include_path" ]
public_deps = [ "$dir_pw_transfer" ]
sources = [ "transfer_service.cc" ]
deps = [ ":file_manager" ]
}

pw_source_set("file_service") {
public = [ "public/pw_system/file_service.h" ]
public_configs = [ ":public_include_path" ]
public_deps = []
sources = [ "file_service.cc" ]
deps = [ ":file_manager" ]
}

pw_source_set("trace_service") {
public = [ "public/pw_system/trace_service.h" ]
public_configs = [ ":public_include_path" ]
public_deps = [ ":transfer_handlers" ]
sources = [ "trace_service.cc" ]
deps = [
"$dir_pw_persistent_ram",
"$dir_pw_trace_tokenized:trace_service_pwpb",
]
}

pw_source_set("thread_snapshot_service") {
public = [ "public/pw_system/thread_snapshot_service.h" ]
public_configs = [ ":public_include_path" ]
Expand All @@ -219,6 +277,7 @@ if (pw_system_TARGET_HOOKS_BACKEND == "") {
get_label_info(":stl_target_hooks", "label_no_toolchain")) {
pw_source_set("stl_target_hooks") {
deps = [
":config",
"$dir_pw_thread:thread",
"$dir_pw_thread_stl:thread",
]
Expand All @@ -229,6 +288,7 @@ if (pw_system_TARGET_HOOKS_BACKEND == "") {
get_label_info(":freertos_target_hooks", "label_no_toolchain")) {
pw_source_set("freertos_target_hooks") {
deps = [
":config",
":init",
"$dir_pw_third_party/freertos",
"$dir_pw_thread:thread",
Expand Down Expand Up @@ -258,6 +318,7 @@ pw_executable("system_example") {
":pw_system",
"$dir_pw_log",
"$dir_pw_thread:sleep",
"$dir_pw_trace",
"$dir_pw_unit_test:rpc_service",

# Adds a test that the test server can run.
Expand Down
Loading

0 comments on commit effa6cb

Please sign in to comment.