gdb/monitor.h - gdb

Data types defined

Macros defined

Source code

  1. /* Definitions for remote debugging interface for ROM monitors.
  2.    Copyright (C) 1990-2015 Free Software Foundation, Inc.
  3.    Contributed by Cygnus Support. Written by Rob Savoye for Cygnus.

  4.    This file is part of GDB.

  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 3 of the License, or
  8.    (at your option) any later version.

  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.

  13.    You should have received a copy of the GNU General Public License
  14.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  15. #ifndef MONITOR_H
  16. #define MONITOR_H

  17. struct target_waitstatus;
  18. struct serial;

  19. /* This structure describes the strings necessary to give small command
  20.    sequences to the monitor, and parse the response.

  21.    CMD is the actual command typed at the monitor.  Usually this has
  22.    embedded sequences ala printf, which are substituted with the
  23.    arguments appropriate to that type of command.  Ie: to examine a
  24.    register, we substitute the register name for the first arg.  To
  25.    modify memory, we substitute the memory location and the new
  26.    contents for the first and second args, etc...

  27.    RESP_DELIM used to home in on the response string, and is used to
  28.    disambiguate the answer within the pile of text returned by the
  29.    monitor.  This should be a unique string that immediately precedes
  30.    the answer.  Ie: if your monitor prints out `PC: 00000001= ' in
  31.    response to asking for the PC, you should use `: ' as the
  32.    RESP_DELIM.  RESP_DELIM may be NULL if the res- ponse is going to
  33.    be ignored, or has no particular leading text.

  34.    TERM is the string that the monitor outputs to indicate that it is
  35.    idle, and waiting for input.  This is usually a prompt of some
  36.    sort.  In the previous example, it would be `= '.  It is important
  37.    that TERM really means that the monitor is idle, otherwise GDB may
  38.    try to type at it when it isn't ready for input.  This is a problem
  39.    because many monitors cannot deal with type-ahead.  TERM may be
  40.    NULL if the normal prompt is output.

  41.    TERM_CMD is used to quit out of the subcommand mode and get back to
  42.    the main prompt.  TERM_CMD may be NULL if it isn't necessary.  It
  43.    will also be ignored if TERM is NULL.  */

  44. struct memrw_cmd
  45.   {
  46.     char *cmdb;                        /* Command to send for byte read/write */
  47.     char *cmdw;                        /* Command for word (16 bit) read/write */
  48.     char *cmdl;                        /* Command for long (32 bit) read/write */
  49.     char *cmdll;                /* Command for long long (64 bit) read/write */
  50.     char *resp_delim;                /* String just prior to the desired value */
  51.     char *term;                        /* Terminating string to search for */
  52.     char *term_cmd;                /* String to get out of sub-mode (if
  53.                                    necessary) */
  54.   };

  55. struct regrw_cmd
  56.   {
  57.     char *cmd;                        /* Command to send for reg read/write */
  58.     char *resp_delim;                /* String (actually a regexp if getmem) just
  59.                                    prior to the desired value */
  60.     char *term;                        /* Terminating string to search for */
  61.     char *term_cmd;                /* String to get out of sub-mode (if
  62.                                    necessary) */
  63.   };

  64. struct monitor_ops
  65.   {
  66.     int flags;                        /* See below */
  67.     char **init;                /* List of init commands.  NULL terminated.  */
  68.     char *cont;                        /* continue command */
  69.     char *step;                        /* single step */
  70.     char *stop;                        /* Interrupt program string */
  71.     char *set_break;                /* set a breakpoint.  If NULL, monitor
  72.                                    implementation sets its own
  73.                                    to_insert_breakpoint method.  */
  74.     char *clr_break;                /* clear a breakpoint */
  75.     char *clr_all_break;        /* Clear all breakpoints */
  76.     char *fill;                        /* Memory fill cmd (addr len val) */
  77.     struct memrw_cmd setmem;        /* set memory to a value */
  78.     struct memrw_cmd getmem;        /* display memory */
  79.     struct regrw_cmd setreg;        /* set a register */
  80.     struct regrw_cmd getreg;        /* get a register */
  81.     /* Some commands can dump a bunch of registers
  82.        at once.  This comes as a set of REG=VAL
  83.        pairs.  This should be called for each pair
  84.        of registers that we can parse to supply
  85.        GDB with the value of a register.  */
  86.     char *dump_registers;        /* Command to dump all regs at once */
  87.     char *register_pattern;        /* Pattern that picks out register
  88.                                    from reg dump */
  89.     void (*supply_register) (struct regcache *regcache, char *name,
  90.                              int namelen, char *val, int vallen);
  91.     int (*dumpregs) (struct regcache *);        /* Dump all registers */
  92.     int (*continue_hook) (void);        /* Emit the continue command */
  93.     int (*wait_filter) (char *buf,        /* Maybe contains registers */
  94.                         int bufmax,
  95.                         int *response_length,
  96.                         struct target_waitstatus * status);
  97.     char *load;                        /* load command */
  98.     char *loadresp;                /* Response to load command */
  99.     char *prompt;                /* monitor command prompt */
  100.     char *line_term;                /* end-of-command delimitor */
  101.     char *cmd_end;                /* optional command terminator */
  102.     struct target_ops *target;        /* target operations */
  103.     int stopbits;                /* number of stop bits */
  104.     char **regnames;                /* array of register names in ascii */
  105.                                 /* deprecated: use regname instead */
  106.     const char *(*regname) (int index);
  107.                                 /* function for dynamic regname array */
  108.     int num_breakpoints;        /* If set_break != NULL, number of supported
  109.                                    breakpoints */
  110.     int magic;                        /* Check value */
  111.   };

  112. /* The monitor ops magic number, used to detect if an ops structure doesn't
  113.    have the right number of entries filled in.  */

  114. #define MONITOR_OPS_MAGIC 600925

  115. /* Flag definitions.  */

  116. /* If set, then clear breakpoint command uses address, otherwise it
  117.    uses an index returned by the monitor.  */

  118. #define MO_CLR_BREAK_USES_ADDR 0x1

  119. /* If set, then memory fill command uses STARTADDR, ENDADDR+1, VALUE
  120.    as args, else it uses STARTADDR, LENGTH, VALUE as args.  */

  121. #define MO_FILL_USES_ADDR 0x2

  122. /* If set, then monitor doesn't automatically supply register dump
  123.    when coming back after a continue.  */

  124. #define MO_NEED_REGDUMP_AFTER_CONT 0x4

  125. /* getmem needs start addr and end addr.  */

  126. #define MO_GETMEM_NEEDS_RANGE 0x8

  127. /* getmem can only read one loc at a time.  */

  128. #define MO_GETMEM_READ_SINGLE 0x10

  129. /* handle \r\n combinations.  */

  130. #define MO_HANDLE_NL 0x20

  131. /* don't expect echos in monitor_open.  */

  132. #define MO_NO_ECHO_ON_OPEN 0x40

  133. /* If set, send break to stop monitor.  */

  134. #define MO_SEND_BREAK_ON_STOP 0x80

  135. /* If set, target sends an ACK after each S-record.  */

  136. #define MO_SREC_ACK 0x100

  137. /* Allow 0x prefix on addresses retured from monitor.  */

  138. #define MO_HEX_PREFIX 0x200

  139. /* Some monitors require a different command when starting a program.  */

  140. #define MO_RUN_FIRST_TIME 0x400

  141. /* Don't expect echos when getting memory */

  142. #define MO_NO_ECHO_ON_SETMEM 0x800

  143. /* If set, then register store command expects value BEFORE regname.  */

  144. #define MO_REGISTER_VALUE_FIRST 0x1000

  145. /* If set, then the monitor displays registers as pairs.  */

  146. #define MO_32_REGS_PAIRED 0x2000

  147. /* If set, then register setting happens interactively.  */

  148. #define MO_SETREG_INTERACTIVE 0x4000

  149. /* If set, then memory setting happens interactively.  */

  150. #define MO_SETMEM_INTERACTIVE 0x8000

  151. /* If set, then memory dumps are always on 16-byte boundaries, even
  152.    when less is desired.  */

  153. #define MO_GETMEM_16_BOUNDARY 0x10000

  154. /* If set, then the monitor numbers its breakpoints starting from 1.  */

  155. #define MO_CLR_BREAK_1_BASED 0x20000

  156. /* If set, then the monitor acks srecords with a plus sign.  */

  157. #define MO_SREC_ACK_PLUS 0x40000

  158. /* If set, then the monitor "acks" srecords with rotating lines.  */

  159. #define MO_SREC_ACK_ROTATE 0x80000

  160. /* If set, then remove useless address bits from memory addresses.  */

  161. #define MO_ADDR_BITS_REMOVE 0x100000

  162. /* If set, then display target program output if prefixed by ^O.  */

  163. #define MO_PRINT_PROGRAM_OUTPUT 0x200000

  164. /* Some dump bytes commands align the first data with the preceding
  165.    16 byte boundary.  Some print blanks and start at the exactly the
  166.    requested boundary.  */

  167. #define MO_EXACT_DUMPADDR 0x400000

  168. /* Rather entering and exiting the write memory dialog for each word byte,
  169.    we can save time by transferring the whole block without exiting
  170.    the memory editing mode.  You only need to worry about this
  171.    if you are doing memory downloading.
  172.    This engages a new write function registered with dcache.  */

  173. #define MO_HAS_BLOCKWRITES 0x800000

  174. #define SREC_SIZE 160

  175. extern void monitor_open (const char *args, struct monitor_ops *ops,
  176.                           int from_tty);
  177. extern void monitor_close (struct target_ops *self);
  178. extern char *monitor_supply_register (struct regcache *regcache,
  179.                                       int regno, char *valstr);
  180. extern int monitor_expect (char *prompt, char *buf, int buflen);
  181. extern int monitor_expect_prompt (char *buf, int buflen);
  182. /* Note: The variable argument functions monitor_printf and
  183.    monitor_printf_noecho vararg do not take take standard format style
  184.    arguments.  Instead they take custom formats interpretered directly
  185.    by monitor_vsprintf.  */
  186. extern void monitor_printf (char *, ...);
  187. extern void monitor_printf_noecho (char *, ...);
  188. extern void monitor_write (char *buf, int buflen);
  189. extern int monitor_readchar (void);
  190. extern char *monitor_get_dev_name (void);
  191. extern void init_monitor_ops (struct target_ops *);
  192. extern int monitor_dump_reg_block (struct regcache *regcache, char *dump_cmd);

  193. #endif