[rfc] [11/14] Prepare monitor targets

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[rfc] [11/14] Prepare monitor targets

Ulrich Weigand
Hello,

this patch prepares the monitor targets by adding REGCACHE arguments to
internal helper routines.

Specifically, the supply_register and dumpregs monitor operation callbacks
(and all their implementations) acquire a REGCACHE parameter, as do the
monitor_supply_register and monitor_dump_reg_block helpers.

Bye,
Ulrich



ChangeLog:

        * monitor.c (monitor_supply_register): Add REGCACHE parameter, use
        it instead of current_regcache.
        (parse_register_dump): Add REGCACHE parameter, pass it to
        supply_register callback.
        (monitor_dump_reg_block): Add REGCACHE parameter, pass it to
        parse_register_dump.
        (monitor_dump_regs): Add REGCACHE parameter, pass it to
        parse_register_dump and dumpregs callback.
        (monitor_wait): Pass current_regcache to parse_register_dump and
        monitor_dump_regs.
        (monitor_fetch_register): Pass current_regcache to
        monitor_supply_register.
        (monitor_fetch_registers): Pass current_regcache to
        monitor_dump_regs.
        * monitor.h (struct monitor_ops): Add REGCACHE parameter to
        supply_register and dumpregs callbacks.
        (monitor_supply_register, monitor_dump_reg_block): Update
        prototypes.
        * dbug-rom.c (dbug_supply_register): Add REGCACHE parameter.  Pass
        it to monitor_supply_register.
        * dink32-rom.c (dink32_supply_register): Likewise.
        * ppcbug-rom.c (ppcbug_supply_register): Likewise.
        * m32r-rom.c (m32r_supply_register): Likewise.  Also, use REGCACHE
        instead of current_regcache.


diff -urNp gdb-orig/gdb/dbug-rom.c gdb-head/gdb/dbug-rom.c
--- gdb-orig/gdb/dbug-rom.c 2007-04-30 02:06:07.000000000 +0200
+++ gdb-head/gdb/dbug-rom.c 2007-04-30 22:37:51.375584665 +0200
@@ -38,7 +38,8 @@
 static void dbug_open (char *args, int from_tty);
 
 static void
-dbug_supply_register (char *regname, int regnamelen, char *val, int vallen)
+dbug_supply_register (struct regcache *regcache, char *regname,
+      int regnamelen, char *val, int vallen)
 {
   int regno;
 
@@ -71,7 +72,7 @@ dbug_supply_register (char *regname, int
       return;
     }
 
-  monitor_supply_register (regno, val);
+  monitor_supply_register (regcache, regno, val);
 }
 
 /* This array of registers needs to match the indexes used by GDB. The
diff -urNp gdb-orig/gdb/dink32-rom.c gdb-head/gdb/dink32-rom.c
--- gdb-orig/gdb/dink32-rom.c 2007-04-30 02:06:07.000000000 +0200
+++ gdb-head/gdb/dink32-rom.c 2007-04-30 22:37:51.379584098 +0200
@@ -31,7 +31,8 @@
 static void dink32_open (char *args, int from_tty);
 
 static void
-dink32_supply_register (char *regname, int regnamelen, char *val, int vallen)
+dink32_supply_register (struct regcache *regcache, char *regname,
+ int regnamelen, char *val, int vallen)
 {
   int regno = 0;
 
@@ -93,7 +94,7 @@ dink32_supply_register (char *regname, i
       return;
     }
 
-  monitor_supply_register (regno, val);
+  monitor_supply_register (regcache, regno, val);
 }
 
 /* This array of registers needs to match the indexes used by GDB. The
diff -urNp gdb-orig/gdb/m32r-rom.c gdb-head/gdb/m32r-rom.c
--- gdb-orig/gdb/m32r-rom.c 2007-04-30 02:06:07.000000000 +0200
+++ gdb-head/gdb/m32r-rom.c 2007-04-30 22:37:51.384583388 +0200
@@ -210,7 +210,8 @@ static char *m32r_regnames[] =
 };
 
 static void
-m32r_supply_register (char *regname, int regnamelen, char *val, int vallen)
+m32r_supply_register (struct regcache *regcache, char *regname,
+      int regnamelen, char *val, int vallen)
 {
   int regno;
   int num_regs = sizeof (m32r_regnames) / sizeof (m32r_regnames[0]);
@@ -224,14 +225,14 @@ m32r_supply_register (char *regname, int
 
   if (regno == ACCL_REGNUM)
     { /* special handling for 64-bit acc reg */
