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

@@ -23,6 +23,7 @@ struct sysopt {
#ifdef PANICTRACE
/* panic options */
char *gdbpath;
char *greppath;
int panictrace_gdb;
# ifdef PANICTRACE_GLIBC
int panictrace_glibc;

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");

View 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,

View File

@@ -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

View 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)

View 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