Line 298... |
Line 298... |
char **trace_names;
|
char **trace_names;
|
|
|
if(!sigsegv_state) {
|
if(!sigsegv_state) {
|
sigsegv_addr = siginf->si_addr;
|
sigsegv_addr = siginf->si_addr;
|
} else {
|
} else {
|
printf("Nested SIGSEGV occured, dumping next chuck of info\n");
|
fprintf(stderr, "Nested SIGSEGV occured, dumping next chuck of info\n");
|
sigsegv_state++;
|
sigsegv_state++;
|
}
|
}
|
|
|
/* First dump all the data that does not need dereferenceing to get */
|
/* First dump all the data that does not need dereferenceing to get */
|
switch(sigsegv_state) {
|
switch(sigsegv_state) {
|
case 0:
|
case 0:
|
fflush(stdout);
|
fflush(stderr);
|
printf("Segmentation fault at %p (or address: 0x%"PRIxADDR")\n\n",
|
fprintf(stderr, "Segmentation fault on acces to %p (or address: 0x%"PRIxADDR")\n\n",
|
sigsegv_addr, get_pc());
|
sigsegv_addr, get_pc());
|
sigsegv_state++;
|
sigsegv_state++;
|
case 1:
|
case 1:
|
/* Run through the recompiled pages, dumping them to disk as we go */
|
/* Run through the recompiled pages, dumping them to disk as we go */
|
for(dp = cpu_state.dyn_pages; dp; dp = dp->next) {
|
for(dp = cpu_state.dyn_pages; dp; dp = dp->next) {
|
printf("Dumping%s page 0x%"PRIxADDR" recompiled to %p (len: %u) to disk\n",
|
fprintf(stderr, "Dumping%s page 0x%"PRIxADDR" recompiled to %p (len: %u) to disk\n",
|
dp->dirty ? " dirty" : "", dp->or_page, dp->host_page,
|
dp->dirty ? " dirty" : "", dp->or_page, dp->host_page,
|
dp->host_len);
|
dp->host_len);
|
fflush(stdout);
|
fflush(stdout);
|
|
|
sprintf(filen, "or_page.%"PRIxADDR, dp->or_page);
|
sprintf(filen, "or_page.%"PRIxADDR, dp->or_page);
|
Line 332... |
Line 332... |
fclose(f);
|
fclose(f);
|
}
|
}
|
sigsegv_state++;
|
sigsegv_state++;
|
case 2:
|
case 2:
|
/* Dump the contents of the stack */
|
/* Dump the contents of the stack */
|
printf("Stack dump: ");
|
fprintf(stderr, "Stack dump: ");
|
fflush(stdout);
|
fflush(stderr);
|
|
|
num_trace = backtrace(trace, 10);
|
num_trace = backtrace(trace, 10);
|
|
|
trace_names = backtrace_symbols(trace, num_trace);
|
trace_names = backtrace_symbols(trace, num_trace);
|
|
|
stack = get_sp();
|
stack = get_sp();
|
printf("(of stack at %p, base: %p)\n", stack, rec_stack_base);
|
fprintf(stderr, "(of stack at %p, base: %p)\n", stack, rec_stack_base);
|
fflush(stdout);
|
fflush(stderr);
|
for(i = 0; stack < rec_stack_base; i++, stack += 4) {
|
for(i = 0; stack < rec_stack_base; i++, stack += 4) {
|
printf(" <%i> 0x%08x", i, *(uint32_t *)stack);
|
fprintf(stderr, " <%i> 0x%08x", i, *(uint32_t *)stack);
|
/* Try to find a symbolic name with this entry */
|
/* Try to find a symbolic name with this entry */
|
for(j = 0; j < num_trace; j++) {
|
for(j = 0; j < num_trace; j++) {
|
if(trace[j] == *(void **)stack)
|
if(trace[j] == *(void **)stack)
|
printf(" <%s>", trace_names[j]);
|
fprintf(stderr, " <%s>", trace_names[j]);
|
}
|
}
|
printf("\n");
|
fprintf(stderr, "\n");
|
fflush(stdout);
|
fflush(stderr);
|
}
|
}
|
sigsegv_state++;
|
sigsegv_state++;
|
case 3:
|
case 3:
|
sim_done();
|
sim_done();
|
}
|
}
|