]> granicus.if.org Git - nethack/commitdiff
make grep's path adjustable for PANICTRACE + more bits
authorkeni <keni>
Sun, 17 Jan 2010 19:36:16 +0000 (19:36 +0000)
committerkeni <keni>
Sun, 17 Jan 2010 19:36:16 +0000 (19:36 +0000)
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
src/end.c
src/files.c
src/sys.c
sys/unix/hints/macosx10.5
sys/unix/sysconf

index 8002538cadb0cfd7c082dfed4d1af29b486d812d..26cab6a508f0dc9f18bc0caf319df91a9277d06c 100644 (file)
@@ -23,6 +23,7 @@ struct sysopt {
 #ifdef PANICTRACE
                /* panic options */
        char *gdbpath;
+       char *greppath;
        int  panictrace_gdb;
 # ifdef PANICTRACE_GLIBC
        int panictrace_glibc;
index ec8a67fb17f36d263da7889d63bdea12f79f82c1..56c5199d3bc1b1eef7f4eeb7c86616c1b26a38bd 100644 (file)
--- 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");
index efce344b2839a4ea8057ff7a065062bfe93e158f..6cf6fb970dce7d0c7a543006db275420323688a1 100644 (file)
@@ -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,
index b7b43f880475b6e153aea80fb71e07ae48c5adcc..5dedfb71ef565201419bd9084d3280f967430a15 100644 (file)
--- 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
index 0cbf9cc11d037e310da34e4308baa6b6b8b35541..4bc0c2484b2b2dc5897e05cd987e3823091e72bb 100644 (file)
@@ -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)
index 4090e223f47293aef1a6c4a5c775719a08a5c97b..f2181c77f22513d5dcae39782b6797344291980a 100644 (file)
@@ -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