-      monitor_supply_register (ACCH_REGNUM, val);
+      monitor_supply_register (regcache, ACCH_REGNUM, val);
       val = strchr (val, ':'); /* skip past ':' to get 2nd word */
       if (val != NULL)
- monitor_supply_register (ACCL_REGNUM, val + 1);
+ monitor_supply_register (regcache, ACCL_REGNUM, val + 1);
     }
   else
     {
-      monitor_supply_register (regno, val);
+      monitor_supply_register (regcache, regno, val);
       if (regno == PSW_REGNUM)
  {
   unsigned long psw = strtoul (val, NULL, 16);
@@ -239,45 +240,45 @@ m32r_supply_register (char *regname, int
 
 #ifdef SM_REGNUM
   /* Stack mode bit */
-  monitor_supply_register (SM_REGNUM, (psw & 0x80) ? one : zero);
+  monitor_supply_register (regcache, SM_REGNUM, (psw & 0x80) ? one : zero);
 #endif
 #ifdef BSM_REGNUM
   /* Backup stack mode bit */
-  monitor_supply_register (BSM_REGNUM, (psw & 0x8000) ? one : zero);
+  monitor_supply_register (regcache, BSM_REGNUM, (psw & 0x8000) ? one : zero);
 #endif
 #ifdef IE_REGNUM
   /* Interrupt enable bit */
-  monitor_supply_register (IE_REGNUM, (psw & 0x40) ? one : zero);
+  monitor_supply_register (regcache, IE_REGNUM, (psw & 0x40) ? one : zero);
 #endif
 #ifdef BIE_REGNUM
   /* Backup interrupt enable bit */
-  monitor_supply_register (BIE_REGNUM, (psw & 0x4000) ? one : zero);
+  monitor_supply_register (regcache, BIE_REGNUM, (psw & 0x4000) ? one : zero);
 #endif
 #ifdef COND_REGNUM
   /* Condition bit (carry etc.) */
-  monitor_supply_register (COND_REGNUM, (psw & 0x1) ? one : zero);
+  monitor_supply_register (regcache, COND_REGNUM, (psw & 0x1) ? one : zero);
 #endif
 #ifdef CBR_REGNUM
-  monitor_supply_register (CBR_REGNUM, (psw & 0x1) ? one : zero);
+  monitor_supply_register (regcache, CBR_REGNUM, (psw & 0x1) ? one : zero);
 #endif
 #ifdef BPC_REGNUM
-  monitor_supply_register (BPC_REGNUM, zero); /* KLUDGE:   (???????) */
+  monitor_supply_register (regcache, BPC_REGNUM, zero); /* KLUDGE:   (???????) */
 #endif
 #ifdef BCARRY_REGNUM
-  monitor_supply_register (BCARRY_REGNUM, zero); /* KLUDGE: (??????) */
+  monitor_supply_register (regcache, BCARRY_REGNUM, zero); /* KLUDGE: (??????) */
 #endif
  }
 
       if (regno == SPI_REGNUM || regno == SPU_REGNUM)
  { /* special handling for stack pointer (spu or spi) */
   ULONGEST stackmode, psw;
-  regcache_cooked_read_unsigned (current_regcache, PSW_REGNUM, &psw);
+  regcache_cooked_read_unsigned (regcache, PSW_REGNUM, &psw);
   stackmode = psw & 0x80;
 
   if (regno == SPI_REGNUM && !stackmode) /* SP == SPI */
-    monitor_supply_register (SP_REGNUM, val);
+    monitor_supply_register (regcache, SP_REGNUM, val);
   else if (regno == SPU_REGNUM && stackmode) /* SP == SPU */
-    monitor_supply_register (SP_REGNUM, val);
+    monitor_supply_register (regcache, SP_REGNUM, val);
  }
     }
 }
