minidump-2-core: Allow user to override shared lib basedir.

This CL introduces "--sobasedir" command-line option to minidump-2-core.
By default, paths to shared lib files included in generated core file are
formatted as "/var/lib/breakpad/[GUID]libFoobar.so". By using "--sobasedir",
this will be "[user-supplied-path]libFoobar.so".

This option can be used to ease debugging minidump files from developer's local
builds. By specifying "minidump-2-core --sobasedir `pwd`/out/Debug/lib/
foobar.mdmp", user can load the generated core file in gdb without setting up
the symlinks for "/var/lib/breakpad".

BUG=None
A=kouhei@chromium.org

Original code review: https://breakpad.appspot.com/1214002/

R=kouhei@chromium.org

Review URL: https://breakpad.appspot.com/1584002

git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1317 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
thestig@chromium.org 2014-04-18 20:59:16 +00:00
parent c83a81450c
commit d4f5ca2275

View File

@ -86,6 +86,7 @@ using google_breakpad::MinidumpMemoryRange;
static const MDRVA kInvalidMDRVA = static_cast<MDRVA>(-1);
static bool verbose;
static std::string g_custom_so_basedir;
static int usage(const char* argv0) {
fprintf(stderr, "Usage: %s [-v] <minidump file>\n", argv0);
@ -365,7 +366,7 @@ ParseThreadRegisters(CrashedProcess::Thread* thread,
for (int i = 0; i < MD_CONTEXT_MIPS_GPR_COUNT; ++i)
thread->regs.regs[i] = rawregs->iregs[i];
thread->regs.lo = rawregs->mdlo;
thread->regs.hi = rawregs->mdhi;
thread->regs.epc = rawregs->epc;
@ -375,7 +376,7 @@ ParseThreadRegisters(CrashedProcess::Thread* thread,
for (int i = 0; i < MD_FLOATINGSAVEAREA_MIPS_FPR_COUNT; ++i)
thread->fpregs.regs[i] = rawregs->float_save.regs[i];
thread->fpregs.fpcsr = rawregs->float_save.fpcsr;
thread->fpregs.fir = rawregs->float_save.fir;
}
@ -575,7 +576,7 @@ static void
ParseEnvironment(CrashedProcess* crashinfo, const MinidumpMemoryRange& range) {
if (verbose) {
fputs("MD_LINUX_ENVIRON:\n", stderr);
char *env = new char[range.length()];
char* env = new char[range.length()];
memcpy(env, range.data(), range.length());
int nul_count = 0;
for (char *ptr = env;;) {
@ -814,8 +815,13 @@ ParseModuleStream(CrashedProcess* crashinfo, const MinidumpMemoryRange& range,
std::string basename = slash == std::string::npos ?
filename : filename.substr(slash + 1);
if (strcmp(guid, "00000000-0000-0000-0000-000000000000")) {
crashinfo->signatures[rawmodule->base_of_image] =
std::string("/var/lib/breakpad/") + guid + "-" + basename;
std::string prefix;
if (!g_custom_so_basedir.empty())
prefix = g_custom_so_basedir;
else
prefix = std::string("/var/lib/breakpad/") + guid + "-" + basename;
crashinfo->signatures[rawmodule->base_of_image] = prefix + basename;
}
if (verbose) {
@ -974,6 +980,14 @@ main(int argc, char** argv) {
while (argi < argc && argv[argi][0] == '-') {
if (!strcmp(argv[argi], "-v")) {
verbose = true;
} else if (!strcmp(argv[argi], "--sobasedir")) {
argi++;
if (argi >= argc) {
fprintf(stderr, "--sobasedir expects an argument.");
return usage(argv[0]);
}
g_custom_so_basedir = argv[argi];
} else {
return usage(argv[0]);
}