GDB (xrefs)
Defines | Functions | Variables
/home/stan/gdb/src/gdb/monitor.c File Reference
#include "defs.h"
#include "gdbcore.h"
#include "target.h"
#include "exceptions.h"
#include <signal.h>
#include <ctype.h>
#include "gdb_string.h"
#include <sys/types.h>
#include "command.h"
#include "serial.h"
#include "monitor.h"
#include "gdbcmd.h"
#include "inferior.h"
#include "gdb_regex.h"
#include "srec.h"
#include "regcache.h"
#include "gdbthread.h"
#include "readline/readline.h"

Go to the source code of this file.

Defines

#define TARGET_BUF_SIZE   2048

Functions

static void monitor_interrupt_query (void)
static void monitor_interrupt_twice (int)
static void monitor_stop (ptid_t)
static void monitor_dump_regs (struct regcache *regcache)
static void monitor_debug (const char *fmt,...) ATTRIBUTE_PRINTF(1
static void monitor_printable_string (char *newstr, char *oldstr, int len)
static void monitor_error (char *function, char *message, CORE_ADDR memaddr, int len, char *string, int final_char)
static int fromhex (int a)
static void monitor_vsprintf (char *sndbuf, char *pattern, va_list args)
void monitor_printf_noecho (char *pattern,...)
void monitor_printf (char *pattern,...)
void monitor_write (char *buf, int buflen)
int monitor_readchar (void)
static int readchar (int timeout)
int monitor_expect (char *string, char *buf, int buflen)
static int monitor_expect_regexp (struct re_pattern_buffer *pat, char *buf, int buflen)
int monitor_expect_prompt (char *buf, int buflen)
static void compile_pattern (char *pattern, struct re_pattern_buffer *compiled_pattern, char *fastmap)
void monitor_open (char *args, struct monitor_ops *mon_ops, int from_tty)
void monitor_close (void)
static void monitor_detach (struct target_ops *ops, char *args, int from_tty)
char * monitor_supply_register (struct regcache *regcache, int regno, char *valstr)
static void monitor_resume (struct target_ops *ops, ptid_t ptid, int step, enum gdb_signal sig)
static void parse_register_dump (struct regcache *regcache, char *buf, int len)
static void monitor_interrupt (int signo)
static void monitor_wait_cleanup (void *old_timeout)
static void monitor_wait_filter (char *buf, int bufmax, int *ext_resp_len, struct target_waitstatus *status)
static ptid_t monitor_wait (struct target_ops *ops, ptid_t ptid, struct target_waitstatus *status, int options)
static void monitor_fetch_register (struct regcache *regcache, int regno)
int monitor_dump_reg_block (struct regcache *regcache, char *block_cmd)
static void monitor_fetch_registers (struct target_ops *ops, struct regcache *regcache, int regno)
static void monitor_store_register (struct regcache *regcache, int regno)
static void monitor_store_registers (struct target_ops *ops, struct regcache *regcache, int regno)
static void monitor_prepare_to_store (struct regcache *regcache)
static void monitor_files_info (struct target_ops *ops)
static int monitor_write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
static int monitor_write_memory_bytes (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
static void longlongendswap (unsigned char *a)
static char * longlong_hexchars (unsigned long long value, char *outbuff)
static int monitor_write_memory_longlongs (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
static int monitor_write_memory_block (CORE_ADDR memaddr, const gdb_byte *myaddr, int len)
static int monitor_read_memory_single (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
static int monitor_read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len)
static LONGEST monitor_xfer_memory (gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST memaddr, LONGEST len)
static LONGEST monitor_xfer_partial (struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, LONGEST len)
static void monitor_kill (struct target_ops *ops)
static void monitor_create_inferior (struct target_ops *ops, char *exec_file, char *args, char **env, int from_tty)
static void monitor_mourn_inferior (struct target_ops *ops)
static int monitor_insert_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
static int monitor_remove_breakpoint (struct gdbarch *gdbarch, struct bp_target_info *bp_tgt)
static int monitor_wait_srec_ack (void)
static void monitor_load (char *args, int from_tty)
static void monitor_rcmd (char *command, struct ui_file *outbuf)
char * monitor_get_dev_name (void)
static int monitor_thread_alive (struct target_ops *ops, ptid_t ptid)
static char * monitor_pid_to_str (struct target_ops *ops, ptid_t ptid)
static void init_base_monitor_ops (void)
void init_monitor_ops (struct target_ops *ops)
void _initialize_remote_monitors (void)

Variables

static char * dev_name
static struct target_opstarg_ops
static struct monitor_opscurrent_monitor
static int hashmark
static int timeout = 30
static int in_monitor_wait = 0
static void(* ofunc )()
static CORE_ADDRbreakaddr
static struct serialmonitor_desc = NULL
static struct re_pattern_buffer register_pattern
static char register_fastmap [256]
static struct re_pattern_buffer getmem_resp_delim_pattern
static char getmem_resp_delim_fastmap [256]
static struct re_pattern_buffer setmem_resp_delim_pattern
static char setmem_resp_delim_fastmap [256]
static struct re_pattern_buffer setreg_resp_delim_pattern
static char setreg_resp_delim_fastmap [256]
static int dump_reg_flag
static int first_time = 0
static ptid_t monitor_ptid
static void static unsigned int monitor_debug_p = 0
static char * hexlate = "0123456789abcdef"
static struct target_ops monitor_ops
initialize_file_ftype _initialize_remote_monitors

Define Documentation

#define TARGET_BUF_SIZE   2048

Function Documentation

void _initialize_remote_monitors ( void  )
static void compile_pattern ( char *  pattern,
struct re_pattern_buffer *  compiled_pattern,
char *  fastmap 
) [static]

Definition at line 689 of file monitor.c.

References _, and error().

Referenced by monitor_open().

static int fromhex ( int  a) [static]

Definition at line 232 of file monitor.c.

References _, and error().

Referenced by monitor_read_memory(), and monitor_supply_register().

static void init_base_monitor_ops ( void  ) [static]
void init_monitor_ops ( struct target_ops ops)
static char* longlong_hexchars ( unsigned long long  value,
char *  outbuff 
) [static]

Definition at line 1592 of file monitor.c.

References longlongendswap(), and scan().

Referenced by monitor_write_memory_longlongs().

static void longlongendswap ( unsigned char *  a) [static]

Definition at line 1574 of file monitor.c.

Referenced by longlong_hexchars().

void monitor_close ( void  )
static void monitor_create_inferior ( struct target_ops ops,
char *  exec_file,
char *  args,
char **  env,
int  from_tty 
) [static]
static void monitor_debug ( const char *  fmt,
  ... 
) [static]
static void monitor_detach ( struct target_ops ops,
char *  args,
int  from_tty 
) [static]

Definition at line 878 of file monitor.c.

References _, printf_unfiltered(), target_shortname, and unpush_target().

Referenced by init_base_monitor_ops().

int monitor_dump_reg_block ( struct regcache regcache,
char *  block_cmd 
)
static void monitor_dump_regs ( struct regcache regcache) [static]
static void monitor_error ( char *  function,
char *  message,
CORE_ADDR  memaddr,
int  len,
char *  string,
int  final_char 
) [static]
int monitor_expect ( char *  string,
char *  buf,
int  buflen 
)
int monitor_expect_prompt ( char *  buf,
int  buflen 
)
static int monitor_expect_regexp ( struct re_pattern_buffer *  pat,
char *  buf,
int  buflen 
) [static]
static void monitor_fetch_register ( struct regcache regcache,
int  regno 
) [static]
static void monitor_fetch_registers ( struct target_ops ops,
struct regcache regcache,
int  regno 
) [static]
static void monitor_files_info ( struct target_ops ops) [static]

Definition at line 1436 of file monitor.c.

References _, baud_rate, dev_name, and printf_unfiltered().

Referenced by init_base_monitor_ops().

char* monitor_get_dev_name ( void  )

Definition at line 2319 of file monitor.c.

References dev_name.

static int monitor_insert_breakpoint ( struct gdbarch gdbarch,
struct bp_target_info bp_tgt 
) [static]
static void monitor_interrupt ( int  signo) [static]
static void monitor_interrupt_query ( void  ) [static]
static void monitor_interrupt_twice ( int  signo) [static]

Definition at line 1019 of file monitor.c.

References monitor_interrupt(), monitor_interrupt_query(), and ofunc.

Referenced by monitor_interrupt().

static void monitor_kill ( struct target_ops ops) [static]

Definition at line 2062 of file monitor.c.

Referenced by init_base_monitor_ops().

static void monitor_load ( char *  args,
int  from_tty 
) [static]
static void monitor_mourn_inferior ( struct target_ops ops) [static]

Definition at line 2088 of file monitor.c.

References delete_thread_silent(), generic_mourn_inferior(), and unpush_target().

Referenced by init_base_monitor_ops().

void monitor_open ( char *  args,
struct monitor_ops mon_ops,
int  from_tty 
)
static char* monitor_pid_to_str ( struct target_ops ops,
ptid_t  ptid 
) [static]

Definition at line 2340 of file monitor.c.

References normal_pid_to_str(), ptid_equal(), and xsnprintf().

Referenced by init_base_monitor_ops().

static void monitor_prepare_to_store ( struct regcache regcache) [static]

Definition at line 1430 of file monitor.c.

Referenced by init_base_monitor_ops().

static void monitor_printable_string ( char *  newstr,
char *  oldstr,
int  len 
) [static]

Definition at line 149 of file monitor.c.

References len.

Referenced by monitor_error(), monitor_expect(), monitor_printf(), and monitor_printf_noecho().

void monitor_printf ( char *  pattern,
  ... 
)
void monitor_printf_noecho ( char *  pattern,
  ... 
)
static void monitor_rcmd ( char *  command,
struct ui_file outbuf 
) [static]
static int monitor_read_memory ( CORE_ADDR  memaddr,
gdb_byte myaddr,
int  len 
) [static]
static int monitor_read_memory_single ( CORE_ADDR  memaddr,
gdb_byte myaddr,
int  len 
) [static]
int monitor_readchar ( void  )

Definition at line 394 of file monitor.c.

References _, error(), perror_with_name(), serial_readchar(), SERIAL_TIMEOUT, and timeout.

static int monitor_remove_breakpoint ( struct gdbarch gdbarch,
struct bp_target_info bp_tgt 
) [static]
static void monitor_resume ( struct target_ops ops,
ptid_t  ptid,
int  step,
enum gdb_signal  sig 
) [static]
static void monitor_stop ( ptid_t  ptid) [static]
static void monitor_store_register ( struct regcache regcache,
int  regno 
) [static]
static void monitor_store_registers ( struct target_ops ops,
struct regcache regcache,
int  regno 
) [static]

Definition at line 1409 of file monitor.c.

References gdbarch_num_regs(), get_regcache_arch(), and monitor_store_register().

Referenced by init_base_monitor_ops().

char* monitor_supply_register ( struct regcache regcache,
int  regno,
char *  valstr 
)
static int monitor_thread_alive ( struct target_ops ops,
ptid_t  ptid 
) [static]

Definition at line 2327 of file monitor.c.

References ptid_equal().

Referenced by init_base_monitor_ops().

static void monitor_vsprintf ( char *  sndbuf,
char *  pattern,
va_list  args 
) [static]

Definition at line 258 of file monitor.c.

References gdbarch_addr_bit(), int, p, phex_nz(), and target_gdbarch().

Referenced by monitor_printf(), and monitor_printf_noecho().

static ptid_t monitor_wait ( struct target_ops ops,
ptid_t  ptid,
struct target_waitstatus status,
int  options 
) [static]
static void monitor_wait_cleanup ( void *  old_timeout) [static]

Definition at line 1046 of file monitor.c.

References in_monitor_wait, ofunc, and timeout.

Referenced by monitor_wait().

static void monitor_wait_filter ( char *  buf,
int  bufmax,
int ext_resp_len,
struct target_waitstatus status 
) [static]
static int monitor_wait_srec_ack ( void  ) [static]

Definition at line 2171 of file monitor.c.

References monitor_ops::flags, MO_SREC_ACK_PLUS, MO_SREC_ACK_ROTATE, readchar(), and timeout.

Referenced by monitor_load().

void monitor_write ( char *  buf,
int  buflen 
)

Definition at line 381 of file monitor.c.

References fprintf_unfiltered(), gdb_stderr, safe_strerror(), and serial_write().

Referenced by monitor_printf(), and monitor_printf_noecho().

static int monitor_write_memory ( CORE_ADDR  memaddr,
const gdb_byte myaddr,
int  len 
) [static]
static int monitor_write_memory_block ( CORE_ADDR  memaddr,
const gdb_byte myaddr,
int  len 
) [static]
static int monitor_write_memory_bytes ( CORE_ADDR  memaddr,
const gdb_byte myaddr,
int  len 
) [static]
static int monitor_write_memory_longlongs ( CORE_ADDR  memaddr,
const gdb_byte myaddr,
int  len 
) [static]
static LONGEST monitor_xfer_memory ( gdb_byte readbuf,
const gdb_byte writebuf,
ULONGEST  memaddr,
LONGEST  len 
) [static]
static LONGEST monitor_xfer_partial ( struct target_ops ops,
enum target_object  object,
const char *  annex,
gdb_byte readbuf,
const gdb_byte writebuf,
ULONGEST  offset,
LONGEST  len 
) [static]

Definition at line 2047 of file monitor.c.

References monitor_xfer_memory(), TARGET_OBJECT_MEMORY, and TARGET_XFER_E_IO.

Referenced by init_base_monitor_ops().

static void parse_register_dump ( struct regcache regcache,
char *  buf,
int  len 
) [static]
static int readchar ( int  timeout) [static]

Variable Documentation

Referenced by initialize_all_files().

CORE_ADDR* breakaddr [static]
struct monitor_ops* current_monitor [static]

Definition at line 71 of file monitor.c.

char* dev_name [static]

Definition at line 59 of file monitor.c.

Referenced by monitor_files_info(), monitor_get_dev_name(), and monitor_open().

int dump_reg_flag [static]

Definition at line 103 of file monitor.c.

Referenced by monitor_resume(), and monitor_wait().

int first_time = 0 [static]
char getmem_resp_delim_fastmap[256] [static]

Definition at line 95 of file monitor.c.

Referenced by monitor_open().

struct re_pattern_buffer getmem_resp_delim_pattern [static]

Definition at line 94 of file monitor.c.

Referenced by monitor_open(), monitor_read_memory(), and monitor_read_memory_single().

int hashmark [static]

Definition at line 73 of file monitor.c.

Referenced by _initialize_remote_monitors(), and monitor_load().

char* hexlate = "0123456789abcdef" [static]

Definition at line 1590 of file monitor.c.

int in_monitor_wait = 0 [static]

Definition at line 77 of file monitor.c.

Referenced by monitor_wait(), monitor_wait_cleanup(), and readchar().

void static unsigned int monitor_debug_p = 0 [static]
struct serial* monitor_desc = NULL [static]

Definition at line 87 of file monitor.c.

struct target_ops monitor_ops [static]

Definition at line 2353 of file monitor.c.

ptid_t monitor_ptid [static]

Definition at line 115 of file monitor.c.

Referenced by monitor_open().

void(* ofunc)() [static]

Definition at line 79 of file monitor.c.

Referenced by monitor_interrupt_twice(), monitor_wait(), and monitor_wait_cleanup().

char register_fastmap[256] [static]

Definition at line 92 of file monitor.c.

Referenced by monitor_open().

struct re_pattern_buffer register_pattern [static]

Definition at line 91 of file monitor.c.

Referenced by monitor_open(), and parse_register_dump().

char setmem_resp_delim_fastmap[256] [static]

Definition at line 98 of file monitor.c.

Referenced by monitor_open().

struct re_pattern_buffer setmem_resp_delim_pattern [static]

Definition at line 97 of file monitor.c.

Referenced by monitor_open(), and monitor_write_memory().

char setreg_resp_delim_fastmap[256] [static]

Definition at line 101 of file monitor.c.

Referenced by monitor_open().

struct re_pattern_buffer setreg_resp_delim_pattern [static]

Definition at line 100 of file monitor.c.

Referenced by monitor_open(), and monitor_store_register().

struct target_ops* targ_ops [static]

Definition at line 60 of file monitor.c.

int timeout = 30 [static]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines