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).
This commit is contained in:
Ove Kaaven 1999-04-25 12:24:42 +00:00 committed by Alexandre Julliard
parent 658191ee00
commit dda17c681f
12 changed files with 141 additions and 107 deletions

View File

@ -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 @@ void flush_symbols(void);
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 @@ static void DEBUG_Main( int signal )
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.
*/

View File

@ -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 char *local_symbols[30];
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;
}

View File

@ -14,7 +14,6 @@
#include "module.h"
#include "selectors.h"
#include "debugger.h"
#include "xmalloc.h"
#include <stdarg.h>

View File

@ -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 @@ search_hist(search, move)
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 @@ hist_add(p)
{
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 @@ readline(prompt)
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 @@ last_argument()
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);

View File

@ -17,7 +17,6 @@
#include "task.h"
#include "selectors.h"
#include "debugger.h"
#include "xmalloc.h"
#include "expr.h"
@ -811,7 +810,7 @@ DEBUG_CloneExpr(struct expr * exp)
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 @@ DEBUG_CloneExpr(struct expr * exp)
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 @@ DEBUG_CloneExpr(struct expr * exp)
{
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 @@ DEBUG_FreeExpr(struct expr * exp)
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(struct expr * exp)
{
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 @@ DEBUG_FreeExpr(struct expr * exp)
break;
}
free(exp);
DBG_free(exp);
return TRUE;
}

View File

