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:
@@ -23,6 +23,7 @@ struct sysopt {
|
|||||||
#ifdef PANICTRACE
|
#ifdef PANICTRACE
|
||||||
/* panic options */
|
/* panic options */
|
||||||
char *gdbpath;
|
char *gdbpath;
|
||||||
|
char *greppath;
|
||||||
int panictrace_gdb;
|
int panictrace_gdb;
|
||||||
# ifdef PANICTRACE_GLIBC
|
# ifdef PANICTRACE_GLIBC
|
||||||
int panictrace_glibc;
|
int panictrace_glibc;
|
||||||
|
|||||||
11
src/end.c
11
src/end.c
@@ -207,13 +207,16 @@ NH_panictrace_glibc(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
# ifdef PANICTRACE_GDB
|
# ifdef PANICTRACE_GDB
|
||||||
/* I'm going to assume /bin/grep is the right path for grep. */
|
|
||||||
# ifdef SYSCF
|
# ifdef SYSCF
|
||||||
# define GDBPATH sysopt.gdbpath
|
# define GDBPATH sysopt.gdbpath
|
||||||
|
# define GREPPATH sysopt.greppath
|
||||||
# else
|
# else
|
||||||
# ifndef GDBPATH
|
# ifndef GDBPATH
|
||||||
# define GDBPATH "/usr/bin/gdb"
|
# define GDBPATH "/usr/bin/gdb"
|
||||||
# endif
|
# endif
|
||||||
|
# ifndef GREPPATH
|
||||||
|
# define GREPPATH "/bin/grep"
|
||||||
|
# endif
|
||||||
# endif /* !SYSCF */
|
# endif /* !SYSCF */
|
||||||
# endif /* PANICTRACE_GDB */
|
# endif /* PANICTRACE_GDB */
|
||||||
|
|
||||||
@@ -223,12 +226,14 @@ NH_panictrace_gdb(){
|
|||||||
/* A (more) generic method to get a stack trace - invoke
|
/* A (more) generic method to get a stack trace - invoke
|
||||||
* gdb on ourself. */
|
* gdb on ourself. */
|
||||||
char *gdbpath = GDBPATH;
|
char *gdbpath = GDBPATH;
|
||||||
|
char *greppath = GREPPATH;
|
||||||
char buf[BUFSZ];
|
char buf[BUFSZ];
|
||||||
|
|
||||||
if(gdbpath == NULL || gdbpath[0] == 0) return FALSE;
|
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 '^#'",
|
sprintf(buf, "%s -n -q %s %d 2>&1 | %s '^#'",
|
||||||
GDBPATH, ARGV0, getpid());
|
gdbpath, ARGV0, getpid(), greppath);
|
||||||
FILE *gdb = popen(buf, "w");
|
FILE *gdb = popen(buf, "w");
|
||||||
if(gdb){
|
if(gdb){
|
||||||
raw_print("Generating more information you may report:\n");
|
raw_print("Generating more information you may report:\n");
|
||||||
|
|||||||
@@ -2119,6 +2119,7 @@ int src;
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
sysopt.pointsmin = temp;
|
sysopt.pointsmin = temp;
|
||||||
|
#ifdef PANICTRACE_GLIBC
|
||||||
} else if ( (src==SET_IN_SYS) && match_varname(buf, "PANICTRACE_GLIBC", 16)) {
|
} else if ( (src==SET_IN_SYS) && match_varname(buf, "PANICTRACE_GLIBC", 16)) {
|
||||||
int temp = atoi(bufp);
|
int temp = atoi(bufp);
|
||||||
if(temp < 1 || temp > 2){
|
if(temp < 1 || temp > 2){
|
||||||
@@ -2126,6 +2127,7 @@ int src;
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
sysopt.panictrace_glibc = temp;
|
sysopt.panictrace_glibc = temp;
|
||||||
|
#endif
|
||||||
} else if ( (src==SET_IN_SYS) && match_varname(buf, "PANICTRACE_GDB", 14)) {
|
} else if ( (src==SET_IN_SYS) && match_varname(buf, "PANICTRACE_GDB", 14)) {
|
||||||
int temp = atoi(bufp);
|
int temp = atoi(bufp);
|
||||||
if(temp < 1 || temp > 2){
|
if(temp < 1 || temp > 2){
|
||||||
@@ -2137,6 +2139,10 @@ int src;
|
|||||||
if(sysopt.gdbpath) free(sysopt.gdbpath);
|
if(sysopt.gdbpath) free(sysopt.gdbpath);
|
||||||
sysopt.gdbpath = (char*)alloc(strlen(bufp)+1);
|
sysopt.gdbpath = (char*)alloc(strlen(bufp)+1);
|
||||||
Strcpy(sysopt.gdbpath, bufp);
|
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
|
#endif
|
||||||
} else if (match_varname(buf, "BOULDER", 3)) {
|
} else if (match_varname(buf, "BOULDER", 3)) {
|
||||||
(void) get_uchars(fp, buf, bufp, &iflags.bouldersym, TRUE,
|
(void) get_uchars(fp, buf, bufp, &iflags.bouldersym, TRUE,
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ sys_early_init(){
|
|||||||
#ifdef PANICTRACE
|
#ifdef PANICTRACE
|
||||||
/* panic options */
|
/* panic options */
|
||||||
sysopt.gdbpath = NULL;
|
sysopt.gdbpath = NULL;
|
||||||
|
sysopt.greppath = NULL;
|
||||||
# ifdef BETA
|
# ifdef BETA
|
||||||
sysopt.panictrace_gdb = 1;
|
sysopt.panictrace_gdb = 1;
|
||||||
# ifdef PANICTRACE_GLIBC
|
# ifdef PANICTRACE_GLIBC
|
||||||
|
|||||||
@@ -64,6 +64,8 @@ CFLAGS=-g -I../include
|
|||||||
CFLAGS+=-DNOCLIPPING -DNOMAIL -DNOTPARMDECL -DHACKDIR=\"$(HACKDIR)\"
|
CFLAGS+=-DNOCLIPPING -DNOMAIL -DNOTPARMDECL -DHACKDIR=\"$(HACKDIR)\"
|
||||||
CFLAGS+= -DDEFAULT_WINDOW_SYS=\"$(WANT_DEFAULT)\" -DDLB
|
CFLAGS+= -DDEFAULT_WINDOW_SYS=\"$(WANT_DEFAULT)\" -DDLB
|
||||||
|
|
||||||
|
CFLAGS+= -DGREPPATH=\"/usr/bin/grep\"
|
||||||
|
|
||||||
ifdef WANT_WIN_TTY
|
ifdef WANT_WIN_TTY
|
||||||
WINSRC = $(WINTTYSRC)
|
WINSRC = $(WINTTYSRC)
|
||||||
WINOBJ = $(WINTTYOBJ)
|
WINOBJ = $(WINTTYOBJ)
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ MAXPLAYERS=10
|
|||||||
# certain compilation options. See src/end.c and sys/unix/hints/* for
|
# certain compilation options. See src/end.c and sys/unix/hints/* for
|
||||||
# more information.
|
# more information.
|
||||||
GDBPATH=/usr/bin/gdb
|
GDBPATH=/usr/bin/gdb
|
||||||
|
GREPPATH=/bin/grep
|
||||||
# Values are priorities: 0 - do not use this method, 1 - low priority,
|
# Values are priorities: 0 - do not use this method, 1 - low priority,
|
||||||
# 2 - high priority. Non-zero priority methods are tried in order.
|
# 2 - high priority. Non-zero priority methods are tried in order.
|
||||||
PANICTRACE_GDB=1
|
PANICTRACE_GDB=1
|
||||||
|
|||||||
Reference in New Issue
Block a user