Skip to content

Commit

Permalink
pw_thread: Get the module to build with bazel
Browse files Browse the repository at this point in the history
Fixes some format-specifier-size errors that only came up in the bazel
build.

Bug: 180
Bug: b/218748512
Change-Id: I9be835890881783a26e48df65f8a471d9099d313
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/93180
Reviewed-by: Rob Mohr <[email protected]>
Commit-Queue: Ted Pudlik <[email protected]>
Pigweed-Auto-Submit: Ted Pudlik <[email protected]>
  • Loading branch information
tpudlik authored and CQ Bot Account committed May 2, 2022
1 parent 74faca4 commit 0c5ac6c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
2 changes: 2 additions & 0 deletions pw_presubmit/py/pw_presubmit/pigweed_presubmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ def cmake_gcc(ctx: PresubmitContext):
'//pw_sys_io_baremetal_lm3s6965evb/...',
'//pw_sys_io_baremetal_stm32f429/...',
'//pw_sys_io_stdio/...',
'//pw_thread/...',
'//pw_thread_stl/...',
'//pw_tokenizer/ts/...',
'//pw_tool/...',
Expand Down Expand Up @@ -411,6 +412,7 @@ def cmake_gcc(ctx: PresubmitContext):
'//pw_status/...',
'//pw_stream/...',
'//pw_string/...',
'//pw_thread/...',
'//pw_thread_stl/...',
'//pw_tokenizer/ts/...',
'//pw_transfer/...',
Expand Down
19 changes: 17 additions & 2 deletions pw_thread/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ load(
"pw_cc_library",
"pw_cc_test",
)
load("//pw_protobuf_compiler:proto.bzl", "pw_proto_library")

package(default_visibility = ["//visibility:public"])

Expand Down Expand Up @@ -174,13 +175,13 @@ pw_cc_library(
"public/pw_thread/snapshot.h",
],
deps = [
":util",
":thread",
":thread_cc.pwpb",
"//pw_bytes",
"//pw_function",
"//pw_log",
"//pw_protobuf",
"//pw_status",
"//pw_thread:protos",
],
)

Expand Down Expand Up @@ -249,3 +250,17 @@ pw_cc_test(
"//pw_unit_test",
],
)

proto_library(
name = "thread_proto",
srcs = ["pw_thread_protos/thread.proto"],
strip_import_prefix = "//pw_thread",
deps = [
"//pw_tokenizer:tokenizer_proto",
],
)

pw_proto_library(
name = "thread_cc",
deps = [":thread_proto"],
)
1 change: 1 addition & 0 deletions pw_thread/public/pw_thread/snapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// the License.
#pragma once

#include <optional>
#include <string_view>

#include "pw_bytes/span.h"
Expand Down
10 changes: 7 additions & 3 deletions pw_thread/snapshot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "pw_thread/snapshot.h"

#include <cinttypes>
#include <string_view>

#include "pw_bytes/span.h"
Expand All @@ -35,7 +36,9 @@ Status SnapshotStack(const StackContext& stack,
encoder.WriteStackStartPointer(stack.stack_high_addr);
encoder.WriteStackEndPointer(stack.stack_low_addr);
encoder.WriteStackPointer(stack.stack_pointer);
PW_LOG_DEBUG("Active stack: 0x%08x-0x%08x (%ld bytes)",
// The PRIuPTR is an appropriate format specifier for uintptr_t values
// https://stackoverflow.com/a/5796039/1224002
PW_LOG_DEBUG("Active stack: 0x%08" PRIuPTR "x-0x%08" PRIuPTR "x (%ld bytes)",
stack.stack_high_addr,
stack.stack_pointer,
static_cast<long>(stack.stack_high_addr) -
Expand All @@ -44,13 +47,14 @@ Status SnapshotStack(const StackContext& stack,
const uintptr_t stack_pointer_est_peak =
stack.stack_pointer_est_peak.value();
encoder.WriteStackPointerEstPeak(stack_pointer_est_peak);
PW_LOG_DEBUG("Est peak stack: 0x%08x-0x%08x (%ld bytes)",
PW_LOG_DEBUG("Est peak stack: 0x%08" PRIuPTR "x-0x%08" PRIuPTR
"x (%ld bytes)",
stack.stack_high_addr,
stack_pointer_est_peak,
static_cast<long>(stack.stack_high_addr) -
static_cast<long>(stack_pointer_est_peak));
}
PW_LOG_DEBUG("Stack Limits: 0x%08x-0x%08x (%ld bytes)",
PW_LOG_DEBUG("Stack Limits: 0x%08" PRIuPTR "x-0x%08" PRIuPTR "x (%ld bytes)",
stack.stack_low_addr,
stack.stack_high_addr,
static_cast<long>(stack.stack_high_addr) -
Expand Down

0 comments on commit 0c5ac6c

Please sign in to comment.