@ -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 @@ DEBUG_ResortSymbols()
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 @@ DEBUG_AddSymbol( const char * name, const DBG_ADDR *addr, const char * source,
* 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 @@ DEBUG_AddSymbol( const char * name, const DBG_ADDR *addr, const char * source,
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 @@ BOOL DEBUG_Normalize(struct name_hash * nh )
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 @@ DEBUG_AddLineNumber( struct name_hash * func, int line_num,
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 @@ DEBUG_AddLocal( struct name_hash * func, int regno,
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 @@ DEBUG_AddLocal( struct name_hash * func, int regno,
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++;

View File

@ -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 @@ static void LocateDebugInfoFile(char *filename, char *dbg_filename)
{
quit:
memcpy(dbg_filename, filename, MAX_PATHNAME_LEN);
free(str1);
free(str2);
DBG_free(str1);
DBG_free(str2);
return;
}
ok:
@ -69,8 +68,8 @@ ok:
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 @@ DEBUG_ParseTypeTable(char * table, int len)
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 @@ DEBUG_RegisterDebugInfo( HMODULE hModule, const char *module_name)
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 @@ DEBUG_RegisterDebugInfo( HMODULE hModule, const char *module_name)
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 @@ DEBUG_RegisterDebugInfo( HMODULE hModule, const char *module_name)
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 @@ DEBUG_RegisterELFDebugInfo(int load_addr, u_long size, char * name)
{
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 @@ DEBUG_RegisterELFDebugInfo(int load_addr, u_long size, char * name)
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 @@ DEBUG_ProcessCoff(struct deferred_debug_info * deefer)
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 @@ DEBUG_ProcessCoff(struct deferred_debug_info * deefer)
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 @@ DEBUG_ProcessCoff(struct deferred_debug_info * deefer)
{
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 @@ DEBUG_ProcessCoff(struct deferred_debug_info * deefer)
{
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 @@ DEBUG_ProcessCoff(struct deferred_debug_info * deefer)
{
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 @@ DEBUG_SnarfLinetab(char * linetab,
* 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 @@ DEBUG_SnarfLinetab(char * linetab,
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 @@ DEBUG_SnarfCodeView( struct deferred_debug_info * deefer,
if( linetab != NULL )
{
free(linetab);
DBG_free(linetab);
}
return TRUE;
@ -1926,7 +1925,7 @@ DEBUG_ProcessPDBFile(struct deferred_debug_info * deefer, char * full_filename)
* 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 @@ DEBUG_ProcessPDBFile(struct deferred_debug_info * deefer, char * full_filename)
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 @@ DEBUG_ProcessPDBFile(struct deferred_debug_info * deefer, char * full_filename)
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 @@ DEBUG_ProcessPDBFile(struct deferred_debug_info * deefer, char * full_filename)
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 @@ leave:
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 )

View File

@ -26,7 +26,6 @@
#include "debugger.h"
#include "peexe.h"
#include "task.h"
#include "xmalloc.h"
struct searchlist
{
@ -70,14 +69,14 @@ DEBUG_AddPath(const char * path)
{
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 @@ DEBUG_NukePath()
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 @@ DEBUG_DisplaySource(char * sourcefile, int start, int end)
* 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 @@ DEBUG_DisplaySource(char * sourcefile, int start, int end)
/*
* 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 @@ DEBUG_DisplaySource(char * sourcefile, int start, int end)
}
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;

View File

@ -20,7 +20,6 @@
#endif
#include "debugger.h"
#include "xmalloc.h"
#ifdef __svr4__
#define __ELF__
@ -146,14 +145,14 @@ static
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 @@ DEBUG_FileSubNr2StabEnum(int filenr,int subnr) {
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 @@ DEBUG_RegisterTypedef(const char * name, struct datatype ** types, int ndef)
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 @@ static int DEBUG_FreeRegisteredTypedefs()
{
count++;
next = ktd->next;
free(ktd->name);
free(ktd);
DBG_free(ktd->name);
DBG_free(ktd);
}
ktd_head[j] = NULL;
}
@ -654,7 +653,7 @@ DEBUG_ParseStabs(char * addr, unsigned int load_offset,
* 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 @@ DEBUG_ParseStabs(char * addr, unsigned int load_offset,
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 @@ DEBUG_ParseStabs(char * addr, unsigned int load_offset,
if( stab_types != NULL )
{
free(stab_types);
DBG_free(stab_types);
stab_types = NULL;
num_stab_types = 0;
}
@ -1063,25 +1062,25 @@ DEBUG_ProcessElfObject(char * filename, unsigned int load_offset)
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;
}

View File

@ -8,7 +8,6 @@
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include "xmalloc.h"
#include "debugger.h"
@ -85,8 +84,8 @@ void DEBUG_BackTrace(void)
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 @@ void DEBUG_BackTrace(void)
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 @@ void DEBUG_SilentBackTrace(void)
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 @@ void DEBUG_SilentBackTrace(void)
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;

View File

@ -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 @@ DEBUG_InitBasic(int type, char * name, int size, int b_signed,
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 @@ DEBUG_NewDataType(enum debug_type xtype, const char * typename)
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 @@ DEBUG_NewDataType(enum debug_type xtype, const char * typename)
dt->type = xtype;
if( typename != NULL )
{
dt->name = xstrdup(typename);
dt->name = DBG_strdup(typename);
}
else
{
@ -281,7 +280,7 @@ DEBUG_FindOrMakePointerType(struct datatype * reftype)
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 @@ DEBUG_AddStructElement(struct datatype * dt, char * name, struct datatype * type
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 @@ DEBUG_AddStructElement(struct datatype * dt, char * name, struct datatype * type
}
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;

View File

@ -143,6 +143,7 @@ enum exec_mode
extern CONTEXT DEBUG_context; /* debugger/registers.c */
extern unsigned int dbg_mode;
extern HANDLE dbg_heap;
/* debugger/break.c */
extern void DEBUG_SetBreakpoints( BOOL set );
@ -328,5 +329,26 @@ extern void (*fnWINE_Debugger)(int,SIGCONTEXT*);
extern void (*ctx_debug_call)( int, CONTEXT* );
extern BOOL (*fnINSTR_EmulateInstruction)( SIGCONTEXT* );
/* Choose your allocator! */
#if 1
/* this one is libc's fast one */
#include "xmalloc.h"
#define DBG_alloc(x) xmalloc(x)
#define DBG_realloc(x,y) xrealloc(x,y)
#define DBG_free(x) free(x)
#define DBG_strdup(x) xstrdup(x)
#else
/* this one is slow (takes 5 minutes to load the debugger on my machine),
but is pretty crash-proof (can step through malloc() without problems,
malloc() arena (and other heaps) can be totally wasted and it'll still
work, etc... if someone could make optimized routines so it wouldn't
take so long to load, it could be made default) */
#include "heap.h"
#define DBG_alloc(x) HEAP_xalloc(dbg_heap,0,x)
#define DBG_realloc(x,y) HEAP_xrealloc(dbg_heap,0,x,y)
#define DBG_free(x) HeapFree(dbg_heap,0,x)
#define DBG_strdup(x) HEAP_strdupA(dbg_heap,0,x)
#define DBG_need_heap
#endif
#endif /* __WINE_DEBUGGER_H */