To: DJ Delorie Cc: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: Re: debug32 & large programs? Date: Fri, 11 Jun 1993 07:51:03 -0700 From: Darryl Okahata > Sometimes, if there are too many lines in a given file/procedure, > debug32 can't build the line number table in local memory before > transferring it to virtual memory. I'll try to fix this in 1.11. Yup, I looked at this last night, and that was the problem. Unfortunately, "too many lines" was around 1100 lines on my system, and the largest file that I have is around 5000-6000 lines. I "fixed" this using a sledgehammer approach, the patch for which follows at the end of this message. I'm sure that there are better ways to fix this, but this was the quickest and dirtiest. The big drawback with this patch is that debug32 uses up 40K more low memory than before. I've tested these patches with Borland's C/C++ 3.1 (why is tcc still being used?), and I was able to debug my large files with them. -- Darryl Okahata Internet: darrylo AT sr DOT hp DOT com DISCLAIMER: this message is the author's personal opinion and does not constitute the support, opinion or policy of Hewlett-Packard or of the little green men that have been following him all day. =============================================================================== *** f:/T0AA.AAA Fri Jun 11 01:13:38 1993 --- unassmbl.c Fri Jun 11 01:12:26 1993 *************** *** 833,853 **** xmalloc(unsigned size) { void *rval = malloc(size); if(!rval) { ! fprintf(stderr,"Out of memory\n"); exit(1); } return rval; } static void * xrealloc(void *rval,unsigned size) { rval = realloc(rval,size); if(!rval) { ! fprintf(stderr,"Out of memory\n"); exit(1); } return rval; } static char * xstrdup(char *s) { --- 833,858 ---- xmalloc(unsigned size) { void *rval = malloc(size); if(!rval) { ! fprintf(stderr,"\nOut of memory trying to allocate %u bytes (coreleft = %u)\n", ! size, coreleft()); exit(1); } return rval; } + #if 0 /* no longer used */ static void * xrealloc(void *rval,unsigned size) { + void *orig = rval; rval = realloc(rval,size); if(!rval) { ! fprintf(stderr,"\nOut of memory trying to reallocate %u bytes (0x%08lx)\n", ! size, (unsigned long) orig); exit(1); } return rval; } + #endif static char * xstrdup(char *s) { *************** *** 859,869 **** /* ** add_file -- add a file to the source line database */ static int add_file(char *name) { FILE *f = fopen(name,"r"); char c; ! long *lines,curpos; unsigned curline = 0; if(!f) --- 864,888 ---- /* ** add_file -- add a file to the source line database */ + + #define LINES_BUF_SIZE 10000 /* we handle files with up to this + number of lines */ + + #pragma option -zEyuk -zHyuk -zFyuk /* get our yuks -- shove this crud + into another segment. For some + reason, we can't use farmalloc() + because it causes a bcc-compiled + program to crash. */ + long far line_offsets[LINES_BUF_SIZE]; + #pragma option -zE* -zH* -zF* /* un-yuk-ify everything and restore + placing variables into the default + segment. */ + static int add_file(char *name) { FILE *f = fopen(name,"r"); char c; ! long curpos; unsigned curline = 0; if(!f) *************** *** 873,897 **** /* ** build an array of line offsets in real memory. */ ! lines = xmalloc(sizeof(long)); ! lines[curline++] = curpos = 0L; while((c = getc(f)) != EOF) { curpos++; if(c == '\n') { ! lines = xrealloc(lines,sizeof(long)*(curline+1)); ! lines[curline++] = curpos; } } /* ** now move the whole array into virtual memory */ files[last_file].offsets = salloc(curline*sizeof(long)); ! symsput(files[last_file].offsets,lines,(curline*sizeof(long))); ! /* ! ** don't need the real memory version any more ! */ ! free(lines); fclose(f); --- 892,914 ---- /* ** build an array of line offsets in real memory. */ ! line_offsets[curline++] = curpos = 0L; while((c = getc(f)) != EOF) { curpos++; if(c == '\n') { ! if (curline >= LINES_BUF_SIZE) { ! fprintf(stderr,"\nOut of memory!\n"); ! exit(1); ! } ! line_offsets[curline++] = curpos; } } /* ** now move the whole array into virtual memory */ files[last_file].offsets = salloc(curline*sizeof(long)); ! symsput(files[last_file].offsets,line_offsets,(curline*sizeof(long))); fclose(f);