mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-17 21:35:07 +00:00
llvm-symbolizer: add --obj flag to specify a single object file that should be symbolized.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197988 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7f7c068388
commit
42c9ecb7a4
docs/CommandGuide
test/DebugInfo
tools/llvm-symbolizer
@ -10,7 +10,9 @@ DESCRIPTION
|
|||||||
-----------
|
-----------
|
||||||
|
|
||||||
:program:`llvm-symbolizer` reads object file names and addresses from standard
|
:program:`llvm-symbolizer` reads object file names and addresses from standard
|
||||||
input and prints corresponding source code locations to standard output. This
|
input and prints corresponding source code locations to standard output.
|
||||||
|
If object file is specified in command line, :program:`llvm-symbolizer` reads
|
||||||
|
only addresses from standard input. This
|
||||||
program uses debug info sections and symbol table in the object files.
|
program uses debug info sections and symbol table in the object files.
|
||||||
|
|
||||||
EXAMPLE
|
EXAMPLE
|
||||||
@ -45,10 +47,22 @@ EXAMPLE
|
|||||||
|
|
||||||
_main
|
_main
|
||||||
/tmp/source_x86_64.cc:8
|
/tmp/source_x86_64.cc:8
|
||||||
|
$ cat addr2.txt
|
||||||
|
0x4004f4
|
||||||
|
0x401000
|
||||||
|
$ llvm-symbolizer -obj=a.out < addr2.txt
|
||||||
|
main
|
||||||
|
/tmp/a.cc:4
|
||||||
|
|
||||||
|
foo(int)
|
||||||
|
/tmp/a.cc:12
|
||||||
|
|
||||||
OPTIONS
|
OPTIONS
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
.. option:: -obj
|
||||||
|
Path to object file to be symbolized.
|
||||||
|
|
||||||
.. option:: -functions
|
.. option:: -functions
|
||||||
|
|
||||||
Print function names as well as source file/line locations. Defaults to true.
|
Print function names as well as source file/line locations. Defaults to true.
|
||||||
|
@ -57,3 +57,12 @@ RUN: llvm-symbolizer < %t.input3 | FileCheck %s --check-prefix=UNKNOWN-ARCH
|
|||||||
UNKNOWN-ARCH-NOT: main
|
UNKNOWN-ARCH-NOT: main
|
||||||
UNKNOWN-ARCH: ??
|
UNKNOWN-ARCH: ??
|
||||||
UNKNOWN-ARCH-NOT: main
|
UNKNOWN-ARCH-NOT: main
|
||||||
|
|
||||||
|
RUN: echo "0x400559" > %t.input4
|
||||||
|
RUN: echo "0x400436" >> %t.input4
|
||||||
|
RUN: llvm-symbolizer --obj %p/Inputs/dwarfdump-test.elf-x86-64 < %t.input4 \
|
||||||
|
RUN: | FileCheck %s --check-prefix=BINARY
|
||||||
|
|
||||||
|
BINARY: main
|
||||||
|
BINARY-NEXT: /tmp/dbginfo{{[/\\]}}dwarfdump-test.cc:16
|
||||||
|
BINARY: _start
|
||||||
|
@ -51,6 +51,11 @@ static cl::opt<std::string> ClDefaultArch("default-arch", cl::init(""),
|
|||||||
cl::desc("Default architecture "
|
cl::desc("Default architecture "
|
||||||
"(for multi-arch objects)"));
|
"(for multi-arch objects)"));
|
||||||
|
|
||||||
|
static cl::opt<std::string>
|
||||||
|
ClBinaryName("obj", cl::init(""),
|
||||||
|
cl::desc("Path to object file to be symbolized (if not provided, "
|
||||||
|
"object file should be specified for each input line)"));
|
||||||
|
|
||||||
static bool parseCommand(bool &IsData, std::string &ModuleName,
|
static bool parseCommand(bool &IsData, std::string &ModuleName,
|
||||||
uint64_t &ModuleOffset) {
|
uint64_t &ModuleOffset) {
|
||||||
const char *kDataCmd = "DATA ";
|
const char *kDataCmd = "DATA ";
|
||||||
@ -62,7 +67,6 @@ static bool parseCommand(bool &IsData, std::string &ModuleName,
|
|||||||
return false;
|
return false;
|
||||||
IsData = false;
|
IsData = false;
|
||||||
ModuleName = "";
|
ModuleName = "";
|
||||||
std::string ModuleOffsetStr = "";
|
|
||||||
char *pos = InputString;
|
char *pos = InputString;
|
||||||
if (strncmp(pos, kDataCmd, strlen(kDataCmd)) == 0) {
|
if (strncmp(pos, kDataCmd, strlen(kDataCmd)) == 0) {
|
||||||
IsData = true;
|
IsData = true;
|
||||||
@ -74,26 +78,29 @@ static bool parseCommand(bool &IsData, std::string &ModuleName,
|
|||||||
// If no cmd, assume it's CODE.
|
// If no cmd, assume it's CODE.
|
||||||
IsData = false;
|
IsData = false;
|
||||||
}
|
}
|
||||||
// Skip delimiters and parse input filename.
|
// Skip delimiters and parse input filename (if needed).
|
||||||
pos += strspn(pos, kDelimiters);
|
if (ClBinaryName == "") {
|
||||||
if (*pos == '"' || *pos == '\'') {
|
pos += strspn(pos, kDelimiters);
|
||||||
char quote = *pos;
|
if (*pos == '"' || *pos == '\'') {
|
||||||
pos++;
|
char quote = *pos;
|
||||||
char *end = strchr(pos, quote);
|
pos++;
|
||||||
if (end == 0)
|
char *end = strchr(pos, quote);
|
||||||
return false;
|
if (end == 0)
|
||||||
ModuleName = std::string(pos, end - pos);
|
return false;
|
||||||
pos = end + 1;
|
ModuleName = std::string(pos, end - pos);
|
||||||
|
pos = end + 1;
|
||||||
|
} else {
|
||||||
|
int name_length = strcspn(pos, kDelimiters);
|
||||||
|
ModuleName = std::string(pos, name_length);
|
||||||
|
pos += name_length;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
int name_length = strcspn(pos, kDelimiters);
|
ModuleName = ClBinaryName;
|
||||||
ModuleName = std::string(pos, name_length);
|
|
||||||
pos += name_length;
|
|
||||||
}
|
}
|
||||||
// Skip delimiters and parse module offset.
|
// Skip delimiters and parse module offset.
|
||||||
pos += strspn(pos, kDelimiters);
|
pos += strspn(pos, kDelimiters);
|
||||||
int offset_length = strcspn(pos, kDelimiters);
|
int offset_length = strcspn(pos, kDelimiters);
|
||||||
ModuleOffsetStr = std::string(pos, offset_length);
|
if (StringRef(pos, offset_length).getAsInteger(0, ModuleOffset))
|
||||||
if (StringRef(ModuleOffsetStr).getAsInteger(0, ModuleOffset))
|
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -104,7 +111,7 @@ int main(int argc, char **argv) {
|
|||||||
PrettyStackTraceProgram X(argc, argv);
|
PrettyStackTraceProgram X(argc, argv);
|
||||||
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
|
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
|
||||||
|
|
||||||
cl::ParseCommandLineOptions(argc, argv, "llvm symbolizer for compiler-rt\n");
|
cl::ParseCommandLineOptions(argc, argv, "llvm-symbolizer\n");
|
||||||
LLVMSymbolizer::Options Opts(ClUseSymbolTable, ClPrintFunctions,
|
LLVMSymbolizer::Options Opts(ClUseSymbolTable, ClPrintFunctions,
|
||||||
ClPrintInlining, ClDemangle, ClDefaultArch);
|
ClPrintInlining, ClDemangle, ClDefaultArch);
|
||||||
LLVMSymbolizer Symbolizer(Opts);
|
LLVMSymbolizer Symbolizer(Opts);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user