This is an automated email from the ASF dual-hosted git repository. jamesge pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-brpc.git
commit e64eb3ce15359263aabf2254379c9130ccff7929 Author: jamesge <jge...@gmail.com> AuthorDate: Mon Nov 30 21:33:20 2020 +0800 partial fix for profiling under MacOS, symbols are not shown yet(even with llvm-symbolizer) --- src/brpc/builtin/hotspots_service.cpp | 7 +++++-- test/brpc_builtin_service_unittest.cpp | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/brpc/builtin/hotspots_service.cpp b/src/brpc/builtin/hotspots_service.cpp index b4e8fcf..7f23a0b 100644 --- a/src/brpc/builtin/hotspots_service.cpp +++ b/src/brpc/builtin/hotspots_service.cpp @@ -376,6 +376,7 @@ static void NotifyWaiters(ProfilingType type, const Controller* cur_cntl, } #if defined(OS_MACOSX) +static const char* s_pprof_binary_path = nullptr; static bool check_GOOGLE_PPROF_BINARY_PATH() { char* str = getenv("GOOGLE_PPROF_BINARY_PATH"); if (str == NULL) { @@ -385,6 +386,7 @@ static bool check_GOOGLE_PPROF_BINARY_PATH() { if (fd < 0) { return false; } + s_pprof_binary_path = strdup(str); return true; } @@ -491,13 +493,13 @@ static void DisplayResult(Controller* cntl, } cmd_builder << " 2>&1 "; #elif defined(OS_MACOSX) - cmd_builder << getenv("GOOGLE_PPROF_BINARY_PATH") << " " + cmd_builder << s_pprof_binary_path << " " << DisplayTypeToPProfArgument(display_type) << (show_ccount ? " -contentions " : ""); if (base_name) { cmd_builder << "-base " << *base_name << ' '; } - cmd_builder << prof_name << " 2>&1 "; + cmd_builder << GetProgramName() << " " << prof_name << " 2>&1 "; #endif const std::string cmd = cmd_builder.str(); @@ -517,6 +519,7 @@ static void DisplayResult(Controller* cntl, errno = 0; // read_command_output may not set errno, clear it to make sure if // we see non-zero errno, it's real error. butil::IOBufBuilder pprof_output; + RPC_VLOG << "Running cmd=" << cmd; const int rc = butil::read_command_output(pprof_output, cmd.c_str()); if (rc != 0) { butil::FilePath pprof_path(pprof_tool); diff --git a/test/brpc_builtin_service_unittest.cpp b/test/brpc_builtin_service_unittest.cpp index d9a24a8..21f6f50 100644 --- a/test/brpc_builtin_service_unittest.cpp +++ b/test/brpc_builtin_service_unittest.cpp @@ -663,15 +663,15 @@ TEST_F(BuiltinServiceTest, pprof) { ClosureChecker done; brpc::Controller cntl; service.heap(&cntl, NULL, NULL, &done); - const int rc = getenv("TCMALLOC_SAMPLE_PARAMETER") ? 0 : brpc::ENOMETHOD; - EXPECT_EQ(rc, cntl.ErrorCode()); + const int rc = getenv("TCMALLOC_SAMPLE_PARAMETER") != nullptr ? 0 : brpc::ENOMETHOD; + EXPECT_EQ(rc, cntl.ErrorCode()) << cntl.ErrorText(); } { ClosureChecker done; brpc::Controller cntl; service.growth(&cntl, NULL, NULL, &done); // linked tcmalloc in UT - EXPECT_EQ(0, cntl.ErrorCode()); + EXPECT_EQ(0, cntl.ErrorCode()) << cntl.ErrorText(); } { ClosureChecker done; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org