dded patch with symbols support in bochs-debugger

This commit is contained in:
Stanislav Shwartsman 2008-03-29 21:32:18 +00:00
parent b5f5e01f7e
commit 46e7ca44dc
6 changed files with 50 additions and 28 deletions

View File

@ -16,6 +16,7 @@ Detailed change log :
optimization enabled
- Minor bugfixes in CPU emulation (both ia32 and x86-64)
- Updated CPU instrumentation callbacks
- A lot internal debugger fixes
- System BIOS (Volker)
- Implemented LBA48 support (since BIOS functions are limited to

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: dbg_main.cc,v 1.119 2008-03-28 12:51:02 sshwarts Exp $
// $Id: dbg_main.cc,v 1.120 2008-03-29 21:32:18 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -3180,7 +3180,7 @@ void bx_dbg_print_help(void)
dbg_printf("h|help command - show short command description\n");
dbg_printf("-*- Debugger control -*-\n");
dbg_printf(" help, q|quit|exit, set, instrument, show, trace, trace-reg,\n");
dbg_printf(" record, playback, load-symbols, slist\n");
dbg_printf(" record, playback, ldsym, slist\n");
dbg_printf("-*- Execution control -*-\n");
dbg_printf(" c|cont|continue, s|step|stepi, p|n|next, modebp\n");
dbg_printf("-*- Breakpoint management -*-\n");

View File

@ -1,6 +1,6 @@
%{
/////////////////////////////////////////////////////////////////////////
// $Id: lexer.l,v 1.22 2007-10-23 21:51:43 sshwarts Exp $
// $Id: lexer.l,v 1.23 2008-03-29 21:32:18 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
#include <stdlib.h>
@ -127,7 +127,7 @@ unwatch { bxlval.sval = strdup(bxtext); return(BX_TOKEN_UNWATCH); }
read { bxlval.sval = strdup(bxtext); return(BX_TOKEN_READ); }
write { bxlval.sval = strdup(bxtext); return(BX_TOKEN_WRITE); }
show { bxlval.sval = strdup(bxtext); return(BX_TOKEN_SHOW); }
load-symbols { bxlval.sval = strdup(bxtext); return(BX_TOKEN_LOAD_SYMBOLS); }
ldsym { bxlval.sval = strdup(bxtext); return(BX_TOKEN_LOAD_SYMBOLS); }
symbols { bxlval.sval = strdup(bxtext); return(BX_TOKEN_SYMBOLS); }
slist { bxlval.sval = strdup(bxtext); return(BX_TOKEN_LIST_SYMBOLS); }
global { bxlval.sval = strdup(bxtext); return(BX_TOKEN_GLOBAL); }

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: parser.y,v 1.24 2007-10-23 21:51:43 sshwarts Exp $
// $Id: parser.y,v 1.25 2008-03-29 21:32:18 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
%{
@ -343,17 +343,22 @@ watch_point_command:
;
symbol_command:
BX_TOKEN_LOAD_SYMBOLS BX_TOKEN_STRING '\n'
BX_TOKEN_LOAD_SYMBOLS BX_TOKEN_STRING '\n'
{
bx_dbg_symbol_command($2, 0, 0);
free($1); free($2);
}
| BX_TOKEN_LOAD_SYMBOLS BX_TOKEN_STRING BX_TOKEN_NUMERIC '\n'
| BX_TOKEN_LOAD_SYMBOLS BX_TOKEN_STRING BX_TOKEN_NUMERIC '\n'
{
bx_dbg_symbol_command($2, 0, $3);
free($1); free($2);
}
| BX_TOKEN_LOAD_SYMBOLS BX_TOKEN_GLOBAL BX_TOKEN_STRING BX_TOKEN_NUMERIC '\n'
| BX_TOKEN_LOAD_SYMBOLS BX_TOKEN_GLOBAL BX_TOKEN_STRING '\n'
{
bx_dbg_symbol_command($3, 1, 0);
free($1); free($2); free($3);
}
| BX_TOKEN_LOAD_SYMBOLS BX_TOKEN_GLOBAL BX_TOKEN_STRING BX_TOKEN_NUMERIC '\n'
{
bx_dbg_symbol_command($3, 1, $4);
free($1); free($2); free($3);
@ -929,7 +934,7 @@ help_command:
}
| BX_TOKEN_HELP BX_TOKEN_LOAD_SYMBOLS '\n'
{
dbg_printf("load-symbols [global] <filename> [offset] - load symbols from file\n");
dbg_printf("ldsym [global] <filename> [offset] - load symbols from file\n");
free($1);free($2);
}
| BX_TOKEN_HELP BX_TOKEN_LIST_SYMBOLS '\n'

View File

@ -1,5 +1,5 @@
/////////////////////////////////////////////////////////////////////////
// $Id: symbols.cc,v 1.9 2008-03-26 22:39:07 sshwarts Exp $
// $Id: symbols.cc,v 1.10 2008-03-29 21:32:18 sshwarts Exp $
/////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2001 MandrakeSoft S.A.
@ -317,27 +317,43 @@ void bx_dbg_symbol_command(char* filename, bx_bool global, Bit32u offset)
dbg_printf ("Could not open symbol file '%s'\n", filename);
return;
}
char buf[200];
while (fgets(buf, 200, fp)) {
// Parse
char* sym_name = buf;
for (int i = 0; i < 200 && buf[i]; i++) {
if (buf[i] == ' ') {
buf[i] = '\0';
sym_name = buf + i + 1;
break;
}
}
if (sym_name == buf) {
dbg_printf ("Syntax error '%s'\n", buf);
// C++/C# symbols can be long
char buf[512];
int line_num = 1;
while (fgets(buf, sizeof(buf), fp)) {
// handle end of line (before error messages)
len = strlen(buf);
bool whole_line = (buf[len - 1] == '\n');
if (whole_line)
buf[len - 1] = 0;
// parse
char* sym_name;
Bit32u addr = strtoul(buf, &sym_name, 16);
if (!isspace(*sym_name)) {
if (*sym_name == 0)
dbg_printf("%s:%d: missing symbol name\n", filename, line_num);
else
dbg_printf("%s:%d: syntax error near '%s'\n", filename, line_num, sym_name);
break;
}
Bit32u addr = strtoul(buf, 0, 16);
if (sym_name[strlen(sym_name)-1] == '\n')
sym_name[strlen(sym_name)-1] = '\0';
++sym_name;
symbol_entry_t* sym = new symbol_entry_t(addr + offset, strdup(sym_name));
cntx->add_symbol(sym);
// skip the rest of long line
while (!whole_line) {
if (!fgets(buf, sizeof(buf), fp))
break;
// actually, last line can end without newline, but then
// we'll just break at the next iteration because of EOF
whole_line = (buf[strlen(buf)-1] == '\n');
}
++line_num;
}
}

View File

@ -1,7 +1,7 @@
<!--
================================================================
doc/docbook/user/user.dbk
$Id: user.dbk,v 1.234 2008-02-05 22:33:34 sshwarts Exp $
$Id: user.dbk,v 1.235 2008-03-29 21:32:18 sshwarts Exp $
This is the top level file for the Bochs Users Manual.
================================================================
@ -6428,7 +6428,7 @@ Remove write watch point from physical address <varname>address</varname>.
Toggles CPU mode switch breakpoint.
<screen>load-symbols [global] <varname>filename</varname> [<varname>offset</varname>]</screen>
<screen>ldsym [global] <varname>filename</varname> [<varname>offset</varname>]</screen>
Load symbols from file <varname>filename</varname>. If the global keyword is
added, then the the symbols will be visible in all contexts for which