diff -urNp gdb-orig/gdb/monitor.c gdb-head/gdb/monitor.c
--- gdb-orig/gdb/monitor.c 2007-04-30 02:06:07.000000000 +0200
+++ gdb-head/gdb/monitor.c 2007-04-30 22:38:36.892033064 +0200
@@ -63,7 +63,7 @@ static struct target_ops *targ_ops;
 static void monitor_interrupt_query (void);
 static void monitor_interrupt_twice (int);
 static void monitor_stop (void);
-static void monitor_dump_regs (void);
+static void monitor_dump_regs (struct regcache *regcache);
 
 #if 0
 static int from_hex (int a);
@@ -848,7 +848,7 @@ monitor_detach (char *args, int from_tty
 /* Convert VALSTR into the target byte-ordered value of REGNO and store it.  */
 
 char *
-monitor_supply_register (int regno, char *valstr)
+monitor_supply_register (struct regcache *regcache, int regno, char *valstr)
 {
   ULONGEST val;
   unsigned char regbuf[MAX_REGISTER_SIZE];
@@ -887,7 +887,7 @@ monitor_supply_register (int regno, char
 
   store_unsigned_integer (regbuf, register_size (current_gdbarch, regno), val);
 
-  regcache_raw_supply (current_regcache, regno, regbuf);
+  regcache_raw_supply (regcache, regno, regbuf);
 
   return p;
 }
@@ -926,7 +926,7 @@ monitor_resume (ptid_t ptid, int step, e
    string which are passed down to monitor specific code.  */
 
 static void
-parse_register_dump (char *buf, int len)
+parse_register_dump (struct regcache *regcache, char *buf, int len)
 {
   monitor_debug ("MON Parsing  register dump\n");
   while (1)
@@ -948,7 +948,8 @@ parse_register_dump (char *buf, int len)
       vallen = register_strings.end[2] - register_strings.start[2];
       val = buf + register_strings.start[2];
 
-      current_monitor->supply_register (regname, regnamelen, val, vallen);
+      current_monitor->supply_register (regcache, regname, regnamelen,
+ val, vallen);
 
       buf += register_strings.end[0];
       len -= register_strings.end[0];
@@ -1108,10 +1109,10 @@ monitor_wait (ptid_t ptid, struct target
     }
 
   if (current_monitor->register_pattern)
-    parse_register_dump (buf, resp_len);
+    parse_register_dump (current_regcache, buf, resp_len);
 #else
   monitor_debug ("Wait fetching registers after stop\n");
-  monitor_dump_regs ();
+  monitor_dump_regs (current_regcache);
 #endif
 
   status->kind = TARGET_WAITKIND_STOPPED;
@@ -1227,7 +1228,7 @@ monitor_fetch_register (int regno)
       current_monitor->getreg.term_cmd) /* ack expected */
     monitor_expect_prompt (NULL, 0); /* get response */
 
-  monitor_supply_register (regno, regbuf);
+  monitor_supply_register (current_regcache, regno, regbuf);
 }
 
 /* Sometimes, it takes several commands to dump the registers */
@@ -1235,13 +1236,13 @@ monitor_fetch_register (int regno)
    case they need to compose the operation.
  */
 int
-monitor_dump_reg_block (char *block_cmd)
+monitor_dump_reg_block (struct regcache *regcache, char *block_cmd)
 {
   char buf[TARGET_BUF_SIZE];
   int resp_len;
   monitor_printf (block_cmd);
   resp_len = monitor_expect_prompt (buf, sizeof (buf));
-  parse_register_dump (buf, resp_len);
+  parse_register_dump (regcache, buf, resp_len);
   return 1;
 }
 
@@ -1250,17 +1251,17 @@ monitor_dump_reg_block (char *block_cmd)
 /* Call the specific function if it has been provided */
 
 static void
-monitor_dump_regs (void)
+monitor_dump_regs (struct regcache *regcache)
 {
   char buf[TARGET_BUF_SIZE];
   int resp_len;
   if (current_monitor->dumpregs)
-    (*(current_monitor->dumpregs)) (); /* call supplied function */
+    (*(current_monitor->dumpregs)) (regcache); /* call supplied function */
   else if (current_monitor->dump_registers) /* default version */
     {
       monitor_printf (current_monitor->dump_registers);
       resp_len = monitor_expect_prompt (buf, sizeof (buf));
-      parse_register_dump (buf, resp_len);
+      parse_register_dump (regcache, buf, resp_len);
     }
   else
     internal_error (__FILE__, __LINE__, _("failed internal consistency check")); /* Need some way to read registers */
@@ -1283,7 +1284,7 @@ monitor_fetch_registers (int regno)
     }
   else
     {
-      monitor_dump_regs ();
+      monitor_dump_regs (current_regcache);
     }
 }
 
diff -urNp gdb-orig/gdb/monitor.h gdb-head/gdb/monitor.h
--- gdb-orig/gdb/monitor.h 2007-04-30 02:06:07.000000000 +0200
+++ gdb-head/gdb/monitor.h 2007-04-30 22:37:51.435576150 +0200
@@ -100,10 +100,11 @@ struct monitor_ops
        GDB with the value of a register.  */
     char *dump_registers; /* Command to dump all regs at once */
     char *register_pattern; /* Pattern that picks out register from reg dump */
-    void (*supply_register) (char *name, int namelen, char *val, int vallen);
+    void (*supply_register) (struct regcache *regcache, char *name,
+     int namelen, char *val, int vallen);
     void (*load_routine) (struct serial *desc, char *file,
   int hashmark); /* Download routine */
-    int (*dumpregs) (void); /* routine to dump all registers */
+    int (*dumpregs) (struct regcache *); /* Dump all registers */
     int (*continue_hook) (void); /* Emit the continue command */
     int (*wait_filter) (char *buf, /* Maybe contains registers */
  int bufmax,
@@ -242,7 +243,8 @@ struct monitor_ops
 
 extern void monitor_open (char *args, struct monitor_ops *ops, int from_tty);
 extern void monitor_close (int quitting);
-extern char *monitor_supply_register (int regno, char *valstr);
+extern char *monitor_supply_register (struct regcache *regcache,
+      int regno, char *valstr);
 extern int monitor_expect (char *prompt, char *buf, int buflen);
 extern int monitor_expect_prompt (char *buf, int buflen);
 /* Note: The variable argument functions monitor_printf and
@@ -255,6 +257,6 @@ extern void monitor_write (char *buf, in
 extern int monitor_readchar (void);
 extern char *monitor_get_dev_name (void);
 extern void init_monitor_ops (struct target_ops *);
-extern int monitor_dump_reg_block (char *dump_cmd);
+extern int monitor_dump_reg_block (struct regcache *regcache, char *dump_cmd);
 
 #endif
diff -urNp gdb-orig/gdb/ppcbug-rom.c gdb-head/gdb/ppcbug-rom.c
--- gdb-orig/gdb/ppcbug-rom.c 2007-04-30 02:06:07.000000000 +0200
+++ gdb-head/gdb/ppcbug-rom.c 2007-04-30 22:37:51.439575583 +0200
@@ -30,7 +30,8 @@
 #include "regcache.h"
 
 static void
-ppcbug_supply_register (char *regname, int regnamelen, char *val, int vallen)
+ppcbug_supply_register (struct regcache *regcache, char *regname,
+ int regnamelen, char *val, int vallen)
 {
   int regno = 0;
 
@@ -92,7 +93,7 @@ ppcbug_supply_register (char *regname, i
       return;
     }
 
-  monitor_supply_register (regno, val);
+  monitor_supply_register (regcache, regno, val);
 }
 
 /*
--
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  [hidden email]