- implemented new debugger command 'info device [string]' that shows the state
of the device specified in 'string'. Added register mechanism and chained list to store the device name and pointer. Replace hardcoded debug info implementations for pic, pci and vga by the new one. - TODO #1: improve existing debug_dump() output and add more devices - TODO #2: add support for additional arguments and replace the NE2k print_info()
This commit is contained in:
parent
9c27d279b9
commit
086266d033
@ -75,6 +75,14 @@ static struct {
|
||||
unsigned next_wpoint_id;
|
||||
} bx_debugger;
|
||||
|
||||
typedef struct _debug_info_t {
|
||||
const char *name;
|
||||
bx_devmodel_c *device;
|
||||
struct _debug_info_t *next;
|
||||
} debug_info_t;
|
||||
|
||||
static debug_info_t *bx_debug_info_list = NULL;
|
||||
|
||||
typedef struct {
|
||||
FILE *fp;
|
||||
char fname[BX_MAX_PATH];
|
||||
@ -154,6 +162,61 @@ int bx_dbg_set_rcfile(const char *rcfile)
|
||||
return bx_nest_infile((char*)rcfile);
|
||||
}
|
||||
|
||||
bx_bool bx_dbg_register_debug_info(const char *devname, void *dev)
|
||||
{
|
||||
debug_info_t *debug_info;
|
||||
|
||||
debug_info = (debug_info_t *)malloc(sizeof(debug_info_t));
|
||||
if (debug_info == NULL) {
|
||||
BX_PANIC(("can't allocate debug_info_t"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
debug_info->name = devname;
|
||||
debug_info->device = (bx_devmodel_c*)dev;
|
||||
debug_info->next = NULL;
|
||||
|
||||
if (bx_debug_info_list == NULL) {
|
||||
bx_debug_info_list = debug_info;
|
||||
} else {
|
||||
debug_info_t *temp = bx_debug_info_list;
|
||||
|
||||
while (temp->next) {
|
||||
if (!strcmp(temp->name, devname)) {
|
||||
free(debug_info);
|
||||
return 0;
|
||||
}
|
||||
temp = temp->next;
|
||||
}
|
||||
temp->next = debug_info;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void bx_dbg_info_cleanup(void)
|
||||
{
|
||||
debug_info_t *temp = bx_debug_info_list, *next;
|
||||
while (temp != NULL) {
|
||||
next = temp->next;
|
||||
free(temp);
|
||||
temp = next;
|
||||
}
|
||||
bx_debug_info_list = NULL;
|
||||
}
|
||||
|
||||
bx_bool bx_dbg_info_find_device(const char *devname, debug_info_t **found_debug_info)
|
||||
{
|
||||
debug_info_t *debug_info;
|
||||
|
||||
for (debug_info = bx_debug_info_list; debug_info; debug_info = debug_info->next) {
|
||||
if (!strcmp(debug_info->name, devname)) {
|
||||
*found_debug_info = debug_info;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int bx_dbg_main(void)
|
||||
{
|
||||
setbuf(stdout, NULL);
|
||||
@ -3287,39 +3350,37 @@ void bx_dbg_info_ne2k(int page, int reg)
|
||||
}
|
||||
|
||||
/*
|
||||
* this implements the info pic command in the debugger.
|
||||
* info pic - shows pic registers
|
||||
* this implements the info device command in the debugger.
|
||||
* info device - list devices supported by this command
|
||||
* info device [string] - shows the state of device specified in string
|
||||
*/
|
||||
void bx_dbg_info_pic()
|
||||
void bx_dbg_info_device(const char *dev)
|
||||
{
|
||||
DEV_pic_debug_dump();
|
||||
}
|
||||
debug_info_t *temp = NULL;
|
||||
|
||||
/*
|
||||
* this implements the info vga command in the debugger.
|
||||
* info vga - shows vga registers
|
||||
*/
|
||||
void bx_dbg_info_vga()
|
||||
{
|
||||
DEV_vga_debug_dump();
|
||||
}
|
||||
|
||||
/*
|
||||
* this implements the info pci command in the debugger.
|
||||
* info pci - shows i440fx state
|
||||
*/
|
||||
void bx_dbg_info_pci()
|
||||
{
|
||||
#if BX_SUPPORT_PCI
|
||||
if (SIM->get_param_bool(BXPN_I440FX_SUPPORT)->get()) {
|
||||
DEV_pci_debug_dump();
|
||||
if (strlen(dev) == 0) {
|
||||
if (bx_debug_info_list == NULL) {
|
||||
dbg_printf("info device list: no device registered\n");
|
||||
} else {
|
||||
dbg_printf("devices supported by 'info device':\n\n");
|
||||
temp = bx_debug_info_list;
|
||||
while (temp) {
|
||||
dbg_printf("%s\n", temp->name);
|
||||
temp = temp->next;
|
||||
}
|
||||
dbg_printf("\n");
|
||||
}
|
||||
} else {
|
||||
if (bx_dbg_info_find_device(dev, &temp)) {
|
||||
if (temp->device != NULL) {
|
||||
temp->device->debug_dump();
|
||||
} else {
|
||||
BX_PANIC(("info device: device pointer is NULL"));
|
||||
}
|
||||
} else {
|
||||
dbg_printf("info device: '%s' not found\n", dev);
|
||||
}
|
||||
else {
|
||||
dbg_printf("PCI support is disabled in .bochsrc\n");
|
||||
}
|
||||
#else
|
||||
dbg_printf("PCI support is not compiled in\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -199,6 +199,9 @@ void bx_add_lex_input(char *buf);
|
||||
extern int bxparse(void);
|
||||
extern void bxerror(char *s);
|
||||
|
||||
// register function for 'info device' command
|
||||
bx_bool bx_dbg_register_debug_info(const char *devname, void *dev);
|
||||
|
||||
#define EMPTY_ARG (-1)
|
||||
|
||||
bx_bool bx_dbg_read_linear(unsigned which_cpu, bx_address laddr, unsigned len, Bit8u *buf);
|
||||
@ -289,9 +292,7 @@ void bx_dbg_doit_command(unsigned);
|
||||
void bx_dbg_crc_command(bx_phy_address addr1, bx_phy_address addr2);
|
||||
void bx_dbg_linux_syscall(unsigned which_cpu);
|
||||
void bx_dbg_info_ne2k(int page, int reg);
|
||||
void bx_dbg_info_pic(void);
|
||||
void bx_dbg_info_vga(void);
|
||||
void bx_dbg_info_pci(void);
|
||||
void bx_dbg_info_device(const char *);
|
||||
void bx_dbg_print_help(void);
|
||||
void bx_dbg_calc_command(Bit64u value);
|
||||
void bx_dbg_dump_table(void);
|
||||
|
@ -106,7 +106,6 @@ pending { bxlval.sval = strdup(bxtext); return(BX_TOKEN_PENDING); }
|
||||
take { bxlval.sval = strdup(bxtext); return(BX_TOKEN_TAKE); }
|
||||
dma { bxlval.sval = strdup(bxtext); return(BX_TOKEN_DMA); }
|
||||
irq { bxlval.sval = strdup(bxtext); return(BX_TOKEN_IRQ); }
|
||||
pic { bxlval.sval = strdup(bxtext); return(BX_TOKEN_PIC); }
|
||||
u |
|
||||
disasm { BEGIN(DISASM); bxlval.sval = strdup(bxtext); return(BX_TOKEN_DISASM); }
|
||||
hex { bxlval.sval = strdup(bxtext); return(BX_TOKEN_HEX); }
|
||||
@ -138,7 +137,7 @@ print-string { bxlval.sval = strdup(bxtext); return(BX_TOKEN_PRINT_STRING); }
|
||||
ne2k|ne2000 { bxlval.sval = strdup(bxtext); return(BX_TOKEN_NE2000); }
|
||||
page { bxlval.sval = strdup(bxtext); return(BX_TOKEN_PAGE); }
|
||||
vga { bxlval.sval = strdup(bxtext); return(BX_TOKEN_VGA); }
|
||||
pci { bxlval.sval = strdup(bxtext); return(BX_TOKEN_PCI); }
|
||||
device { bxlval.sval = strdup(bxtext); return(BX_TOKEN_DEVICE); }
|
||||
all { bxlval.sval = strdup(bxtext); return(BX_TOKEN_ALL); }
|
||||
al { bxlval.uval = BX_DBG_REG8L_AL; return(BX_TOKEN_8BL_REG);}
|
||||
bl { bxlval.uval = BX_DBG_REG8L_BL; return(BX_TOKEN_8BL_REG);}
|
||||
|
@ -110,12 +110,11 @@
|
||||
%token <sval> BX_TOKEN_PRINT_STRING
|
||||
%token <uval> BX_TOKEN_NUMERIC
|
||||
%token <sval> BX_TOKEN_NE2000
|
||||
%token <sval> BX_TOKEN_PIC
|
||||
%token <sval> BX_TOKEN_PAGE
|
||||
%token <sval> BX_TOKEN_HELP
|
||||
%token <sval> BX_TOKEN_CALC
|
||||
%token <sval> BX_TOKEN_VGA
|
||||
%token <sval> BX_TOKEN_PCI
|
||||
%token <sval> BX_TOKEN_DEVICE
|
||||
%token <sval> BX_TOKEN_COMMAND
|
||||
%token <sval> BX_TOKEN_GENERIC
|
||||
%token BX_TOKEN_RSHIFT
|
||||
@ -631,19 +630,14 @@ info_command:
|
||||
free($1); free($2); free($3); free($5);
|
||||
bx_dbg_info_ne2k($4, $6);
|
||||
}
|
||||
| BX_TOKEN_INFO BX_TOKEN_PIC '\n'
|
||||
| BX_TOKEN_INFO BX_TOKEN_DEVICE '\n'
|
||||
{
|
||||
bx_dbg_info_pic();
|
||||
bx_dbg_info_device("");
|
||||
free($1); free($2);
|
||||
}
|
||||
| BX_TOKEN_INFO BX_TOKEN_VGA '\n'
|
||||
| BX_TOKEN_INFO BX_TOKEN_DEVICE BX_TOKEN_STRING '\n'
|
||||
{
|
||||
bx_dbg_info_vga();
|
||||
free($1); free($2);
|
||||
}
|
||||
| BX_TOKEN_INFO BX_TOKEN_PCI '\n'
|
||||
{
|
||||
bx_dbg_info_pci();
|
||||
bx_dbg_info_device($3);
|
||||
free($1); free($2);
|
||||
}
|
||||
;
|
||||
@ -1133,10 +1127,9 @@ help_command:
|
||||
dbg_printf("info tab - show page tables\n");
|
||||
dbg_printf("info eflags - show decoded EFLAGS register\n");
|
||||
dbg_printf("info symbols [string] - list symbols whose prefix is string\n");
|
||||
dbg_printf("info pic - show PICs registers\n");
|
||||
dbg_printf("info ne2000 - show NE2000 registers\n");
|
||||
dbg_printf("info vga - show vga registers\n");
|
||||
dbg_printf("info pci - show i440fx PCI state\n");
|
||||
dbg_printf("info device - show list of devices supported by this command\n");
|
||||
dbg_printf("info device [string]- show state of device specified in string\n");
|
||||
free($1);free($2);
|
||||
}
|
||||
| BX_TOKEN_HELP BX_TOKEN_SHOW '\n'
|
||||
|
@ -104,6 +104,11 @@ void bx_pci_bridge_c::init(void)
|
||||
BX_PCI_THIS pci_conf[0x02] = 0x37;
|
||||
BX_PCI_THIS pci_conf[0x03] = 0x12;
|
||||
BX_PCI_THIS pci_conf[0x0b] = 0x06;
|
||||
|
||||
#if BX_DEBUGGER
|
||||
// register device for the 'info device' command (calls debug_dump())
|
||||
bx_dbg_register_debug_info("pci", this);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -379,9 +384,9 @@ void bx_pci_bridge_c::smram_control(Bit8u value8)
|
||||
BX_PCI_THIS pci_conf[0x72] = value8;
|
||||
}
|
||||
|
||||
#if BX_DEBUGGER
|
||||
void bx_pci_bridge_c::debug_dump()
|
||||
{
|
||||
#if BX_DEBUGGER
|
||||
int i;
|
||||
|
||||
dbg_printf("i440fx ConfAddr = 0x%08x\n", BX_PCI_THIS confAddr);
|
||||
@ -395,10 +400,10 @@ void bx_pci_bridge_c::debug_dump()
|
||||
for (i=0x59; i<0x60; i++) {
|
||||
dbg_printf("i440fx PAM reg 0x%02x = 0x%02x\n", i, BX_PCI_THIS pci_conf[i]);
|
||||
}
|
||||
dbg_printf("i440fx SMRAM control = 0x%02\nx", BX_PCI_THIS pci_conf[0x72]);
|
||||
dbg_printf("i440fx SMRAM control = 0x%02x\n", BX_PCI_THIS pci_conf[0x72]);
|
||||
#endif /* DUMP_FULL_I440FX */
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
bx_bool bx_pci_bridge_c::register_pci_handlers(bx_pci_device_stub_c *dev,
|
||||
Bit8u *devfunc, const char *name,
|
||||
|
@ -62,8 +62,9 @@ public:
|
||||
|
||||
virtual Bit32u pci_read_handler(Bit8u address, unsigned io_len);
|
||||
virtual void pci_write_handler(Bit8u address, Bit32u value, unsigned io_len);
|
||||
|
||||
#if BX_DEBUGGER
|
||||
virtual void debug_dump(void);
|
||||
#endif
|
||||
|
||||
private:
|
||||
Bit8u pci_handler_id[0x100]; // 256 devices/functions
|
||||
|
@ -118,6 +118,11 @@ void bx_pic_c::init(void)
|
||||
BX_PIC_THIS s.slave_pic.rotate_on_autoeoi = 0;
|
||||
BX_PIC_THIS s.slave_pic.edge_level = 0;
|
||||
BX_PIC_THIS s.slave_pic.IRQ_in = 0;
|
||||
|
||||
#if BX_DEBUGGER
|
||||
// register device for the 'info device' command (calls debug_dump())
|
||||
bx_dbg_register_debug_info("pic", this);
|
||||
#endif
|
||||
}
|
||||
|
||||
void bx_pic_c::reset(unsigned type) {}
|
||||
|
@ -124,6 +124,10 @@ void bx_vgacore_c::init(void)
|
||||
if (!BX_VGA_THIS pci_enabled) {
|
||||
BX_MEM(0)->load_ROM(SIM->get_param_string(BXPN_VGA_ROM_PATH)->getptr(), 0xc0000, 1);
|
||||
}
|
||||
#if BX_DEBUGGER
|
||||
// register device for the 'info device' command (calls debug_dump())
|
||||
bx_dbg_register_debug_info("vga", this);
|
||||
#endif
|
||||
}
|
||||
|
||||
void bx_vgacore_c::init_standard_vga(void)
|
||||
|
@ -208,7 +208,6 @@ extern "C" {
|
||||
#define DEV_pic_raise_irq(b) (bx_devices.pluginPicDevice->raise_irq(b))
|
||||
#define DEV_pic_set_mode(a,b) (bx_devices.pluginPicDevice->set_mode(a,b))
|
||||
#define DEV_pic_iac() (bx_devices.pluginPicDevice->IAC())
|
||||
#define DEV_pic_debug_dump() (bx_devices.pluginPicDevice->debug_dump())
|
||||
|
||||
///////// VGA macros
|
||||
#define DEV_vga_mem_read(addr) (bx_devices.pluginVgaDevice->mem_read(addr))
|
||||
@ -223,7 +222,6 @@ extern "C" {
|
||||
#define DEV_vga_refresh() \
|
||||
(bx_devices.pluginVgaDevice->trigger_timer(bx_devices.pluginVgaDevice))
|
||||
#define DEV_vga_set_override(a) (bx_devices.pluginVgaDevice->set_override(a))
|
||||
#define DEV_vga_debug_dump() (bx_devices.pluginVgaDevice->debug_dump())
|
||||
|
||||
///////// PCI macros
|
||||
#define DEV_register_pci_handlers(a,b,c,d) \
|
||||
@ -234,7 +232,6 @@ extern "C" {
|
||||
(bx_devices.pluginPciBridge->pci_set_base_mem(a,b,c,d,e,f))
|
||||
#define DEV_pci_set_base_io(a,b,c,d,e,f,g,h) \
|
||||
(bx_devices.pluginPciBridge->pci_set_base_io(a,b,c,d,e,f,g,h))
|
||||
#define DEV_pci_debug_dump() bx_devices.pluginPciBridge->debug_dump()
|
||||
#define DEV_ide_bmdma_present() bx_devices.pluginPciIdeController->bmdma_present()
|
||||
#define DEV_ide_bmdma_set_irq(a) bx_devices.pluginPciIdeController->bmdma_set_irq(a)
|
||||
#define DEV_acpi_generate_smi(a) bx_devices.pluginACPIController->generate_smi(a)
|
||||
|
Loading…
x
Reference in New Issue
Block a user