Mail Archives: djgpp/1993/12/10/04:16:40
FYI ...
Here's a patch to the 1.11 GO32 that allows the optional dumping of
exception info/registers/stack trace to a file when GO32 detects an
exception. With this patch, you can add the following to the GO32
environment variable:
core <corefile>
If this is present in the GO32 environment variable, GO32 will *APPEND*
exception information, register values, and a stack trace to the file
whose name is given by "<corefile>", above. If the above is not
present, GO32 will act as it currently does (writes to stderr).
This is useful for users of DJGPP-compiled programs, as users can
simply mail the corefile information to developers when a program
crashes, instead of having to tediously copy down the cryptoglyphs on
the screen.
-- 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.
===============================================================================
*** e:\djgpp/tmp/T0AA.AAA Fri Dec 10 00:03:50 1993
--- control.c Thu Dec 9 22:47:34 1993
***************
*** 94,99 ****
--- 94,102 ----
int redir_2_1=0;
int redir_1_2=0;
+ static FILE *core_log_file = stderr;
+ static char *corefile = NULL;
+
static int initial_argc;
static int old_video_mode;
static int globbing=-1;
***************
*** 264,269 ****
--- 267,301 ----
setvect(0x1b, old_ctrlbrk);
}
+ static void open_core_log(void)
+ {
+ FILE *fp;
+
+ if (corefile && ((fp = fopen(corefile, "a")) != NULL))
+ {
+ core_log_file = fp;
+ fprintf(stderr,
+ "\nEXCEPTION OCCURRED! Information dumped to core file:\n");
+ fprintf(stderr, " \"%s\" \n", corefile);
+ fprintf(core_log_file, "\n====================\n");
+ }
+ else
+ {
+ corefile = NULL;
+ core_log_file = stderr;
+ }
+ }
+
+ static void close_core_log(void)
+ {
+ if (corefile)
+ {
+ fclose(core_log_file);
+ corefile = NULL;
+ core_log_file = stderr;
+ }
+ }
+
void show_call_frame(void)
{
word32 vbp,vbp_new, tos;
***************
*** 274,285 ****
else
tos = 0x90000000L;
vbp = tss_ptr->tss_ebp;
! fprintf(stderr,"Call frame traceback EIPs:\n 0x%08lx\n",tss_ptr->tss_eip);
if (vbp == 0) return;
do {
vbp_new = peek32(vbp+ARENA);
if (vbp_new == 0) break;
! fprintf(stderr," 0x%08lx\n",peek32(vbp+ARENA+4)); /* EIP */
vbp = vbp_new;
if (++max == 10)
break;
--- 306,318 ----
else
tos = 0x90000000L;
vbp = tss_ptr->tss_ebp;
! fprintf(core_log_file,
! "Call frame traceback EIPs:\n 0x%08lx\n",tss_ptr->tss_eip);
if (vbp == 0) return;
do {
vbp_new = peek32(vbp+ARENA);
if (vbp_new == 0) break;
! fprintf(core_log_file," 0x%08lx\n",peek32(vbp+ARENA+4)); /* EIP */
vbp = vbp_new;
if (++max == 10)
break;
***************
*** 294,302 ****
_AX = old_video_mode;
geninterrupt(0x10);
}
if (tss_ptr->tss_irqn == hard_master_lo+1)
{
! fprintf(stderr, "Ctrl-%s Hit! Stopped at address %lx\n",
ctrl_break_hit ? "Break" : "C", tss_ptr->tss_eip);
if (ctrl_break_hit)
show_call_frame();
--- 327,336 ----
_AX = old_video_mode;
geninterrupt(0x10);
}
+ open_core_log();
if (tss_ptr->tss_irqn == hard_master_lo+1)
{
! fprintf(core_log_file, "Ctrl-%s Hit! Stopped at address %lx\n",
ctrl_break_hit ? "Break" : "C", tss_ptr->tss_eip);
if (ctrl_break_hit)
show_call_frame();
***************
*** 309,320 ****
if (tss_ptr->tss_irqn == hard_slave_lo + 5)
en = "Floating Point exception";
if (en == 0)
! fprintf(stderr, "Exception %d (0x%02x) at eip=%lx\n",
tss_ptr->tss_irqn, tss_ptr->tss_irqn, tss_ptr->tss_eip);
else
! fprintf(stderr, "%s at eip=%lx\n", en, tss_ptr->tss_eip);
}
! fprintf(stderr, "eax=%08lx ebx=%08lx ecx=%08lx edx=%08lx esi=%08lx edi=%08lx\n",
tss_ptr->tss_eax,
tss_ptr->tss_ebx,
tss_ptr->tss_ecx,
--- 343,355 ----
if (tss_ptr->tss_irqn == hard_slave_lo + 5)
en = "Floating Point exception";
if (en == 0)
! fprintf(core_log_file, "Exception %d (0x%02x) at eip=%lx\n",
tss_ptr->tss_irqn, tss_ptr->tss_irqn, tss_ptr->tss_eip);
else
! fprintf(core_log_file, "%s at eip=%lx\n", en, tss_ptr->tss_eip);
}
! fprintf(core_log_file,
! "eax=%08lx ebx=%08lx ecx=%08lx edx=%08lx esi=%08lx edi=%08lx\n",
tss_ptr->tss_eax,
tss_ptr->tss_ebx,
tss_ptr->tss_ecx,
***************
*** 321,327 ****
tss_ptr->tss_edx,
tss_ptr->tss_esi,
tss_ptr->tss_edi);
! fprintf(stderr, "ebp=%08lx esp=%08lx cs=%x ds=%x es=%x fs=%x gs=%x ss=%x cr2=%08x\n",
tss_ptr->tss_ebp,
tss_ptr->tss_esp,
tss_ptr->tss_cs,
--- 356,363 ----
tss_ptr->tss_edx,
tss_ptr->tss_esi,
tss_ptr->tss_edi);
! fprintf(core_log_file,
! "ebp=%08lx esp=%08lx cs=%x ds=%x es=%x fs=%x gs=%x ss=%x cr2=%08x\n",
tss_ptr->tss_ebp,
tss_ptr->tss_esp,
tss_ptr->tss_cs,
***************
*** 333,338 ****
--- 369,375 ----
tss_ptr->tss_cr2);
show_call_frame();
}
+ close_core_log();
exit(exit_code);
}
***************
*** 537,542 ****
--- 575,586 ----
gr_def_gh = atoi(val);
else if (stricmp(sw, "nc") == 0)
gr_def_numcolor = atoi(val);
+ else if (stricmp(sw, "core") == 0)
+ {
+ if (corefile)
+ free(corefile);
+ corefile = strdup(val);
+ }
else if (stricmp(sw, "emu") == 0)
{
if (emu_fn) free(emu_fn);
- Raw text -