Changeset View
Changeset View
Standalone View
Standalone View
devel/gdb/files/kgdb/kgdb-main.c
Show First 20 Lines • Show All 377 Lines • ▼ Show 20 Lines | main(int argc, char *argv[]) | ||||
/* Set an alternate prompt. */ | /* Set an alternate prompt. */ | ||||
add_arg(&args, "-iex"); | add_arg(&args, "-iex"); | ||||
add_arg(&args, "set prompt (kgdb) "); | add_arg(&args, "set prompt (kgdb) "); | ||||
/* Change osabi to assume a FreeBSD kernel. */ | /* Change osabi to assume a FreeBSD kernel. */ | ||||
add_arg(&args, "-iex"); | add_arg(&args, "-iex"); | ||||
add_arg(&args, "set osabi FreeBSD/kernel"); | add_arg(&args, "set osabi FreeBSD/kernel"); | ||||
/* | |||||
* PowerPC kernels are fully relocatable and may be loaded | |||||
* at any memory address. In order to resolve symbols properly, | |||||
* GDB must load the kernel symbol file relative to the base | |||||
* offset where the it was loaded in memory. | |||||
*/ | |||||
#ifdef __powerpc__ | |||||
{ | |||||
unsigned long long offs; | |||||
unsigned long long ppcfbsd_get_startkernel( | |||||
const char *, const char *); | |||||
offs = ppcfbsd_get_startkernel(kernel, vmcore); | |||||
/* Set executable file but don't load it yet. */ | |||||
add_arg(&args, "-e"); | |||||
add_arg(&args, kernel); | |||||
add_arg(&args, "-ex"); | |||||
add_arg(&args, "set confirm off"); | |||||
/* Load symbols at proper offsets. */ | |||||
add_arg(&args, "-ex"); | |||||
asprintf(&s, "symbol-file -o 0x%llx %s", offs, kernel); | |||||
add_arg(&args, s); | |||||
add_arg(&args, "-ex"); | |||||
add_arg(&args, "set confirm on"); | |||||
} | |||||
#endif | |||||
/* Open the vmcore if requested. */ | /* Open the vmcore if requested. */ | ||||
if (vmcore != NULL) { | if (vmcore != NULL) { | ||||
add_arg(&args, "-ex"); | add_arg(&args, "-ex"); | ||||
if (asprintf(&s, "target vmcore %s%s", writeable ? "-w " : "", | if (asprintf(&s, "target vmcore %s%s", writeable ? "-w " : "", | ||||
vmcore) < 0) | vmcore) < 0) | ||||
err(1, "couldn't build command line"); | err(1, "couldn't build command line"); | ||||
add_arg(&args, s); | add_arg(&args, s); | ||||
} | } | ||||
/* Open the remote target if requested. */ | /* Open the remote target if requested. */ | ||||
if (remote != NULL) { | if (remote != NULL) { | ||||
add_arg(&args, "-ex"); | add_arg(&args, "-ex"); | ||||
if (asprintf(&s, "target remote %s", remote) < 0) | if (asprintf(&s, "target remote %s", remote) < 0) | ||||
err(1, "couldn't build command line"); | err(1, "couldn't build command line"); | ||||
add_arg(&args, s); | add_arg(&args, s); | ||||
} | } | ||||
/* Avoid loading symbols twice on PowerPC. */ | |||||
#ifndef __powerpc__ | |||||
add_arg(&args, kernel); | add_arg(&args, kernel); | ||||
#endif | |||||
/* The libgdb code uses optind too. Reset it... */ | /* The libgdb code uses optind too. Reset it... */ | ||||
optind = 0; | optind = 0; | ||||
/* Terminate argv list. */ | /* Terminate argv list. */ | ||||
add_arg(&args, NULL); | add_arg(&args, NULL); | ||||
return (gdb_main(&args)); | return (gdb_main(&args)); | ||||
} | } |