From 9cd309157b4f5ddfa4df475805198aa98f4a609c Mon Sep 17 00:00:00 2001 From: keni Date: Sun, 17 Jan 2010 19:36:16 +0000 Subject: [PATCH] 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. --- include/sys.h | 1 + src/end.c | 11 ++++++++--- src/files.c | 6 ++++++ src/sys.c | 1 + sys/unix/hints/macosx10.5 | 2 ++ sys/unix/sysconf | 1 + 6 files changed, 19 insertions(+), 3 deletions(-) diff --git a/include/sys.h b/include/sys.h index 8002538ca..26cab6a50 100644 --- a/include/sys.h +++ b/include/sys.h @@ -23,6 +23,7 @@ struct sysopt { #ifdef PANICTRACE /* panic options */ char *gdbpath; + char *greppath; int panictrace_gdb; # ifdef PANICTRACE_GLIBC int panictrace_glibc; diff --git a/src/end.c b/src/end.c index ec8a67fb1..56c5199d3 100644 --- a/src/end.c +++ b/src/end.c @@ -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"); diff --git a/src/files.c b/src/files.c index efce344b2..6cf6fb970 100644 --- a/src/files.c +++ b/src/files.c @@ -2119,6 +2119,7 @@ int src; return 0; } sysopt.pointsmin = temp; +#ifdef PANICTRACE_GLIBC } else if ( (src==SET_IN_SYS) && match_varname(buf, "PANICTRACE_GLIBC", 16)) { int temp = atoi(bufp); if(temp < 1 || temp > 2){ @@ -2126,6 +2127,7 @@ int src; return 0; } sysopt.panictrace_glibc = temp; +#endif } else if ( (src==SET_IN_SYS) && match_varname(buf, "PANICTRACE_GDB", 14)) { int temp = atoi(bufp); if(temp < 1 || temp > 2){ @@ -2137,6 +2139,10 @@ int src; if(sysopt.gdbpath) free(sysopt.gdbpath); sysopt.gdbpath = (char*)alloc(strlen(bufp)+1); Strcpy(sysopt.gdbpath, bufp); + } else if ( (src==SET_IN_SYS) && match_varname(buf, "GREPPATH", 7)) { + if(sysopt.greppath) free(sysopt.greppath); + sysopt.greppath = (char*)alloc(strlen(bufp)+1); + Strcpy(sysopt.greppath, bufp); #endif } else if (match_varname(buf, "BOULDER", 3)) { (void) get_uchars(fp, buf, bufp, &iflags.bouldersym, TRUE, diff --git a/src/sys.c b/src/sys.c index b7b43f880..5dedfb71e 100644 --- a/src/sys.c +++ b/src/sys.c @@ -34,6 +34,7 @@ sys_early_init(){ #ifdef PANICTRACE /* panic options */ sysopt.gdbpath = NULL; + sysopt.greppath = NULL; # ifdef BETA sysopt.panictrace_gdb = 1; # ifdef PANICTRACE_GLIBC diff --git a/sys/unix/hints/macosx10.5 b/sys/unix/hints/macosx10.5 index 0cbf9cc11..4bc0c2484 100644 --- a/sys/unix/hints/macosx10.5 +++ b/sys/unix/hints/macosx10.5 @@ -64,6 +64,8 @@ CFLAGS=-g -I../include CFLAGS+=-DNOCLIPPING -DNOMAIL -DNOTPARMDECL -DHACKDIR=\"$(HACKDIR)\" CFLAGS+= -DDEFAULT_WINDOW_SYS=\"$(WANT_DEFAULT)\" -DDLB +CFLAGS+= -DGREPPATH=\"/usr/bin/grep\" + ifdef WANT_WIN_TTY WINSRC = $(WINTTYSRC) WINOBJ = $(WINTTYOBJ) diff --git a/sys/unix/sysconf b/sys/unix/sysconf index 4090e223f..f2181c77f 100644 --- a/sys/unix/sysconf +++ b/sys/unix/sysconf @@ -42,6 +42,7 @@ MAXPLAYERS=10 # certain compilation options. See src/end.c and sys/unix/hints/* for # more information. GDBPATH=/usr/bin/gdb +GREPPATH=/bin/grep # Values are priorities: 0 - do not use this method, 1 - low priority, # 2 - high priority. Non-zero priority methods are tried in order. PANICTRACE_GDB=1