Update rx sim so that it'll print load statistics.
authorKevin Buettner <kevinb@redhat.com>
Sat, 3 Mar 2012 01:23:45 +0000 (01:23 +0000)
committerKevin Buettner <kevinb@redhat.com>
Sat, 3 Mar 2012 01:23:45 +0000 (01:23 +0000)
sim/rx/ChangeLog
sim/rx/gdb-if.c
sim/rx/load.c
sim/rx/load.h
sim/rx/main.c
sim/rx/syscalls.c
sim/rx/syscalls.h

index d9c2264994d12e1bd962dfd4a133a2f7964e4daa..659fc6bd6275cb2ec1498fcfd8db04396102e145 100644 (file)
@@ -1,3 +1,16 @@
+2012-03-02  Kevin Buettner  <kevinb@redhat.com>
+
+       * load.h (rx_load): Add `callback' parameter to function prototype.
+       (gdb/callback.h): Include.
+       * load.c (load.h): Include.
+       (xprintf, find_section_name_by_offset): New functions.
+       (rx_load): Add `callback' parameter.  Add code for printing
+       section loaded using GDB's printf facilities.
+       * gdb-if.c (sim_load, sim_create_inferior): Update calls to
+       rx_load().
+       * main.c (main): Likewise.
+       * syscalls.c, syscalls.h (get_callbacks): New function.
+
 2011-12-03  Mike Frysinger  <vapier@gentoo.org>
 
        * aclocal.m4: New file.
index 6f882d686a89a5365c3fa33302d8e107d686555c..9a7e030d0ddb21bff32c97de44fdbe33b3a59a8c 100644 (file)
@@ -201,7 +201,7 @@ sim_load (SIM_DESC sd, char *prog, struct bfd *abfd, int from_tty)
   if (!abfd)
     return SIM_RC_FAIL;
 
-  rx_load (abfd);
+  rx_load (abfd, get_callbacks ());
   build_swap_list (abfd);
 
   return SIM_RC_OK;
@@ -214,7 +214,7 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd, char **argv, char **env)
 
   if (abfd)
     {
-      rx_load (abfd);
+      rx_load (abfd, NULL);
       build_swap_list (abfd);
     }
 
index 39eb26166ac5de1043eecb4937451694df4ca983..f6fc56e8545df013bea164823cfb37f124fd921b 100644 (file)
@@ -28,9 +28,36 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "libbfd.h"
 #include "cpu.h"
 #include "mem.h"
+#include "load.h"
 #include "elf/internal.h"
 #include "elf/common.h"
 
+/* Helper function for invoking a GDB-specified printf.  */
+static void
+xprintf (host_callback *callback, const char *fmt, ...)
+{
+  va_list ap;
+
+  va_start (ap, fmt);
+
+  (*callback->vprintf_filtered) (callback, fmt, ap);
+
+  va_end (ap);
+}
+
+/* Given a file offset, look up the section name.  */
+static const char *
+find_section_name_by_offset (bfd *abfd, file_ptr filepos)
+{
+  asection *s;
+
+  for (s = abfd->sections; s; s = s->next)
+    if (s->filepos == filepos)
+      return bfd_get_section_name (abfd, s);
+
+  return "(unknown)";
+}
+
 /* A note about endianness and swapping...
 
    The RX chip is CISC-like in that the opcodes are variable length
@@ -56,7 +83,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
    encoded in little-endian format.  */
 
 void
-rx_load (bfd *prog)
+rx_load (bfd *prog, host_callback *callback)
 {
   unsigned long highest_addr_loaded = 0;
   Elf_Internal_Phdr * phdrs;
@@ -105,6 +132,11 @@ rx_load (bfd *prog)
       if (verbose > 1)
        fprintf (stderr, "[load segment: lma=%08x vma=%08x size=%08x]\n",
                 (int) base, (int) p->p_vaddr, (int) size);
+      if (callback)
+       xprintf (callback,
+                "Loading section %s, size %#lx lma %08lx vma %08lx\n",
+                find_section_name_by_offset (prog, p->p_offset),
+                size, base, p->p_vaddr);
 
       buf = malloc (size);
       if (buf == NULL)
index b9c63d31f0acd85477f91b234b7d72c4c1b395eb..ef78814e4b2f66b4a4fa59109f365c2d811c5fd1 100644 (file)
@@ -20,8 +20,9 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 
 #include "bfd.h"
+#include "gdb/callback.h"
 
 extern int default_machine;
 
 void rx_set_mach (int mach);
-void rx_load (bfd *);
+void rx_load (bfd *, host_callback *callback);
index 6f43c9f1a7ccda3983cc12103189562b74f940fb..594c6c8a7d906bd9e58ad79e6a3ff751ffce4000 100644 (file)
@@ -174,7 +174,7 @@ main (int argc, char **argv)
   rx_in_gdb = 0;
   save_trace = trace;
   trace = 0;
-  rx_load (prog);
+  rx_load (prog, NULL);
   trace = save_trace;
 
   sim_disasm_init (prog);
index 6d2f16317df95260590702edf0de510a3729aabf..9263257878cfe644800c130bff27afa585c0149f 100644 (file)
@@ -43,6 +43,12 @@ set_callbacks (struct host_callback_struct *cb)
   callbacks = cb;
 }
 
+struct host_callback_struct *
+get_callbacks (void)
+{
+  return callbacks;
+}
+
 
 /* Arguments 1..4 are in R1..R4, remainder on stack.
 
index b1521ad3a60d47ec41a5a07a1c8699c198fe15a6..73bdef6965fbe4413d741c973c0bf3076c83dd95 100644 (file)
@@ -21,4 +21,5 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 struct host_callback_struct;
 extern void set_callbacks (struct host_callback_struct *);
+extern struct host_callback_struct * get_callbacks (void);
 extern int rx_syscall (int id);
This page took 0.027712 seconds and 4 git commands to generate.