Added a possibility to let the internal debugger use a separate
heap. Not enabled by default, change #if in include/debugger.h to use
this (the heap allocator is very slow).
diff --git a/debugger/dbg.y b/debugger/dbg.y
index 5c15c1e..26e56ba 100644
--- a/debugger/dbg.y
+++ b/debugger/dbg.y
@@ -32,6 +32,7 @@
extern FILE * yyin;
unsigned int dbg_mode = 0;
+HANDLE dbg_heap = 0;
int curr_frame = 0;
static enum exec_mode dbg_exec_mode = EXEC_CONT;
@@ -43,6 +44,12 @@
int yylex(void);
int yyerror(char *);
+#ifdef DBG_need_heap
+#define malloc(x) DBG_alloc(x)
+#define realloc(x,y) DBG_realloc(x,y)
+#define free(x) DBG_free(x)
+#endif
+
extern void VIRTUAL_Dump(void); /* memory/virtual.c */
%}
@@ -452,6 +459,13 @@
frozen = TRUE;
}
+#ifdef DBG_need_heap
+ /*
+ * Initialize the debugger heap.
+ */
+ dbg_heap = HeapCreate(HEAP_NO_SERIALIZE, 0x1000, 0x8000000); /* 128MB */
+#endif
+
/*
* Initialize the type handling stuff.
*/
diff --git a/debugger/debug.l b/debugger/debug.l
index e7b24c0..a77b17d 100644
--- a/debugger/debug.l
+++ b/debugger/debug.l
@@ -9,9 +9,14 @@
#include <stdlib.h>
#include <string.h>
#include "debugger.h"
-#include "xmalloc.h"
#include "y.tab.h"
+#ifdef DBG_need_heap
+#define malloc(x) DBG_alloc(x)
+#define realloc(x,y) DBG_realloc(x,y)
+#define free(x) DBG_free(x)
+#endif
+
#ifndef DONT_USE_READLINE
#undef YY_INPUT
#define YY_INPUT(buf,result,max_size) \
@@ -270,12 +275,12 @@
static int next_symbol;
char * make_symbol(char * symbol){
- return local_symbols[next_symbol++] = xstrdup(symbol);
+ return local_symbols[next_symbol++] = DBG_strdup(symbol);
}
void flush_symbols()
{
- while(--next_symbol>= 0) free(local_symbols[next_symbol]);
+ while(--next_symbol>= 0) DBG_free(local_symbols[next_symbol]);
next_symbol = 0;
}
diff --git a/debugger/display.c b/debugger/display.c
index b3ac40d..74a7519 100644
--- a/debugger/display.c
+++ b/debugger/display.c
@@ -14,7 +14,6 @@
#include "module.h"
#include "selectors.h"
#include "debugger.h"
-#include "xmalloc.h"
#include <stdarg.h>
diff --git a/debugger/editline.c b/debugger/editline.c
index 7021bcb..37c8e13 100644
--- a/debugger/editline.c
+++ b/debugger/editline.c
@@ -34,6 +34,7 @@
#include <sys/stat.h>
#include "windef.h"
+#include "debugger.h"
/*
** Manifest constants.
@@ -55,11 +56,11 @@
#define MEM_INC 64
#define SCREEN_INC 256
-#define DISPOSE(p) free((char *)(p))
+#define DISPOSE(p) DBG_free((char *)(p))
#define NEW(T, c) \
- ((T *)malloc((unsigned int)(sizeof (T) * (c))))
+ ((T *)DBG_alloc((unsigned int)(sizeof (T) * (c))))
#define RENEW(p, T, c) \
- (p = (T *)realloc((char *)(p), (unsigned int)(sizeof (T) * (c))))
+ (p = (T *)DBG_realloc((char *)(p), (unsigned int)(sizeof (T) * (c))))
#define COPYFROMTO(new, p, len) \
(void)memcpy((char *)(new), (char *)(p), (int)(len))
@@ -664,7 +665,7 @@
if (search && *search) {
if (old_search)
DISPOSE(old_search);
- old_search = (CHAR *)strdup((char *)search);
+ old_search = (CHAR *)DBG_strdup((char *)search);
}
else {
if (old_search == NULL || *old_search == '\0')
@@ -1014,7 +1015,7 @@
{
int i;
- if ((p = (CHAR *)strdup((char *)p)) == NULL)
+ if ((p = (CHAR *)DBG_strdup((char *)p)) == NULL)
return;
if (H.Size < HIST_SIZE)
H.Lines[H.Size++] = p;
@@ -1047,7 +1048,7 @@
Prompt = prompt ? prompt : (char *)NIL;
TTYputs((CHAR *)Prompt);
if ((line = editinput()) != NULL) {
- line = (CHAR *)strdup((char *)line);
+ line = (CHAR *)DBG_strdup((char *)line);
TTYputs((CHAR *)NEWLINE);
TTYflush();
}
@@ -1318,7 +1319,7 @@
if (H.Size == 1 || (p = H.Lines[H.Size - 2]) == NULL)
return ring_bell();
- if ((p = (CHAR *)strdup((char *)p)) == NULL)
+ if ((p = (CHAR *)DBG_strdup((char *)p)) == NULL)
return CSstay;
ac = argify(p, &av);
diff --git a/debugger/expr.c b/debugger/expr.c
index bf5f9c2..1f9a4eb 100644
--- a/debugger/expr.c
+++ b/debugger/expr.c
@@ -17,7 +17,6 @@
#include "task.h"
#include "selectors.h"
#include "debugger.h"
-#include "xmalloc.h"
#include "expr.h"
@@ -811,7 +810,7 @@
int i;
struct expr * rtn;
- rtn = (struct expr *) xmalloc(sizeof(struct expr));
+ rtn = (struct expr *) DBG_alloc(sizeof(struct expr));
/*
* First copy the contents of the expression itself.
@@ -829,15 +828,15 @@
case EXPR_TYPE_CONST:
break;
case EXPR_TYPE_STRING:
- rtn->un.string.str = xstrdup(exp->un.string.str);
+ rtn->un.string.str = DBG_strdup(exp->un.string.str);
break;
case EXPR_TYPE_SYMBOL:
- rtn->un.symbol.name = xstrdup(exp->un.symbol.name);
+ rtn->un.symbol.name = DBG_strdup(exp->un.symbol.name);
break;
case EXPR_TYPE_PSTRUCT:
case EXPR_TYPE_STRUCT:
rtn->un.structure.exp1 = DEBUG_CloneExpr(exp->un.structure.exp1);
- rtn->un.structure.element_name = xstrdup(exp->un.structure.element_name);
+ rtn->un.structure.element_name = DBG_strdup(exp->un.structure.element_name);
break;
case EXPR_TYPE_CALL:
/*
@@ -848,7 +847,7 @@
{
rtn->un.call.arg[i] = DEBUG_CloneExpr(exp->un.call.arg[i]);
}
- rtn->un.call.funcname = xstrdup(exp->un.call.funcname);
+ rtn->un.call.funcname = DBG_strdup(exp->un.call.funcname);
break;
case EXPR_TYPE_BINOP:
rtn->un.binop.exp1 = DEBUG_CloneExpr(exp->un.binop.exp1);
@@ -886,15 +885,15 @@
case EXPR_TYPE_CONST:
break;
case EXPR_TYPE_STRING:
- free((char *) exp->un.string.str);
+ DBG_free((char *) exp->un.string.str);
break;
case EXPR_TYPE_SYMBOL:
- free((char *) exp->un.symbol.name);
+ DBG_free((char *) exp->un.symbol.name);
break;
case EXPR_TYPE_PSTRUCT:
case EXPR_TYPE_STRUCT:
DEBUG_FreeExpr(exp->un.structure.exp1);
- free((char *) exp->un.structure.element_name);
+ DBG_free((char *) exp->un.structure.element_name);
break;
case EXPR_TYPE_CALL:
/*
@@ -905,7 +904,7 @@
{
DEBUG_FreeExpr(exp->un.call.arg[i]);
}
- free((char *) exp->un.call.funcname);
+ DBG_free((char *) exp->un.call.funcname);
break;
case EXPR_TYPE_BINOP:
DEBUG_FreeExpr(exp->un.binop.exp1);
@@ -920,6 +919,6 @@
break;
}
- free(exp);
+ DBG_free(exp);
return TRUE;
}
diff --git a/debugger/hash.c b/debugger/hash.c
index 1361d1c..87dee7a 100644
--- a/debugger/hash.c
+++ b/debugger/hash.c
@@ -17,7 +17,6 @@
#include "selectors.h"
#include "debugger.h"
#include "toolhelp.h"
-#include "xmalloc.h"
#define NR_NAME_HASH 16384
#ifndef PATH_MAX
@@ -154,7 +153,7 @@
return;
}
- addr_sorttab = (struct name_hash **) xrealloc(addr_sorttab,
+ addr_sorttab = (struct name_hash **) DBG_realloc(addr_sorttab,
nsym * sizeof(struct name_hash *));
nsym = 0;
@@ -215,9 +214,9 @@
* return it, so we don't end up with duplicates.
*/
- new = (struct name_hash *) xmalloc(sizeof(struct name_hash));
+ new = (struct name_hash *) DBG_alloc(sizeof(struct name_hash));
new->addr = *addr;
- new->name = xstrdup(name);
+ new->name = DBG_strdup(name);
if( source != NULL )
{
@@ -233,7 +232,7 @@
else
{
strcpy(prev_source, source);
- prev_duped_source = new->sourcefile = xstrdup(source);
+ prev_duped_source = new->sourcefile = DBG_strdup(source);
}
}
else
@@ -301,14 +300,14 @@
if( nh->n_locals != nh->locals_alloc )
{
nh->locals_alloc = nh->n_locals;
- nh->local_vars = xrealloc(nh->local_vars,
+ nh->local_vars = DBG_realloc(nh->local_vars,
nh->locals_alloc * sizeof(WineLocals));
}
if( nh->n_lines != nh->lines_alloc )
{
nh->lines_alloc = nh->n_lines;
- nh->linetab = xrealloc(nh->linetab,
+ nh->linetab = DBG_realloc(nh->linetab,
nh->lines_alloc * sizeof(WineLineNo));
}
@@ -928,7 +927,7 @@
if( func->n_lines + 1 >= func->lines_alloc )
{
func->lines_alloc += 64;
- func->linetab = xrealloc(func->linetab,
+ func->linetab = DBG_realloc(func->linetab,
func->lines_alloc * sizeof(WineLineNo));
}
@@ -955,7 +954,7 @@
if( func->n_locals + 1 >= func->locals_alloc )
{
func->locals_alloc += 32;
- func->local_vars = xrealloc(func->local_vars,
+ func->local_vars = DBG_realloc(func->local_vars,
func->locals_alloc * sizeof(WineLocals));
}
@@ -963,7 +962,7 @@
func->local_vars[func->n_locals].offset = offset;
func->local_vars[func->n_locals].pc_start = pc_start;
func->local_vars[func->n_locals].pc_end = pc_end;
- func->local_vars[func->n_locals].name = xstrdup(name);
+ func->local_vars[func->n_locals].name = DBG_strdup(name);
func->local_vars[func->n_locals].type = NULL;
func->n_locals++;
diff --git a/debugger/msc.c b/debugger/msc.c
index 7565dc0..1a5de9d 100644
--- a/debugger/msc.c
+++ b/debugger/msc.c
@@ -31,7 +31,6 @@
#include "debugger.h"
#include "neexe.h"
#include "peexe.h"
-#include "xmalloc.h"
#include "file.h"
/*
@@ -39,8 +38,8 @@
*/
static void LocateDebugInfoFile(char *filename, char *dbg_filename)
{
- char *str1 = xmalloc(MAX_PATHNAME_LEN*10);
- char *str2 = xmalloc(MAX_PATHNAME_LEN);
+ char *str1 = DBG_alloc(MAX_PATHNAME_LEN*10);
+ char *str2 = DBG_alloc(MAX_PATHNAME_LEN);
char *file;
char *name_part;
DOS_FULL_NAME fullname;
@@ -60,8 +59,8 @@
{
quit:
memcpy(dbg_filename, filename, MAX_PATHNAME_LEN);
- free(str1);
- free(str2);
+ DBG_free(str1);
+ DBG_free(str2);
return;
}
ok:
@@ -69,8 +68,8 @@
memcpy(dbg_filename, fullname.long_name, MAX_PATHNAME_LEN);
else
goto quit;
- free(str1);
- free(str2);
+ DBG_free(str1);
+ DBG_free(str2);
return;
}
/*
@@ -627,7 +626,7 @@
if( curr_type - 0x1000 >= num_cv_defined_types )
{
num_cv_defined_types += 0x100;
- cv_defined_types = (struct datatype **) realloc(cv_defined_types,
+ cv_defined_types = (struct datatype **) DBG_realloc(cv_defined_types,
num_cv_defined_types * sizeof(struct datatype *));
memset(cv_defined_types + num_cv_defined_types - 0x100,
0,
@@ -987,7 +986,7 @@
char fn[PATH_MAX];
int fd = -1;
DOS_FULL_NAME full_name;
- struct deferred_debug_info* deefer = (struct deferred_debug_info *) xmalloc(sizeof(*deefer));
+ struct deferred_debug_info* deefer = (struct deferred_debug_info *) DBG_alloc(sizeof(*deefer));
deefer->module = hModule;
deefer->load_addr = (char *)hModule;
@@ -1011,13 +1010,13 @@
close(fd);
if( deefer->dbg_info == (char *) 0xffffffff )
{
- free(deefer);
+ DBG_free(deefer);
break;
}
}
else
{
- free(deefer);
+ DBG_free(deefer);
fprintf(stderr, " (not mapped: fn=%s, lfn=%s, fd=%d)", fn, full_name.long_name, fd);
break;
}
@@ -1026,7 +1025,7 @@
deefer->next = dbglist;
deefer->loaded = FALSE;
deefer->dbg_index = DEBUG_next_index;
- deefer->module_name = xstrdup(module_name);
+ deefer->module_name = DBG_strdup(module_name);
deefer->sectp = PE_SECTIONS(hModule);
deefer->nsect = PE_HEADER(hModule)->FileHeader.NumberOfSections;
@@ -1077,7 +1076,7 @@
{
struct deferred_debug_info * deefer;
- deefer = (struct deferred_debug_info *) xmalloc(sizeof(*deefer));
+ deefer = (struct deferred_debug_info *) DBG_alloc(sizeof(*deefer));
deefer->module = 0;
/*
@@ -1093,7 +1092,7 @@
deefer->next = dbglist;
deefer->loaded = TRUE;
deefer->dbg_index = DEBUG_next_index;
- deefer->module_name = xstrdup(name);
+ deefer->module_name = DBG_strdup(name);
dbglist = deefer;
DEBUG_next_index++;
@@ -1162,7 +1161,7 @@
if( nfiles + 1 >= nfiles_alloc )
{
nfiles_alloc += 10;
- coff_files = (struct CoffFiles *) realloc( coff_files,
+ coff_files = (struct CoffFiles *) DBG_realloc(coff_files,
nfiles_alloc * sizeof(struct CoffFiles));
}
curr_file = coff_files + nfiles;
@@ -1224,7 +1223,7 @@
if( nfiles + 1 >= nfiles_alloc )
{
nfiles_alloc += 10;
- coff_files = (struct CoffFiles *) realloc( coff_files,
+ coff_files = (struct CoffFiles *) DBG_realloc(coff_files,
nfiles_alloc * sizeof(struct CoffFiles));
}
curr_file = coff_files + nfiles;
@@ -1304,7 +1303,7 @@
{
curr_file->neps_alloc += 10;
curr_file->entries = (struct name_hash **)
- realloc( curr_file->entries,
+ DBG_realloc(curr_file->entries,
curr_file->neps_alloc * sizeof(struct name_hash *));
}
#if 0
@@ -1363,7 +1362,7 @@
{
coff_files[j].neps_alloc += 10;
coff_files[j].entries = (struct name_hash **)
- realloc( coff_files[j].entries,
+ DBG_realloc(coff_files[j].entries,
coff_files[j].neps_alloc * sizeof(struct name_hash *));
}
coff_files[j].entries[coff_files[j].neps++] =
@@ -1509,10 +1508,10 @@
{
if( coff_files[j].entries != NULL )
{
- free(coff_files[j].entries);
+ DBG_free(coff_files[j].entries);
}
}
- free(coff_files);
+ DBG_free(coff_files);
}
return (rtn);
@@ -1568,7 +1567,7 @@
* and pull bits as required.
*/
lt_hdr = (struct codeview_linetab_hdr *)
- xmalloc((nseg + 1) * sizeof(*lt_hdr));
+ DBG_alloc((nseg + 1) * sizeof(*lt_hdr));
if( lt_hdr == NULL )
{
goto leave;
@@ -1602,7 +1601,7 @@
fn = (unsigned char *) (start + file_segcount);
memset(filename, 0, sizeof(filename));
memcpy(filename, fn + 1, *fn);
- fn = strdup(filename);
+ fn = DBG_strdup(filename);
for(k = 0; k < file_segcount; k++, this_seg++)
{
@@ -1825,7 +1824,7 @@
if( linetab != NULL )
{
- free(linetab);
+ DBG_free(linetab);
}
return TRUE;
@@ -1926,7 +1925,7 @@
* extents from the file to form the TOC.
*/
toc_blocks = (pdbhdr->toc_len + blocksize - 1) / blocksize;
- toc = (char *) xmalloc(toc_blocks * blocksize);
+ toc = (char *) DBG_alloc(toc_blocks * blocksize);
table = pdbhdr->toc_ext;
for(i=0; i < toc_blocks; i++)
{
@@ -1955,7 +1954,7 @@
goto leave;
}
- filelist = (struct file_list *) xmalloc(npair * sizeof(*filelist));
+ filelist = (struct file_list *) DBG_alloc(npair * sizeof(*filelist));
if( filelist == NULL )
{
goto leave;
@@ -1996,7 +1995,7 @@
if( bufflen < filelist[i].nextents * blocksize )
{
bufflen = filelist[i].nextents * blocksize;
- buffer = (char *) realloc(buffer, bufflen);
+ buffer = (char *) DBG_realloc(buffer, bufflen);
}
/*
@@ -2056,7 +2055,7 @@
hd = (struct filetab_hdr *) buffer;
gsym_record = hd->gsym_file;
- gsymtab = (char *) xmalloc( filelist[gsym_record].nextents
+ gsymtab = (char *) DBG_alloc(filelist[gsym_record].nextents
* blocksize);
memset(gsymtab, 0, filelist[gsym_record].nextents * blocksize);
@@ -2162,18 +2161,18 @@
if( gsymtab != NULL )
{
- free(gsymtab);
+ DBG_free(gsymtab);
gsymtab = NULL;
}
if( buffer != NULL )
{
- free(buffer);
+ DBG_free(buffer);
}
if( filelist != NULL )
{
- free(filelist);
+ DBG_free(filelist);
}
if( addr != (char *) 0xffffffff )
diff --git a/debugger/source.c b/debugger/source.c
index 3892894..2fe0d34 100644
--- a/debugger/source.c
+++ b/debugger/source.c
@@ -26,7 +26,6 @@
#include "debugger.h"
#include "peexe.h"
#include "task.h"
-#include "xmalloc.h"
struct searchlist
{
@@ -70,14 +69,14 @@
{
struct searchlist * sl;
- sl = (struct searchlist *) xmalloc(sizeof(struct searchlist));
+ sl = (struct searchlist *) DBG_alloc(sizeof(struct searchlist));
if( sl == NULL )
{
return;
}
sl->next = listhead;
- sl->path = xstrdup(path);
+ sl->path = DBG_strdup(path);
listhead = sl;
}
@@ -90,8 +89,8 @@
for(sl = listhead; sl; sl = nxt)
{
nxt = sl->next;
- free(sl->path);
- free(sl);
+ DBG_free(sl->path);
+ DBG_free(sl);
}
listhead = NULL;
@@ -215,8 +214,8 @@
* OK, I guess the user doesn't really want to see it
* after all.
*/
- ol = (struct open_filelist *) xmalloc(sizeof(*ol));
- ol->path = xstrdup(sourcefile);
+ ol = (struct open_filelist *) DBG_alloc(sizeof(*ol));
+ ol->path = DBG_strdup(sourcefile);
ol->real_path = NULL;
ol->next = ofiles;
ol->nlines = 0;
@@ -230,9 +229,9 @@
/*
* Create header for file.
*/
- ol = (struct open_filelist *) xmalloc(sizeof(*ol));
- ol->path = xstrdup(sourcefile);
- ol->real_path = xstrdup(tmppath);
+ ol = (struct open_filelist *) DBG_alloc(sizeof(*ol));
+ ol->path = DBG_strdup(sourcefile);
+ ol->real_path = DBG_strdup(tmppath);
ol->next = ofiles;
ol->nlines = 0;
ol->linelist = NULL;
@@ -268,7 +267,7 @@
}
ol->nlines++;
- ol->linelist = (unsigned int*) xmalloc(ol->nlines * sizeof(unsigned int) );
+ ol->linelist = (unsigned int*) DBG_alloc( ol->nlines * sizeof(unsigned int) );
nlines = 0;
pnt = addr;
diff --git a/debugger/stabs.c b/debugger/stabs.c
index 966f8f0..a554d08 100644
--- a/debugger/stabs.c
+++ b/debugger/stabs.c
@@ -20,7 +20,6 @@
#endif
#include "debugger.h"
-#include "xmalloc.h"
#ifdef __svr4__
#define __ELF__
@@ -146,14 +145,14 @@
int
DEBUG_FileSubNr2StabEnum(int filenr,int subnr) {
if (nrofnroftypenums<=filenr) {
- nroftypenums = xrealloc(nroftypenums,sizeof(nroftypenums[0])*(filenr+1));
+ nroftypenums = DBG_realloc(nroftypenums,sizeof(nroftypenums[0])*(filenr+1));
memset(nroftypenums+nrofnroftypenums,0,(filenr+1-nrofnroftypenums)*sizeof(nroftypenums[0]));
- typenums = xrealloc(typenums,sizeof(typenums[0])*(filenr+1));
+ typenums = DBG_realloc(typenums,sizeof(typenums[0])*(filenr+1));
memset(typenums+nrofnroftypenums,0,sizeof(typenums[0])*(filenr+1-nrofnroftypenums));
nrofnroftypenums=filenr+1;
}
if (nroftypenums[filenr]<=subnr) {
- typenums[filenr] = xrealloc(typenums[filenr],sizeof(typenums[0][0])*(subnr+1));
+ typenums[filenr] = DBG_realloc(typenums[filenr],sizeof(typenums[0][0])*(subnr+1));
memset(typenums[filenr]+nroftypenums[filenr],0,sizeof(typenums[0][0])*(subnr+1-nroftypenums[filenr]));
nroftypenums[filenr] = subnr+1;
}
@@ -162,7 +161,7 @@
if( num_stab_types <= curtypenum ) {
num_stab_types = curtypenum + 256;
- stab_types = (struct datatype **) xrealloc(stab_types,
+ stab_types = (struct datatype **) DBG_realloc(stab_types,
num_stab_types * sizeof(struct datatype *)
);
memset( stab_types + curtypenum, 0, sizeof(struct datatype *) * (num_stab_types - curtypenum) );
@@ -221,12 +220,12 @@
if( ndef == 1 )
return TRUE;
- ktd = (struct known_typedef *) xmalloc(sizeof(struct known_typedef)
+ ktd = (struct known_typedef *) DBG_alloc(sizeof(struct known_typedef)
+ ndef * sizeof(struct datatype *));
hash = stab_hash(name);
- ktd->name = xstrdup(name);
+ ktd->name = DBG_strdup(name);
ktd->ndefs = ndef;
memcpy(&ktd->types[0], types, ndef * sizeof(struct datatype *));
ktd->next = ktd_head[hash];
@@ -333,8 +332,8 @@
{
count++;
next = ktd->next;
- free(ktd->name);
- free(ktd);
+ DBG_free(ktd->name);
+ DBG_free(ktd);
}
ktd_head[j] = NULL;
}
@@ -654,7 +653,7 @@
* where the stab is continued over multiple lines.
*/
stabbufflen = 65536;
- stabbuff = (char *) xmalloc(stabbufflen);
+ stabbuff = (char *) DBG_alloc(stabbufflen);
strtabinc = 0;
stabbuff[0] = '\0';
@@ -672,7 +671,7 @@
if( strlen(stabbuff) + len > stabbufflen )
{
stabbufflen += 65536;
- stabbuff = (char *) xrealloc(stabbuff, stabbufflen);
+ stabbuff = (char *) DBG_realloc(stabbuff, stabbufflen);
}
strncat(stabbuff, ptr, len - 1);
continue;
@@ -935,7 +934,7 @@
if( stab_types != NULL )
{
- free(stab_types);
+ DBG_free(stab_types);
stab_types = NULL;
num_stab_types = 0;
}
@@ -1063,25 +1062,25 @@
char *s,*t,*fn,*paths;
if (strchr(filename,'/'))
goto leave;
- paths = xstrdup(getenv("PATH"));
+ paths = DBG_strdup(getenv("PATH"));
s = paths;
while (s && *s) {
t = strchr(s,':');
if (t) *t='\0';
- fn = (char*)xmalloc(strlen(filename)+1+strlen(s)+1);
+ fn = (char*)DBG_alloc(strlen(filename)+1+strlen(s)+1);
strcpy(fn,s);
strcat(fn,"/");
strcat(fn,filename);
if ((rtn = DEBUG_ProcessElfObject(fn,load_offset))) {
- free(fn);
- free(paths);
+ DBG_free(fn);
+ DBG_free(paths);
goto leave;
}
- free(fn);
+ DBG_free(fn);
if (t) s = t+1; else break;
}
if (!s || !*s) fprintf(stderr," not found");
- free(paths);
+ DBG_free(paths);
goto leave;
}
diff --git a/debugger/stack.c b/debugger/stack.c
index 68b141b..22577f1 100644
--- a/debugger/stack.c
+++ b/debugger/stack.c
@@ -8,7 +8,6 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
-#include "xmalloc.h"
#include "debugger.h"
@@ -85,8 +84,8 @@
if (IS_SELECTOR_SYSTEM(SS_reg(&DEBUG_context))) /* system stack */
{
nframe = 1;
- if (frames) free( frames );
- frames = (struct bt_info *) xmalloc( sizeof(struct bt_info) );
+ if (frames) DBG_free( frames );
+ frames = (struct bt_info *) DBG_alloc( sizeof(struct bt_info) );
fprintf(stderr,"%s%d ",(curr_frame == 0 ? "=>" : " "), frameno++);
addr.seg = 0;
@@ -102,7 +101,7 @@
if (!DBG_CHECK_READ_PTR( &addr, sizeof(FRAME32) )) return;
if (!frame->ip) break;
nframe++;
- frames = (struct bt_info *)xrealloc(frames,
+ frames = (struct bt_info *)DBG_realloc(frames,
nframe*sizeof(struct bt_info));
fprintf(stderr,"%s%d ", (frameno == curr_frame ? "=>" : " "),
frameno);
@@ -161,8 +160,8 @@
int frameno = 0;
nframe = 1;
- if (frames) free( frames );
- frames = (struct bt_info *) xmalloc( sizeof(struct bt_info) );
+ if (frames) DBG_free( frames );
+ frames = (struct bt_info *) DBG_alloc( sizeof(struct bt_info) );
if (IS_SELECTOR_SYSTEM(SS_reg(&DEBUG_context))) /* system stack */
{
addr.seg = 0;
@@ -179,7 +178,7 @@
if (!DBG_CHECK_READ_PTR( &addr, sizeof(FRAME32) )) return;
if (!frame->ip) break;
nframe++;
- frames = (struct bt_info *)xrealloc(frames,
+ frames = (struct bt_info *)DBG_realloc(frames,
nframe*sizeof(struct bt_info));
addr.off = frame->ip;
frames[frameno].eip = addr.off;
diff --git a/debugger/types.c b/debugger/types.c
index f171865..e22df1e 100644
--- a/debugger/types.c
+++ b/debugger/types.c
@@ -23,7 +23,6 @@
#include "peexe.h"
#include "debugger.h"
#include "peexe.h"
-#include "xmalloc.h"
#define NR_TYPE_HASH 521
@@ -153,7 +152,7 @@
int hash;
struct datatype * dt;
- dt = (struct datatype *) xmalloc(sizeof(struct datatype));
+ dt = (struct datatype *) DBG_alloc(sizeof(struct datatype));
if( dt != NULL )
{
@@ -227,7 +226,7 @@
if( dt == NULL )
{
- dt = (struct datatype *) xmalloc(sizeof(struct datatype));
+ dt = (struct datatype *) DBG_alloc(sizeof(struct datatype));
if( dt != NULL )
{
@@ -236,7 +235,7 @@
dt->type = xtype;
if( typename != NULL )
{
- dt->name = xstrdup(typename);
+ dt->name = DBG_strdup(typename);
}
else
{
@@ -281,7 +280,7 @@
if( dt == NULL )
{
- dt = (struct datatype *) xmalloc(sizeof(struct datatype));
+ dt = (struct datatype *) DBG_alloc(sizeof(struct datatype));
if( dt != NULL )
{
@@ -571,13 +570,13 @@
break;
}
}
- m = (struct member *) xmalloc(sizeof(struct member));
+ m = (struct member *) DBG_alloc(sizeof(struct member));
if( m == FALSE )
{
return FALSE;
}
- m->name = xstrdup(name);
+ m->name = DBG_strdup(name);
m->type = type;
m->offset = offset;
m->size = size;
@@ -604,13 +603,13 @@
}
else if( dt->type == DT_ENUM )
{
- e = (struct en_values *) xmalloc(sizeof(struct en_values));
+ e = (struct en_values *) DBG_alloc(sizeof(struct en_values));
if( e == FALSE )
{
return FALSE;
}
- e->name = xstrdup(name);
+ e->name = DBG_strdup(name);
e->value = offset;
e->next = dt->un.enumeration.members;
dt->un.enumeration.members = e;