winedbg fixup
Eric Pouech
pouech-eric at wanadoo.fr
Wed Feb 4 13:57:12 CST 2004
this patch should fix the latest breakages I introduced, as well as some
error cases handling (reported by R Shearman).
A+
-------------- next part --------------
Name: wd_dt
ChangeLog:
- Fixed broken compilation on BSD
- Fixed some corner case handling in ELF list walking (reported by R Shearman)
License: X11
GenDate: 2004/02/04 19:55:01 UTC
ModifiedFiles: configure.ac programs/winedbg/elf.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/configure.ac,v
retrieving revision 1.234
diff -u -u -r1.234 configure.ac
--- configure.ac 26 Jan 2004 21:29:05 -0000 1.234
+++ configure.ac 3 Feb 2004 21:18:12 -0000
@@ -1087,7 +1087,9 @@
stdint.h \
strings.h \
sys/cdio.h \
+ sys/elf32.h \
sys/errno.h \
+ sys/exec_elf.h \
sys/file.h \
sys/filio.h \
sys/inttypes.h \
Index: programs/winedbg/elf.c
===================================================================
RCS file: /home/cvs/cvsroot/wine/wine/programs/winedbg/elf.c,v
retrieving revision 1.1
diff -u -u -r1.1 elf.c
--- programs/winedbg/elf.c 3 Feb 2004 00:14:12 -0000 1.1
+++ programs/winedbg/elf.c 4 Feb 2004 19:53:18 -0000
@@ -41,17 +41,29 @@
#define __ELF__
#endif
-#ifdef __ELF__
#ifdef HAVE_ELF_H
# include <elf.h>
#endif
+#ifdef HAVE_SYS_ELF32_H
+# include <sys/elf32.h>
+#endif
+#ifdef HAVE_SYS_EXEC_ELF_H
+# include <sys/exec_elf.h>
+#endif
+#if !defined(DT_NUM)
+# if defined(DT_COUNT)
+# define DT_NUM DT_COUNT
+# else
+/* this seems to be a satisfactory value on Solaris, which doesn't support this AFAICT */
+# define DT_NUM 24
+# endif
+#endif
#ifdef HAVE_LINK_H
# include <link.h>
#endif
#ifdef HAVE_SYS_LINK_H
# include <sys/link.h>
#endif
-#endif
#include "wine/debug.h"
@@ -249,6 +261,24 @@
return dil;
}
+static unsigned is_dt_flag_valid(unsigned d_tag)
+{
+#ifndef DT_PROCNUM
+#define DT_PROCNUM 0
+#endif
+#ifndef DT_EXTRANUM
+#define DT_PROCNUM 0
+#endif
+ return (d_tag >= 0 && d_tag < DT_NUM + DT_PROCNUM + DT_EXTRANUM)
+#if defined(DT_LOOS) && defined(DT_HIOS)
+ || (d_tag >= DT_LOOS && d_tag < DT_HIOS)
+#endif
+#if defined(DT_LOPROC) && defined(DT_HIPROC)
+ || (d_tag >= DT_LOPROC && d_tag < DT_HIPROC)
+#endif
+ ;
+}
+
/*
* Loads the information for ELF module stored in 'filename'
* the module has been loaded at 'load_offset' address
@@ -339,12 +369,7 @@
do
{
if (!ReadProcessMemory(hProcess, ptr, &dyn, sizeof(dyn), &len) ||
- len != sizeof(dyn) ||
- !((dyn.d_tag >= 0 &&
- dyn.d_tag < DT_NUM+DT_PROCNUM+DT_EXTRANUM) ||
- (dyn.d_tag >= DT_LOOS && dyn.d_tag < DT_HIOS) ||
- (dyn.d_tag >= DT_LOPROC && dyn.d_tag < DT_HIPROC))
- )
+ len != sizeof(dyn) || !is_dt_flag_valid(dyn.d_tag))
dyn.d_tag = DT_NULL;
ptr += sizeof(dyn);
} while (dyn.d_tag != DT_DEBUG && dyn.d_tag != DT_NULL);
@@ -402,7 +427,7 @@
char *s, *t, *fn;
char* paths = NULL;
- if (!path) return -1;
+ if (!path) return dil;
for (s = paths = DBG_strdup(path); s && *s; s = (t) ? (t+1) : NULL)
{
@@ -430,7 +455,7 @@
{
enum DbgInfoLoad dil = DIL_ERROR;
- if (filename == NULL) return DIL_ERROR;
+ if (filename == NULL || *filename == '\0') return DIL_ERROR;
if (DEBUG_FindModuleByName(filename, DMT_ELF))
{
assert(!(elf_info->flags & ELF_INFO_PATH));
More information about the wine-patches
mailing list