From: Pedro Alves Date: Fri, 6 Sep 2013 17:41:50 +0000 (+0000) Subject: remote-sim.c: cleanup debug output code. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=fcde0081d9ab56137d740a528d2c833998b18dba;p=binutils-gdb.git remote-sim.c: cleanup debug output code. Manually tested with a --target=arm-eabi build, and doing $ arm-eabi-gcc ~/gdb/tests/main.c -o a.out -c -g $ ./gdb a.out ... (gdb) tar sim (gdb) load (gdb) set debug remote 1 (gdb) disassemble 0 Dump of assembler code for function main: gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x0, len 4, write 0 0x00000000 <+0>: 0xe1a0c00d mov r12, sp gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x4, len 4, write 0 0x00000004 <+4>: 0xe92dd800 push {r11, r12, lr, pc} gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x8, len 4, write 0 0x00000008 <+8>: 0xe24cb004 sub r11, r12, #4 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0xc, len 4, write 0 0x0000000c <+12>: 0xe24dd008 sub sp, sp, #8 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x10, len 4, write 0 0x00000010 <+16>: 0xe50b0010 str r0, [r11, #-16] gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x14, len 4, write 0 0x00000014 <+20>: 0xe50b1014 str r1, [r11, #-20] gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x18, len 4, write 0 0x00000018 <+24>: 0xe3a03000 mov r3, #0 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x1c, len 4, write 0 0x0000001c <+28>: 0xe1a00003 mov r0, r3 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x20, len 4, write 0 0x00000020 <+32>: 0xe24bd00c sub sp, r11, #12 gdbsim_xfer_inferior_memory: myaddr 0x7fffffffd400, memaddr 0x24, len 4, write 0 0x00000024 <+36>: 0xe89da800 ldm sp, {r11, sp, pc} End of assembler dump. (gdb) p *0 = 1 gdbsim_xfer_inferior_memory: myaddr 0xc69bc0, memaddr 0x0, len 4, write 1 0x00000001 $1 = 1 Which happens to differ from before, I think due to stdout line buffering: (gdb) disassemble 0 Dump of assembler code for function main: 0x00000000 <+0>: gdbsim_xfer_inferior_memory: myaddr 0x0x7fffffffd400, memaddr 0x0, len 4, write 0 0xe1a0c00d But the new output looks reasonable to me, better even. gdb/ 2013-09-06 Pedro Alves * remote-sim.c (gdbsim_xfer_inferior_memory): Use host_address_to_string, and send debug output to gdb_stdlog. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2dddbf36cef..2c7b6556a9b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2013-09-06 Pedro Alves + + * remote-sim.c (gdbsim_xfer_inferior_memory): Use + host_address_to_string, and send debug output to gdb_stdlog. + 2013-09-06 Ricard Wanderlof * Makefile.in (ALL_TARGET_OBS): Add cris-linux-tdep.o. diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index d534e566be8..49e2581bb20 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -1086,18 +1086,17 @@ gdbsim_xfer_inferior_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, gdb_assert (sim_data->gdbsim_desc != NULL); if (remote_debug) - { - /* FIXME: Send to something other than STDOUT? */ - printf_filtered ("gdbsim_xfer_inferior_memory: myaddr 0x"); - gdb_print_host_address (myaddr, gdb_stdout); - printf_filtered (", memaddr %s, len %d, write %d\n", - paddress (target_gdbarch (), memaddr), len, write); - if (remote_debug && write) - dump_mem (myaddr, len); - } + fprintf_unfiltered (gdb_stdlog, + "gdbsim_xfer_inferior_memory: myaddr %s, " + "memaddr %s, len %d, write %d\n", + host_address_to_string (myaddr), + paddress (target_gdbarch (), memaddr), + len, write); if (write) { + if (remote_debug && len > 0) + dump_mem (myaddr, len); len = sim_write (sim_data->gdbsim_desc, memaddr, myaddr, len); } else