Commit fa774e22 authored by Mao Huang's avatar Mao Huang Committed by Commit Bot

tcmalloc: Let DEFINE_string define char arrays.

Original CL:

- https://codereview.chromium.org/286953011

  tcmalloc: Let DEFINE_string define const char*s.

  DEFINE_string is used in 3 files in tcmalloc, but we only compile one
  of these.  In this one file, the string is converted to char every
  time it's used, and since the string is used after global destructors
  have run it needs to be copied to a second string in a static
  initializer.

  Instead of all that silliness, just let DEFINE_string define a const
  char* (like it does in v8 or webrtc).

  BUG=94925
  R=willchan@chromium.org

  Committed:
  https://src.chromium.org/viewvc/chrome?view=rev&revision=271307

BUG=724399,b:70905156

Change-Id: Iec6efe53f03daff472107e700a9d833d60e33eff
Reviewed-on: https://chromium-review.googlesource.com/1130781
Commit-Queue: Gabriel Marin <gmx@chromium.org>
Reviewed-by: default avatarWill Harris <wfh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579528}
parent a6066971
......@@ -97,16 +97,15 @@
#define DEFINE_double(name, value, meaning) \
DEFINE_VARIABLE(double, name, value, meaning)
// Special case for string, because we have to specify the namespace
// std::string, which doesn't play nicely with our FLAG__namespace hackery.
// Special case for string, because of the pointer type.
#define DECLARE_string(name) \
namespace FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead { \
extern std::string FLAGS_##name; \
extern const char* FLAGS_##name; \
} \
using FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead::FLAGS_##name
#define DEFINE_string(name, value, meaning) \
namespace FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead { \
std::string FLAGS_##name(value); \
const char* FLAGS_##name = value; \
char FLAGS_no##name; \
} \
using FLAG__namespace_do_not_use_directly_use_DECLARE_string_instead::FLAGS_##name
......
......@@ -72,11 +72,6 @@ DEFINE_string(symbolize_pprof,
EnvToString("PPROF_PATH", "pprof"),
"Path to pprof to call for reporting function names.");
// heap_profile_table_pprof may be referenced after destructors are
// called (since that's when leak-checking is done), so we make
// a more-permanent copy that won't ever get destroyed.
static string* g_pprof_path = new string(FLAGS_symbolize_pprof);
// Returns NULL if we're on an OS where we can't get the invocation name.
// Using a static var is ok because we're not called from a thread.
static const char* GetProgramInvocationName() {
......@@ -144,7 +139,7 @@ int SymbolTable::Symbolize() {
PrintError("Cannot figure out the name of this executable (argv0)");
return 0;
}
if (access(g_pprof_path->c_str(), R_OK) != 0) {
if (access(FLAGS_symbolize_pprof, R_OK) != 0) {
PrintError("Cannot find 'pprof' (is PPROF_PATH set correctly?)");
return 0;
}
......@@ -206,7 +201,7 @@ int SymbolTable::Symbolize() {
unsetenv("HEAPPROFILE");
unsetenv("HEAPCHECK");
unsetenv("PERFTOOLS_VERBOSE");
execlp(g_pprof_path->c_str(), g_pprof_path->c_str(),
execlp(FLAGS_symbolize_pprof, FLAGS_symbolize_pprof,
"--symbols", argv0, NULL);
_exit(3); // if execvp fails, it's bad news for us
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment