diff options
author | Kevin Buettner <kevinb@redhat.com> | 2012-03-03 01:23:45 +0000 |
---|---|---|
committer | Kevin Buettner <kevinb@redhat.com> | 2012-03-03 01:23:45 +0000 |
commit | d98bfeb0233c622e936bdda16ff03277077f5ca2 (patch) | |
tree | e0a9fd593d3f088e78995b29fc3a2f33087f9ba1 /sim/rx | |
parent | 636b802b4e0e0bfa08745d20c468bac0a38e9fa1 (diff) | |
download | gdb-d98bfeb0233c622e936bdda16ff03277077f5ca2.zip gdb-d98bfeb0233c622e936bdda16ff03277077f5ca2.tar.gz gdb-d98bfeb0233c622e936bdda16ff03277077f5ca2.tar.bz2 |
Update rx sim so that it'll print load statistics.
Diffstat (limited to 'sim/rx')
-rw-r--r-- | sim/rx/ChangeLog | 13 | ||||
-rw-r--r-- | sim/rx/gdb-if.c | 4 | ||||
-rw-r--r-- | sim/rx/load.c | 34 | ||||
-rw-r--r-- | sim/rx/load.h | 3 | ||||
-rw-r--r-- | sim/rx/main.c | 2 | ||||
-rw-r--r-- | sim/rx/syscalls.c | 6 | ||||
-rw-r--r-- | sim/rx/syscalls.h | 1 |
7 files changed, 58 insertions, 5 deletions
diff --git a/sim/rx/ChangeLog b/sim/rx/ChangeLog index d9c2264..659fc6b 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 6f882d6..9a7e030 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 39eb261..f6fc56e 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 b9c63d3..ef78814 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 6f43c9f..594c6c8 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 6d2f163..9263257 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 b1521ad..73bdef6 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); |