summaryrefslogtreecommitdiff
path: root/sim/rx
diff options
context:
space:
mode:
authorKevin Buettner <kevinb@redhat.com>2012-03-03 01:23:45 +0000
committerKevin Buettner <kevinb@redhat.com>2012-03-03 01:23:45 +0000
commitec43c7943ae35dc7f1a69ee0be0bfe0d1a9bb92e (patch)
tree5fd1110dd3d4008c38d327db3a69df17763dedb4 /sim/rx
parent44fc9128422d18f3111134dd0a9aa1639f28963e (diff)
downloadgdb-ec43c7943ae35dc7f1a69ee0be0bfe0d1a9bb92e.tar.gz
Update rx sim so that it'll print load statistics.
Diffstat (limited to 'sim/rx')
-rw-r--r--sim/rx/ChangeLog13
-rw-r--r--sim/rx/gdb-if.c4
-rw-r--r--sim/rx/load.c34
-rw-r--r--sim/rx/load.h3
-rw-r--r--sim/rx/main.c2
-rw-r--r--sim/rx/syscalls.c6
-rw-r--r--sim/rx/syscalls.h1
7 files changed, 58 insertions, 5 deletions
diff --git a/sim/rx/ChangeLog b/sim/rx/ChangeLog
index d9c2264994d..659fc6bd627 100644
--- a/sim/rx/ChangeLog
+++ b/sim/rx/ChangeLog
@@ -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.
diff --git a/sim/rx/gdb-if.c b/sim/rx/gdb-if.c
index 6f882d686a8..9a7e030d0dd 100644
--- a/sim/rx/gdb-if.c
+++ b/sim/rx/gdb-if.c
@@ -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);
}
diff --git a/sim/rx/load.c b/sim/rx/load.c
index 39eb26166ac..f6fc56e8545 100644
--- a/sim/rx/load.c
+++ b/sim/rx/load.c
@@ -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)
diff --git a/sim/rx/load.h b/sim/rx/load.h
index b9c63d31f0a..ef78814e4b2 100644
--- a/sim/rx/load.h
+++ b/sim/rx/load.h
@@ -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);
diff --git a/sim/rx/main.c b/sim/rx/main.c
index 6f43c9f1a7c..594c6c8a7d9 100644
--- a/sim/rx/main.c
+++ b/sim/rx/main.c
@@ -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);
diff --git a/sim/rx/syscalls.c b/sim/rx/syscalls.c
index 6d2f16317df..9263257878c 100644
--- a/sim/rx/syscalls.c
+++ b/sim/rx/syscalls.c
@@ -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.
diff --git a/sim/rx/syscalls.h b/sim/rx/syscalls.h
index b1521ad3a60..73bdef6965f 100644
--- a/sim/rx/syscalls.h
+++ b/sim/rx/syscalls.h
@@ -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);