forked from OSchip/llvm-project
[PR] Instrumentation: Introduce instrumentation-binpath argument
Summary: This commit introduces -instrumentation-binpath argument used to point instuqmented binary in runtime in case if /proc/self/map_files path is not accessible due to access restriction issues. Vasily Leonenko Advanced Software Technology Lab, Huawei (cherry picked from FBD30092681)
This commit is contained in:
parent
285ac26d16
commit
519cbbaa9a
|
@ -90,6 +90,8 @@ extern bool __bolt_instr_no_counters_clear;
|
|||
extern bool __bolt_instr_wait_forks;
|
||||
// Filename to dump data to
|
||||
extern char __bolt_instr_filename[];
|
||||
// Instumented binary file path
|
||||
extern char __bolt_instr_binpath[];
|
||||
// If true, append current PID to the fdata filename when creating it so
|
||||
// different invocations of the same program can be differentiated.
|
||||
extern bool __bolt_instr_use_pid;
|
||||
|
@ -597,6 +599,9 @@ static char *getBinaryPath() {
|
|||
static char TargetPath[NameMax] = {};
|
||||
char Buf[BufSize];
|
||||
|
||||
if (__bolt_instr_binpath[0] != '\0')
|
||||
return __bolt_instr_binpath;
|
||||
|
||||
if (TargetPath[0] != '\0')
|
||||
return TargetPath;
|
||||
|
||||
|
|
|
@ -27,6 +27,12 @@ cl::opt<std::string> InstrumentationFilename(
|
|||
"/tmp/prof.fdata)"),
|
||||
cl::init("/tmp/prof.fdata"), cl::Optional, cl::cat(BoltInstrCategory));
|
||||
|
||||
cl::opt<std::string> InstrumentationBinpath(
|
||||
"instrumentation-binpath",
|
||||
cl::desc("path to instumented binary in case if /proc/self/map_files "
|
||||
"is not accessible due to access restriction issues"),
|
||||
cl::Optional, cl::cat(BoltInstrCategory));
|
||||
|
||||
cl::opt<bool> InstrumentationFileAppendPID(
|
||||
"instrumentation-file-append-pid",
|
||||
cl::desc("append PID to saved profile file name (default: false)"),
|
||||
|
|
|
@ -25,6 +25,7 @@ extern cl::OptionCategory BoltOptCategory;
|
|||
|
||||
extern cl::opt<bool> InstrumentationFileAppendPID;
|
||||
extern cl::opt<std::string> InstrumentationFilename;
|
||||
extern cl::opt<std::string> InstrumentationBinpath;
|
||||
extern cl::opt<uint32_t> InstrumentationSleepTime;
|
||||
extern cl::opt<bool> InstrumentationNoCountersClear;
|
||||
extern cl::opt<bool> InstrumentationWaitForks;
|
||||
|
@ -178,6 +179,7 @@ void InstrumentationRuntimeLibrary::emitBinary(BinaryContext &BC,
|
|||
Summary->IndCallTargetDescriptions.size());
|
||||
emitIntValue("__bolt_instr_num_funcs", Summary->FunctionDescriptions.size());
|
||||
emitString("__bolt_instr_filename", opts::InstrumentationFilename);
|
||||
emitString("__bolt_instr_binpath", opts::InstrumentationBinpath);
|
||||
emitIntValue("__bolt_instr_use_pid", !!opts::InstrumentationFileAppendPID, 1);
|
||||
|
||||
if (BC.isMachO()) {
|
||||
|
|
Loading…
Reference in New Issue