2003-11-28 18:07:29 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 01:05:47 +03:00
|
|
|
// $Id$
|
2003-11-28 18:07:29 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2011-03-19 23:09:34 +03:00
|
|
|
// Copyright (C) 2001-2011 The Bochs Project
|
2003-11-28 18:07:29 +03:00
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
2009-02-08 12:05:52 +03:00
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2003-11-28 18:07:29 +03:00
|
|
|
|
2011-12-29 02:43:18 +04:00
|
|
|
#ifndef BX_DEBUG_H
|
|
|
|
#define BX_DEBUG_H
|
2003-11-28 18:07:29 +03:00
|
|
|
|
|
|
|
// if including from C parser, need basic types etc
|
|
|
|
#include "config.h"
|
|
|
|
#include "osdep.h"
|
|
|
|
|
|
|
|
#define BX_DBG_NO_HANDLE 1000
|
|
|
|
|
2006-01-24 22:03:55 +03:00
|
|
|
Bit32u crc32(const Bit8u *buf, int len);
|
2003-11-28 18:07:29 +03:00
|
|
|
|
|
|
|
#if BX_DEBUGGER
|
|
|
|
|
|
|
|
// some strict C declarations needed by the parser/lexer
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2009-11-10 00:26:09 +03:00
|
|
|
extern Bit32u dbg_cpu;
|
|
|
|
|
2006-01-24 22:03:55 +03:00
|
|
|
void dbg_printf (const char *fmt, ...);
|
|
|
|
|
2006-01-25 21:13:44 +03:00
|
|
|
typedef enum {
|
|
|
|
BX_DBG_SREG_ES,
|
|
|
|
BX_DBG_SREG_CS,
|
|
|
|
BX_DBG_SREG_SS,
|
|
|
|
BX_DBG_SREG_DS,
|
|
|
|
BX_DBG_SREG_FS,
|
|
|
|
BX_DBG_SREG_GS
|
|
|
|
} SRegs;
|
|
|
|
|
2006-01-31 22:45:34 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
# define BX_DBG_GEN_REGISTERS 16
|
|
|
|
#else
|
|
|
|
# define BX_DBG_GEN_REGISTERS 8
|
|
|
|
#endif
|
2006-01-27 22:50:00 +03:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
BX_DBG_REG8H_AH,
|
|
|
|
BX_DBG_REG8H_CH,
|
|
|
|
BX_DBG_REG8H_DH,
|
|
|
|
BX_DBG_REG8H_BH,
|
|
|
|
} Regs8H;
|
|
|
|
|
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
|
2006-01-25 21:13:44 +03:00
|
|
|
typedef enum {
|
|
|
|
BX_DBG_REG8L_AL,
|
|
|
|
BX_DBG_REG8L_CL,
|
|
|
|
BX_DBG_REG8L_DL,
|
|
|
|
BX_DBG_REG8L_BL,
|
2006-01-27 22:50:00 +03:00
|
|
|
BX_DBG_REG8L_SPL,
|
|
|
|
BX_DBG_REG8L_BPL,
|
|
|
|
BX_DBG_REG8L_SIL,
|
|
|
|
BX_DBG_REG8L_DIL,
|
|
|
|
BX_DBG_REG8L_R8,
|
|
|
|
BX_DBG_REG8L_R9,
|
|
|
|
BX_DBG_REG8L_R10,
|
|
|
|
BX_DBG_REG8L_R11,
|
|
|
|
BX_DBG_REG8L_R12,
|
|
|
|
BX_DBG_REG8L_R13,
|
|
|
|
BX_DBG_REG8L_R14,
|
|
|
|
BX_DBG_REG8L_R15
|
|
|
|
} Regs8L;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
BX_DBG_REG16_AX,
|
|
|
|
BX_DBG_REG16_CX,
|
|
|
|
BX_DBG_REG16_DX,
|
|
|
|
BX_DBG_REG16_BX,
|
|
|
|
BX_DBG_REG16_SP,
|
|
|
|
BX_DBG_REG16_BP,
|
|
|
|
BX_DBG_REG16_SI,
|
|
|
|
BX_DBG_REG16_DI,
|
|
|
|
BX_DBG_REG16_R8,
|
|
|
|
BX_DBG_REG16_R9,
|
|
|
|
BX_DBG_REG16_R10,
|
|
|
|
BX_DBG_REG16_R11,
|
|
|
|
BX_DBG_REG16_R12,
|
|
|
|
BX_DBG_REG16_R13,
|
|
|
|
BX_DBG_REG16_R14,
|
|
|
|
BX_DBG_REG16_R15
|
|
|
|
} Regs16;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
BX_DBG_REG32_EAX,
|
|
|
|
BX_DBG_REG32_ECX,
|
|
|
|
BX_DBG_REG32_EDX,
|
|
|
|
BX_DBG_REG32_EBX,
|
|
|
|
BX_DBG_REG32_ESP,
|
|
|
|
BX_DBG_REG32_EBP,
|
|
|
|
BX_DBG_REG32_ESI,
|
|
|
|
BX_DBG_REG32_EDI,
|
|
|
|
BX_DBG_REG32_R8,
|
|
|
|
BX_DBG_REG32_R9,
|
|
|
|
BX_DBG_REG32_R10,
|
|
|
|
BX_DBG_REG32_R11,
|
|
|
|
BX_DBG_REG32_R12,
|
|
|
|
BX_DBG_REG32_R13,
|
|
|
|
BX_DBG_REG32_R14,
|
|
|
|
BX_DBG_REG32_R15
|
|
|
|
} Regs32;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
BX_DBG_REG64_RAX,
|
|
|
|
BX_DBG_REG64_RCX,
|
|
|
|
BX_DBG_REG64_RDX,
|
|
|
|
BX_DBG_REG64_RBX,
|
|
|
|
BX_DBG_REG64_RSP,
|
|
|
|
BX_DBG_REG64_RBP,
|
|
|
|
BX_DBG_REG64_RSI,
|
|
|
|
BX_DBG_REG64_RDI,
|
|
|
|
BX_DBG_REG64_R8,
|
|
|
|
BX_DBG_REG64_R9,
|
|
|
|
BX_DBG_REG64_R10,
|
|
|
|
BX_DBG_REG64_R11,
|
|
|
|
BX_DBG_REG64_R12,
|
|
|
|
BX_DBG_REG64_R13,
|
|
|
|
BX_DBG_REG64_R14,
|
|
|
|
BX_DBG_REG64_R15
|
|
|
|
} Regs64;
|
2006-01-25 21:13:44 +03:00
|
|
|
|
2006-01-27 22:50:00 +03:00
|
|
|
#else
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
BX_DBG_REG8L_AL,
|
|
|
|
BX_DBG_REG8L_CL,
|
|
|
|
BX_DBG_REG8L_DL,
|
|
|
|
BX_DBG_REG8L_BL
|
|
|
|
} Regs8L;
|
2006-01-25 21:13:44 +03:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
BX_DBG_REG16_AX,
|
|
|
|
BX_DBG_REG16_CX,
|
|
|
|
BX_DBG_REG16_DX,
|
|
|
|
BX_DBG_REG16_BX,
|
|
|
|
BX_DBG_REG16_SP,
|
|
|
|
BX_DBG_REG16_BP,
|
|
|
|
BX_DBG_REG16_SI,
|
|
|
|
BX_DBG_REG16_DI
|
|
|
|
} Regs16;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
BX_DBG_REG32_EAX,
|
|
|
|
BX_DBG_REG32_ECX,
|
|
|
|
BX_DBG_REG32_EDX,
|
|
|
|
BX_DBG_REG32_EBX,
|
|
|
|
BX_DBG_REG32_ESP,
|
|
|
|
BX_DBG_REG32_EBP,
|
|
|
|
BX_DBG_REG32_ESI,
|
|
|
|
BX_DBG_REG32_EDI
|
|
|
|
} Regs32;
|
2003-11-28 18:07:29 +03:00
|
|
|
|
2006-01-27 22:50:00 +03:00
|
|
|
#endif
|
|
|
|
|
2003-11-28 18:07:29 +03:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
bkRegular,
|
|
|
|
bkAtIP,
|
|
|
|
bkStepOver
|
|
|
|
} BreakpointKind;
|
|
|
|
|
2006-02-12 23:21:36 +03:00
|
|
|
typedef enum _show_flags {
|
|
|
|
Flag_call = 0x1,
|
|
|
|
Flag_ret = 0x2,
|
|
|
|
Flag_softint = 0x4,
|
|
|
|
Flag_iret = 0x8,
|
|
|
|
Flag_intsig = 0x10,
|
2011-05-06 12:19:03 +04:00
|
|
|
Flag_mode = 0x20,
|
2006-02-12 23:21:36 +03:00
|
|
|
} show_flags_t;
|
|
|
|
|
2003-11-28 18:07:29 +03:00
|
|
|
// Flex defs
|
|
|
|
extern int bxlex(void);
|
|
|
|
extern char *bxtext; // Using the pointer option rather than array
|
|
|
|
extern int bxwrap(void);
|
|
|
|
void bx_add_lex_input(char *buf);
|
|
|
|
|
|
|
|
// Yacc defs
|
|
|
|
extern int bxparse(void);
|
|
|
|
extern void bxerror(char *s);
|
|
|
|
|
2012-03-10 21:14:07 +04:00
|
|
|
// register function for 'info device' command
|
|
|
|
bx_bool bx_dbg_register_debug_info(const char *devname, void *dev);
|
|
|
|
|
2003-11-28 18:07:29 +03:00
|
|
|
#define EMPTY_ARG (-1)
|
|
|
|
|
2009-08-07 12:26:41 +04:00
|
|
|
bx_bool bx_dbg_read_linear(unsigned which_cpu, bx_address laddr, unsigned len, Bit8u *buf);
|
2003-11-28 18:07:29 +03:00
|
|
|
Bit16u bx_dbg_get_selector_value(unsigned int seg_no);
|
2006-01-31 22:45:34 +03:00
|
|
|
Bit16u bx_dbg_get_ip (void);
|
|
|
|
Bit32u bx_dbg_get_eip(void);
|
2006-02-13 21:28:14 +03:00
|
|
|
bx_address bx_dbg_get_instruction_pointer(void);
|
2006-01-25 21:13:44 +03:00
|
|
|
Bit8u bx_dbg_get_reg8l_value(unsigned reg);
|
|
|
|
Bit8u bx_dbg_get_reg8h_value(unsigned reg);
|
|
|
|
Bit16u bx_dbg_get_reg16_value(unsigned reg);
|
|
|
|
Bit32u bx_dbg_get_reg32_value(unsigned reg);
|
2006-02-13 21:28:14 +03:00
|
|
|
Bit64u bx_dbg_get_reg64_value(unsigned reg);
|
2006-01-25 21:13:44 +03:00
|
|
|
void bx_dbg_set_reg8l_value(unsigned reg, Bit8u value);
|
|
|
|
void bx_dbg_set_reg8h_value(unsigned reg, Bit8u value);
|
|
|
|
void bx_dbg_set_reg16_value(unsigned reg, Bit16u value);
|
|
|
|
void bx_dbg_set_reg32_value(unsigned reg, Bit32u value);
|
2006-02-13 21:28:14 +03:00
|
|
|
void bx_dbg_set_reg64_value(unsigned reg, Bit64u value);
|
2012-11-07 00:01:02 +04:00
|
|
|
void bx_dbg_set_rip_value(bx_address value);
|
2009-12-27 19:38:09 +03:00
|
|
|
void bx_dbg_load_segreg(unsigned reg, unsigned value);
|
2009-04-07 20:12:19 +04:00
|
|
|
bx_address bx_dbg_get_laddr(Bit16u sel, bx_address ofs);
|
2003-11-28 18:07:29 +03:00
|
|
|
void bx_dbg_step_over_command(void);
|
2006-01-31 22:45:34 +03:00
|
|
|
void bx_dbg_trace_command(bx_bool enable);
|
|
|
|
void bx_dbg_trace_reg_command(bx_bool enable);
|
2008-04-19 17:21:23 +04:00
|
|
|
void bx_dbg_trace_mem_command(bx_bool enable);
|
2003-11-28 18:07:29 +03:00
|
|
|
void bx_dbg_ptime_command(void);
|
|
|
|
void bx_dbg_timebp_command(bx_bool absolute, Bit64u time);
|
|
|
|
#define MAX_CONCURRENT_BPS 5
|
|
|
|
extern int timebp_timer;
|
|
|
|
extern Bit64u timebp_queue[MAX_CONCURRENT_BPS];
|
|
|
|
extern int timebp_queue_size;
|
2006-01-24 00:44:44 +03:00
|
|
|
void bx_dbg_modebp_command(void);
|
2011-05-06 12:19:03 +04:00
|
|
|
void bx_dbg_vmexitbp_command(void);
|
2003-11-28 18:07:29 +03:00
|
|
|
void bx_dbg_where_command(void);
|
2006-02-03 01:33:32 +03:00
|
|
|
void bx_dbg_print_string_command(bx_address addr);
|
2007-09-24 01:10:06 +04:00
|
|
|
void bx_dbg_xlate_address(bx_lin_address address);
|
2006-02-12 00:19:22 +03:00
|
|
|
void bx_dbg_show_command(const char*);
|
2006-02-03 01:33:32 +03:00
|
|
|
void bx_dbg_print_stack_command(unsigned nwords);
|
2009-04-03 21:36:24 +04:00
|
|
|
void bx_dbg_print_watchpoints(void);
|
2009-11-20 15:02:57 +03:00
|
|
|
void bx_dbg_watchpoint_continue(bx_bool watch_continue);
|
|
|
|
void bx_dbg_watch(int type, bx_phy_address address, Bit32u len);
|
2009-04-03 21:36:24 +04:00
|
|
|
void bx_dbg_unwatch_all(void);
|
2008-10-08 21:13:35 +04:00
|
|
|
void bx_dbg_unwatch(bx_phy_address handle);
|
2003-11-28 18:07:29 +03:00
|
|
|
void bx_dbg_continue_command(void);
|
2009-10-29 18:49:50 +03:00
|
|
|
void bx_dbg_stepN_command(int cpu, Bit32u count);
|
2006-01-25 00:37:37 +03:00
|
|
|
void bx_dbg_set_auto_disassemble(bx_bool enable);
|
|
|
|
void bx_dbg_disassemble_switch_mode(void);
|
2009-12-28 16:44:32 +03:00
|
|
|
void bx_dbg_disassemble_hex_mode_switch(int mode);
|
2006-01-25 00:37:37 +03:00
|
|
|
void bx_dbg_set_disassemble_size(unsigned size);
|
2003-11-28 18:07:29 +03:00
|
|
|
void bx_dbg_del_breakpoint_command(unsigned handle);
|
|
|
|
void bx_dbg_en_dis_breakpoint_command(unsigned handle, bx_bool enable);
|
2006-06-12 23:51:31 +04:00
|
|
|
bx_bool bx_dbg_en_dis_pbreak(unsigned handle, bx_bool enable);
|
|
|
|
bx_bool bx_dbg_en_dis_lbreak(unsigned handle, bx_bool enable);
|
|
|
|
bx_bool bx_dbg_en_dis_vbreak(unsigned handle, bx_bool enable);
|
2003-11-28 18:07:29 +03:00
|
|
|
bx_bool bx_dbg_del_pbreak(unsigned handle);
|
2006-06-12 23:51:31 +04:00
|
|
|
bx_bool bx_dbg_del_lbreak(unsigned handle);
|
|
|
|
bx_bool bx_dbg_del_vbreak(unsigned handle);
|
2006-02-01 21:12:08 +03:00
|
|
|
int bx_dbg_vbreakpoint_command(BreakpointKind bk, Bit32u cs, bx_address eip);
|
|
|
|
int bx_dbg_lbreakpoint_command(BreakpointKind bk, bx_address laddress);
|
2007-10-09 23:49:23 +04:00
|
|
|
int bx_dbg_pbreakpoint_command(BreakpointKind bk, bx_phy_address paddress);
|
2003-11-28 18:07:29 +03:00
|
|
|
void bx_dbg_info_bpoints_command(void);
|
|
|
|
void bx_dbg_quit_command(void);
|
2011-03-19 20:19:41 +03:00
|
|
|
#define BX_INFO_GENERAL_PURPOSE_REGS 0x01 /* bitmasks - choices for bx_dbg_info_registers_command */
|
|
|
|
#define BX_INFO_FPU_REGS 0x02
|
|
|
|
#define BX_INFO_MMX_REGS 0x04
|
|
|
|
#define BX_INFO_SSE_REGS 0x08
|
2011-03-19 23:09:34 +03:00
|
|
|
#define BX_INFO_AVX_REGS 0x10
|
2008-02-06 01:33:35 +03:00
|
|
|
void bx_dbg_info_registers_command(int);
|
2006-02-14 00:32:21 +03:00
|
|
|
void bx_dbg_info_ivt_command(unsigned from, unsigned to);
|
|
|
|
void bx_dbg_info_idt_command(unsigned from, unsigned to);
|
|
|
|
void bx_dbg_info_gdt_command(unsigned from, unsigned to);
|
|
|
|
void bx_dbg_info_ldt_command(unsigned from, unsigned to);
|
|
|
|
void bx_dbg_info_tss_command(void);
|
2009-08-07 12:26:41 +04:00
|
|
|
void bx_dbg_info_debug_regs_command(void);
|
2003-11-28 18:07:29 +03:00
|
|
|
void bx_dbg_info_control_regs_command(void);
|
2007-10-24 01:51:44 +04:00
|
|
|
void bx_dbg_info_segment_regs_command(void);
|
2003-11-28 18:07:29 +03:00
|
|
|
void bx_dbg_info_flags(void);
|
|
|
|
void bx_dbg_info_linux_command(void);
|
2011-02-11 12:56:23 +03:00
|
|
|
void bx_dbg_examine_command(const char *command, const char *format, bx_bool format_passed,
|
2007-10-09 23:49:23 +04:00
|
|
|
bx_address addr, bx_bool addr_passed);
|
2010-01-05 16:59:08 +03:00
|
|
|
Bit32u bx_dbg_lin_indirect(bx_address addr);
|
|
|
|
Bit32u bx_dbg_phy_indirect(bx_phy_address addr);
|
2012-04-24 15:01:59 +04:00
|
|
|
void bx_dbg_writemem_command(const char *filename, bx_address laddr, unsigned len);
|
2007-10-09 23:49:23 +04:00
|
|
|
void bx_dbg_setpmem_command(bx_phy_address addr, unsigned len, Bit32u val);
|
2006-02-12 00:19:22 +03:00
|
|
|
void bx_dbg_query_command(const char *);
|
|
|
|
void bx_dbg_take_command(const char *, unsigned n);
|
2006-10-22 01:28:20 +04:00
|
|
|
void bx_dbg_disassemble_current(const char *);
|
|
|
|
void bx_dbg_disassemble_command(const char *, Bit64u from, Bit64u to);
|
2005-04-08 22:30:34 +04:00
|
|
|
void bx_dbg_instrument_command(const char *);
|
2003-11-28 18:07:29 +03:00
|
|
|
void bx_dbg_doit_command(unsigned);
|
2007-10-09 23:49:23 +04:00
|
|
|
void bx_dbg_crc_command(bx_phy_address addr1, bx_phy_address addr2);
|
2006-01-27 22:50:00 +03:00
|
|
|
void bx_dbg_linux_syscall(unsigned which_cpu);
|
2012-04-23 21:06:19 +04:00
|
|
|
void bx_dbg_info_device(const char *, const char *);
|
2006-01-24 22:03:55 +03:00
|
|
|
void bx_dbg_print_help(void);
|
2003-11-28 18:07:29 +03:00
|
|
|
void bx_dbg_calc_command(Bit64u value);
|
2006-02-11 23:47:22 +03:00
|
|
|
void bx_dbg_dump_table(void);
|
2008-04-19 17:21:23 +04:00
|
|
|
|
|
|
|
// callbacks from CPU
|
2006-06-22 23:53:58 +04:00
|
|
|
void bx_dbg_exception(unsigned cpu, Bit8u vector, Bit16u error_code);
|
|
|
|
void bx_dbg_interrupt(unsigned cpu, Bit8u vector, Bit16u error_code);
|
2008-03-24 00:39:01 +03:00
|
|
|
void bx_dbg_halt(unsigned cpu);
|
2006-06-22 23:53:58 +04:00
|
|
|
|
2008-04-19 17:21:23 +04:00
|
|
|
// memory trace callbacks from CPU, len=1,2,4 or 8
|
|
|
|
void bx_dbg_lin_memory_access(unsigned cpu, bx_address lin, bx_phy_address phy, unsigned len, unsigned pl, unsigned rw, Bit8u *data);
|
2012-01-18 02:02:19 +04:00
|
|
|
void bx_dbg_phy_memory_access(unsigned cpu, bx_phy_address phy, unsigned len, unsigned rw, unsigned attr, Bit8u *data);
|
2008-04-19 17:21:23 +04:00
|
|
|
|
2008-06-01 00:59:38 +04:00
|
|
|
// check memory access for watchpoints
|
2008-08-08 01:09:30 +04:00
|
|
|
void bx_dbg_check_memory_watchpoints(unsigned cpu, bx_phy_address phy, unsigned len, unsigned rw);
|
2008-06-01 00:59:38 +04:00
|
|
|
|
2007-10-14 23:04:51 +04:00
|
|
|
// commands that work with Bochs param tree
|
|
|
|
void bx_dbg_restore_command(const char *param_name, const char *path);
|
2009-05-03 23:29:19 +04:00
|
|
|
void bx_dbg_show_param_command(const char *param);
|
2007-10-14 23:04:51 +04:00
|
|
|
|
2006-02-12 23:21:36 +03:00
|
|
|
int bx_dbg_show_symbolic(void);
|
2012-11-07 00:10:32 +04:00
|
|
|
void bx_dbg_set_symbol_command(const char *symbol, bx_address val);
|
2009-05-03 23:21:38 +04:00
|
|
|
const char* bx_dbg_symbolic_address(Bit32u context, Bit32u eip, Bit32u base);
|
|
|
|
const char* bx_dbg_symbolic_address_16bit(Bit32u eip, Bit32u cs);
|
|
|
|
int bx_dbg_symbol_command(const char* filename, bx_bool global, Bit32u offset);
|
|
|
|
void bx_dbg_info_symbols_command(const char *Symbol);
|
|
|
|
int bx_dbg_lbreakpoint_symbol_command(const char *Symbol);
|
|
|
|
Bit32u bx_dbg_get_symbol_value(const char *Symbol);
|
|
|
|
const char* bx_dbg_disasm_symbolic_address(Bit32u eip, Bit32u base);
|
2006-02-12 00:19:22 +03:00
|
|
|
|
2003-11-28 18:07:29 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// the rest for C++
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
|
|
|
typedef enum {
|
2008-06-01 00:59:38 +04:00
|
|
|
STOP_NO_REASON = 0,
|
|
|
|
STOP_TIME_BREAK_POINT,
|
|
|
|
STOP_READ_WATCH_POINT,
|
|
|
|
STOP_WRITE_WATCH_POINT,
|
|
|
|
STOP_MAGIC_BREAK_POINT,
|
|
|
|
STOP_MODE_BREAK_POINT,
|
2011-05-06 12:19:03 +04:00
|
|
|
STOP_VMEXIT_BREAK_POINT,
|
|
|
|
STOP_CPU_HALTED,
|
2003-11-28 18:07:29 +03:00
|
|
|
} stop_reason_t;
|
|
|
|
|
|
|
|
typedef enum {
|
2008-06-01 00:59:38 +04:00
|
|
|
BREAK_POINT_MAGIC, BREAK_POINT_READ, BREAK_POINT_WRITE, BREAK_POINT_TIME
|
2003-11-28 18:07:29 +03:00
|
|
|
} break_point_t;
|
|
|
|
|
|
|
|
#define BX_DBG_PENDING_DMA 1
|
|
|
|
#define BX_DBG_PENDING_IRQ 2
|
|
|
|
|
2006-06-12 23:51:31 +04:00
|
|
|
void bx_debug_break(void);
|
2003-11-28 18:07:29 +03:00
|
|
|
|
|
|
|
void bx_dbg_exit(int code);
|
|
|
|
#if BX_DBG_EXTENSIONS
|
2008-06-01 00:59:38 +04:00
|
|
|
int bx_dbg_extensions(char *command);
|
2003-11-28 18:07:29 +03:00
|
|
|
#else
|
|
|
|
#define bx_dbg_extensions(command) 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//
|
|
|
|
// code for guards...
|
|
|
|
//
|
|
|
|
|
2006-02-01 21:12:08 +03:00
|
|
|
#define BX_DBG_GUARD_IADDR_VIR 0x0001
|
|
|
|
#define BX_DBG_GUARD_IADDR_LIN 0x0002
|
|
|
|
#define BX_DBG_GUARD_IADDR_PHY 0x0004
|
2003-11-28 18:07:29 +03:00
|
|
|
#define BX_DBG_GUARD_IADDR_ALL (BX_DBG_GUARD_IADDR_VIR | \
|
|
|
|
BX_DBG_GUARD_IADDR_LIN | \
|
|
|
|
BX_DBG_GUARD_IADDR_PHY)
|
|
|
|
|
2011-08-17 23:51:32 +04:00
|
|
|
#define BX_DBG_GUARD_ICOUNT 0x0010
|
|
|
|
|
2003-11-28 18:07:29 +03:00
|
|
|
typedef struct {
|
2009-03-10 19:28:01 +03:00
|
|
|
unsigned guard_for;
|
2003-11-28 18:07:29 +03:00
|
|
|
|
|
|
|
// instruction address breakpoints
|
|
|
|
struct {
|
2007-10-13 02:11:25 +04:00
|
|
|
#if (BX_DBG_MAX_VIR_BPOINTS > 0)
|
2003-11-28 18:07:29 +03:00
|
|
|
unsigned num_virtual;
|
|
|
|
struct {
|
|
|
|
Bit32u cs; // only use 16 bits
|
2006-02-01 21:12:08 +03:00
|
|
|
bx_address eip;
|
2003-11-28 18:07:29 +03:00
|
|
|
unsigned bpoint_id;
|
|
|
|
bx_bool enabled;
|
2005-04-08 22:30:34 +04:00
|
|
|
} vir[BX_DBG_MAX_VIR_BPOINTS];
|
2003-11-28 18:07:29 +03:00
|
|
|
#endif
|
|
|
|
|
2007-10-13 02:11:25 +04:00
|
|
|
#if (BX_DBG_MAX_LIN_BPOINTS > 0)
|
2003-11-28 18:07:29 +03:00
|
|
|
unsigned num_linear;
|
|
|
|
struct {
|
2006-02-01 21:12:08 +03:00
|
|
|
bx_address addr;
|
2003-11-28 18:07:29 +03:00
|
|
|
unsigned bpoint_id;
|
|
|
|
bx_bool enabled;
|
2005-04-08 22:30:34 +04:00
|
|
|
} lin[BX_DBG_MAX_LIN_BPOINTS];
|
2003-11-28 18:07:29 +03:00
|
|
|
#endif
|
|
|
|
|
2007-10-13 02:11:25 +04:00
|
|
|
#if (BX_DBG_MAX_PHY_BPOINTS > 0)
|
2003-11-28 18:07:29 +03:00
|
|
|
unsigned num_physical;
|
|
|
|
struct {
|
2009-11-20 00:28:25 +03:00
|
|
|
bx_phy_address addr;
|
2003-11-28 18:07:29 +03:00
|
|
|
unsigned bpoint_id;
|
|
|
|
bx_bool enabled;
|
2005-04-08 22:30:34 +04:00
|
|
|
} phy[BX_DBG_MAX_PHY_BPOINTS];
|
2003-11-28 18:07:29 +03:00
|
|
|
#endif
|
2005-04-08 22:30:34 +04:00
|
|
|
} iaddr;
|
2003-11-28 18:07:29 +03:00
|
|
|
|
2011-08-11 23:40:51 +04:00
|
|
|
// user typed Ctrl-C, requesting simulator stop at next convinient spot
|
2003-11-28 18:07:29 +03:00
|
|
|
volatile bx_bool interrupt_requested;
|
|
|
|
|
|
|
|
// booleans to control whether simulator should report events
|
|
|
|
// to debug controller
|
|
|
|
struct {
|
2005-04-08 22:30:34 +04:00
|
|
|
bx_bool irq;
|
|
|
|
bx_bool a20;
|
|
|
|
bx_bool io;
|
|
|
|
bx_bool dma;
|
|
|
|
} report;
|
2003-11-28 18:07:29 +03:00
|
|
|
|
|
|
|
struct {
|
|
|
|
bx_bool irq; // should process IRQs asynchronously
|
|
|
|
bx_bool dma; // should process DMAs asynchronously
|
2005-04-08 22:30:34 +04:00
|
|
|
} async;
|
2003-11-28 18:07:29 +03:00
|
|
|
|
|
|
|
#define BX_DBG_ASYNC_PENDING_A20 0x01
|
|
|
|
#define BX_DBG_ASYNC_PENDING_RESET 0x02
|
|
|
|
#define BX_DBG_ASYNC_PENDING_NMI 0x04
|
|
|
|
|
|
|
|
// Asynchronous changes which are pending. These are Q'd by
|
|
|
|
// the debugger, as the master simulator is notified of a pending
|
|
|
|
// async change. At the simulator's next point, where it checks for
|
|
|
|
// such events, it notifies the debugger with acknowlegement. This
|
|
|
|
// field contains a logically or'd list of all events which should
|
|
|
|
// be checked, and ack'd.
|
|
|
|
struct {
|
|
|
|
unsigned which; // logical OR of above constants
|
|
|
|
bx_bool a20;
|
|
|
|
bx_bool reset;
|
|
|
|
bx_bool nmi;
|
2005-04-08 22:30:34 +04:00
|
|
|
} async_changes_pending;
|
|
|
|
} bx_guard_t;
|
2003-11-28 18:07:29 +03:00
|
|
|
|
|
|
|
// working information for each simulator to update when a guard
|
|
|
|
// is reached (found)
|
|
|
|
typedef struct bx_guard_found_t {
|
2009-03-10 19:28:01 +03:00
|
|
|
unsigned guard_found;
|
2011-08-17 23:51:32 +04:00
|
|
|
Bit64u icount_max; // stop after completing this many instructions
|
2003-11-28 18:07:29 +03:00
|
|
|
unsigned iaddr_index;
|
2011-08-17 23:51:32 +04:00
|
|
|
Bit32u cs; // cs:eip and linear addr of instruction at guard point
|
2006-01-19 21:32:39 +03:00
|
|
|
bx_address eip;
|
|
|
|
bx_address laddr;
|
2009-03-10 19:28:01 +03:00
|
|
|
// 00 - 16 bit, 01 - 32 bit, 10 - 64-bit, 11 - illegal
|
|
|
|
unsigned code_32_64; // CS seg size at guard point
|
2005-04-08 22:30:34 +04:00
|
|
|
} bx_guard_found_t;
|
2003-11-28 18:07:29 +03:00
|
|
|
|
2009-11-20 00:28:25 +03:00
|
|
|
struct bx_watchpoint {
|
|
|
|
bx_phy_address addr;
|
2009-11-20 15:02:57 +03:00
|
|
|
Bit32u len;
|
2009-11-20 00:28:25 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
extern unsigned num_write_watchpoints;
|
|
|
|
extern unsigned num_read_watchpoints;
|
|
|
|
extern bx_watchpoint write_watchpoint[BX_DBG_MAX_WATCHPONTS];
|
|
|
|
extern bx_watchpoint read_watchpoint[BX_DBG_MAX_WATCHPONTS];
|
2006-01-19 21:32:39 +03:00
|
|
|
extern bx_guard_t bx_guard;
|
2003-11-28 18:07:29 +03:00
|
|
|
|
2009-03-10 19:28:01 +03:00
|
|
|
#define IS_CODE_32(code_32_64) ((code_32_64 & 1) != 0)
|
|
|
|
#define IS_CODE_64(code_32_64) ((code_32_64 & 2) != 0)
|
|
|
|
|
2006-10-24 21:53:47 +04:00
|
|
|
void bx_dbg_init_infile(void);
|
|
|
|
int bx_dbg_set_rcfile(const char *rcfile);
|
|
|
|
int bx_dbg_main(void);
|
2003-11-28 18:07:29 +03:00
|
|
|
void bx_dbg_user_input_loop(void);
|
2006-06-12 23:51:31 +04:00
|
|
|
void bx_dbg_interpret_line(char *cmd);
|
2003-11-28 18:07:29 +03:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
Bit16u sel;
|
|
|
|
Bit32u des_l, des_h, valid;
|
2009-10-29 18:49:50 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
Bit32u dword3;
|
|
|
|
#endif
|
2005-04-08 22:30:34 +04:00
|
|
|
} bx_dbg_sreg_t;
|
2003-11-28 18:07:29 +03:00
|
|
|
|
2006-06-11 20:40:37 +04:00
|
|
|
typedef struct {
|
|
|
|
bx_address base;
|
|
|
|
Bit16u limit;
|
|
|
|
} bx_dbg_global_sreg_t;
|
|
|
|
|
2007-10-09 23:49:23 +04:00
|
|
|
void bx_dbg_dma_report(bx_phy_address addr, unsigned len, unsigned what, Bit32u val);
|
2003-11-28 18:07:29 +03:00
|
|
|
void bx_dbg_iac_report(unsigned vector, unsigned irq);
|
|
|
|
void bx_dbg_a20_report(unsigned val);
|
2007-10-09 23:49:23 +04:00
|
|
|
void bx_dbg_io_report(Bit32u port, unsigned size, unsigned op, Bit32u val);
|
2006-01-26 01:20:00 +03:00
|
|
|
void bx_dbg_disassemble_current(int which_cpu, int print_time);
|
2003-11-28 18:07:29 +03:00
|
|
|
|
|
|
|
#endif // #ifdef __cplusplus
|
2005-04-08 22:30:34 +04:00
|
|
|
|
2003-11-28 18:07:29 +03:00
|
|
|
#endif // #if BX_DEBUGGER
|
2011-12-29 02:43:18 +04:00
|
|
|
|
|
|
|
#endif
|