make grep's path adjustable for PANICTRACE + more bits

Mac OS X doesn't have /bin/grep, only /usr/bin/grep.  Grr.
Don't try to parse PANICTRACE_GLIBC if the field doesn't exist.
This commit is contained in:
keni
2010-01-17 19:36:16 +00:00
parent efed004b64
commit 9cd309157b
6 changed files with 19 additions and 3 deletions

View File

@@ -207,13 +207,16 @@ NH_panictrace_glibc(){
}
# ifdef PANICTRACE_GDB
/* I'm going to assume /bin/grep is the right path for grep. */
# ifdef SYSCF
# define GDBPATH sysopt.gdbpath
# define GREPPATH sysopt.greppath
# else
# ifndef GDBPATH
# define GDBPATH "/usr/bin/gdb"
# endif
# ifndef GREPPATH
# define GREPPATH "/bin/grep"
# endif
# endif /* !SYSCF */
# endif /* PANICTRACE_GDB */
@@ -223,12 +226,14 @@ NH_panictrace_gdb(){
/* A (more) generic method to get a stack trace - invoke
* gdb on ourself. */
char *gdbpath = GDBPATH;
char *greppath = GREPPATH;
char buf[BUFSZ];
if(gdbpath == NULL || gdbpath[0] == 0) return FALSE;
if(greppath == NULL || greppath[0] == 0) return FALSE;
sprintf(buf, "%s -n -q %s %d 2>&1 | /bin/grep '^#'",
GDBPATH, ARGV0, getpid());
sprintf(buf, "%s -n -q %s %d 2>&1 | %s '^#'",
gdbpath, ARGV0, getpid(), greppath);
FILE *gdb = popen(buf, "w");
if(gdb){
raw_print("Generating more information you may report:\n");