1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-08 17:53:14 +02:00

Make './unreal backtrace' work again. Hmmm.

This commit is contained in:
Bram Matthys
2015-07-12 18:07:10 +02:00
parent 7e78f04058
commit 68ba94c136
8 changed files with 57 additions and 31 deletions
+1 -7
View File
@@ -89,12 +89,6 @@ XCFLAGS=@PTHREAD_CFLAGS@ @TRE_CFLAGS@ @PCRE2_CFLAGS@ @CARES_CFLAGS@ @CFLAGS@
# you are not defining CMDLINE_CONFIG
IRCDMODE = 711
# [CHANGEME]
# IRCDDIR must be the same as DPATH in include/config.h
#
IRCDDIR=@IRCDDIR@
URL=@URL@
# [CHANGEME]
@@ -129,7 +123,7 @@ all: build
MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'IRCDLIBS=${IRCDLIBS}' \
'LDFLAGS=${LDFLAGS}' 'IRCDMODE=${IRCDMODE}' \
'RES=${RES}' 'BINDIR=${BINDIR}' 'INSTALL=${INSTALL}' \
'INCLUDEDIR=${INCLUDEDIR}' 'IRCDDIR=${IRCDDIR}' \
'INCLUDEDIR=${INCLUDEDIR}' \
'RM=${RM}' 'CP=${CP}' 'TOUCH=${TOUCH}' \
'SHELL=${SHELL}' 'STRTOUL=${STRTOUL}' \
'CRYPTOLIB=${CRYPTOLIB}' \
+1
View File
@@ -563,6 +563,7 @@ extern int count_oper_sessions(char *);
extern char *unreal_mktemp(const char *dir, const char *suffix);
extern char *unreal_getpathname(char *filepath, char *path);
extern char *unreal_getfilename(char *path);
extern char *unreal_getmodfilename(char *path);
extern char *unreal_mkcache(const char *url);
extern int has_cached_version(const char *url);
extern int unreal_copyfile(const char *src, const char *dest);
-3
View File
@@ -20,9 +20,6 @@
/* Define to 1 if using `alloca.c'. */
#undef C_ALLOCA
/* Define the location of permanent data files */
#undef DATADIR
/* The default permissions for configuration files. Set to 0 to prevent
unrealircd from calling chmod() on the files. */
#undef DEFAULT_PERMISSIONS
+1 -14
View File
@@ -36,7 +36,7 @@ SRC=$(OBJS:%.o=%.c)
MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'IRCDLIBS=${IRCDLIBS}' \
'LDFLAGS=${LDFLAGS}' 'IRCDMODE=${IRCDMODE}' \
'BINDIR=${BINDIR}' 'INSTALL=${INSTALL}' \
'INCLUDEDIR=${INCLUDEDIR}' 'IRCDDIR=${IRCDDIR}' \
'INCLUDEDIR=${INCLUDEDIR}' \
'MANDIR=${MANDIR}' 'RM=${RM}' 'CP=${CP}' 'TOUCH=${TOUCH}' \
'RES=${RES}' 'SHELL=${SHELL}' 'STRTOUL=${STRTOUL}' \
'CRYPTOLIB=${CRYPTOLIB}' \
@@ -130,19 +130,6 @@ s_svs.o: s_svs.c $(INCLUDES)
events.o: events.c $(INCLUDES)
$(CC) $(CFLAGS) -c events.c
#install: all
# -if [ ! -d ${IRCDDIR} -a ! -f ${IRCDDIR} ] ; then \
# mkdir ${IRCDDIR}; \
# fi
# ../bsdinstall -m ${IRCDMODE} ircd ${BINDIR}
# ../bsdinstall -m 700 chkconf ${BINDIR}
# $(CP) ../doc/example.conf ${IRCDDIR}
# $(TOUCH) ${IRCDDIR}/ircd.motd
# $(RM) -f ${IRCDDIR}/ircd.m4
# $(TOUCH) ${IRCDDIR}/ircd.m4
# chmod +x buildm4
# ./buildm4 ${IRCDDIR}
clean:
$(RM) -f *.o *.so *~ core ircd version.c; \
cd modules; make clean
+1 -1
View File
@@ -1352,7 +1352,7 @@ int InitwIRCD(int argc, char *argv[])
do_version_check();
#if !defined(CHROOTDIR) && !defined(_WIN32)
if (chdir(CONFDIR)) {
if (chdir(PERMDATADIR)) {
# ifndef _WIN32
perror("chdir");
fprintf(stderr, "ERROR: Unable to change to directory '%s'\n", CONFDIR);
+1 -1
View File
@@ -348,7 +348,7 @@ _ */
if (!strstr(path, MODULE_SUFFIX))
strlcat(path, MODULE_SUFFIX, sizeof(path));
tmppath = unreal_mktemp(TMPDIR, unreal_getfilename(path));
tmppath = unreal_mktemp(TMPDIR, unreal_getmodfilename(path));
if (!tmppath)
return "Unable to create temporary file!";
+47
View File
@@ -1630,6 +1630,53 @@ char *unreal_getfilename(char *path)
return end;
}
/* Returns the special module tmp name for a given path
* The original string is not modified
*/
char *unreal_getmodfilename(char *path)
{
static char ret[512];
char buf[512];
char *p;
char *name = NULL;
char *directory = NULL;
if (BadPtr(path))
return path;
strlcpy(buf, path, sizeof(buf));
/* Backtrack... */
for (p = buf + strlen(buf); p >= buf; p--)
{
if ((*p == '/') || (*p == '\\'))
{
name = p+1;
*p = '\0';
directory = buf; /* fallback */
for (; p >= buf; p--)
{
if ((*p == '/') || (*p == '\\'))
{
directory = p + 1;
break;
}
}
break;
}
}
if (!name)
name = buf;
if (!directory || !strcmp(directory, "modules"))
snprintf(ret, sizeof(ret), "%s", name);
else
snprintf(ret, sizeof(ret), "%s.%s", directory, name);
return ret;
}
/* Returns a consistent filename for the cache/ directory.
* Returned value will be like: cache/<hash of url>
*/
+5 -5
View File
@@ -88,7 +88,7 @@ elif [ "$1" = "gencloak" ] ; then
elif [ "$1" = "upgrade-conf" ] ; then
@BINDIR@/unrealircd -U
elif [ "$1" = "backtrace" ] ; then
cd @IRCDDIR@
cd @PERMDATADIR@
modpath="@MODULESDIR@"
@@ -133,13 +133,13 @@ elif [ "$1" = "backtrace" ] ; then
# (ugly) scripting to recreate the tmp/*.so links to the modules *.so files...
echo 'info sharedlibrary'|gdb @BINDIR@/unrealircd $corefile 2>/dev/null|\
grep No|grep tmp/|awk '{ print $2 }'|\
awk -F '.' "{ system(\"ln -s ../$modpath/\" \$2 \".so \" \$0) }"
awk -F '.' "{ system(\"[ -f $modpath/\" \$2 \"/\" \$3 \".so ] && ln -s $modpath/\" \$2 \"/\" \$3 \".so \" \$0 \" || ln -s $modpath/\" \$2 \".so \" \$0) }"
echo ""
echo "=================== START HERE ======================"
echo "BACKTRACE:"
cat >gdb.commands << __EOF__
cat >@TMPDIR@/gdb.commands << __EOF__
bt
echo \n
frame
@@ -150,8 +150,8 @@ bt 3 full
quit
__EOF__
gdb -batch -x gdb.commands @BINDIR@/unrealircd $corefile
rm -f gdb.commands
gdb -batch -x @TMPDIR@/gdb.commands @BINDIR@/unrealircd $corefile
rm -f @TMPDIR@/gdb.commands
echo "GCC: `gcc -v 2>&1|tail -n 1`"
echo "UNAME: `uname -a`"
echo "UNREAL: `$0 version`"