This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] h8300 "info registers" broken


At Mon, 10 Feb 2014 15:30:02 +0000,
Pedro Alves wrote:
> 
> On 02/08/2014 06:36 PM, Yoshinori Sato wrote:
> 
> 
> > #10 0x00000000005b954e in frame_unwind_register (frame=<optimized out>, 
> >     regnum=13, buf=<optimized out>) at ../../gdb/frame.c:1064
> 
> Hard to reason about an optimized build...  Please try with "-g3 -O0".
> 
> I don't have a h8300-elf toolchain handy, and the h8300-linux
> toolchain I found doesn't seem to want to link executables,
> but I managed to try something by building an .o file, and debugging
> that.  I don't see a crash, but instead GDB complains CCR
> is unavailable.
> 
> (gdb) info target
> Symbols from "/home/pedro/h8300-main.o".
> simulator:
>         Attached to sim running program /home/pedro/h8300-main.o
> 
> #instructions executed           0
> #cycles (v approximate)          0
> #real time taken            0.0000
> #virtual time taken         0.0000
> #compiles                        0
> #cache size                   1024
>         While running this, GDB does not access memory from...
> Local exec file:
>         `/home/pedro/h8300-main.o', file type elf32-h8300.
>         Entry point: 0x0
>         0x00000000 - 0x00000024 is .text
>         0x00000024 - 0x00000024 is .data
>         0x00000024 - 0x00000024 is .bss
> (gdb) b *0
> Breakpoint 1 at 0x0: file main.c, line 4.
> (gdb) r
> Starting program: /home/pedro/h8300-main.o
> 
> Breakpoint 1, foo (i=0x0 <foo>) at main.c:4
> 4       {
> (gdb) info registers
> r0             0x0000  0
> r1             0x0000  0
> r2             0x0000  0
> r3             0x0000  0
> r4             0x0000  0
> r5             0x0000  0
> r6             0x0000  0
> sp             0x0000  0
> Register 13 is not available
> (gdb) info registers ccr
> Register 13 is not available
> 
> The problem seems to me that the h8300 port does not define
> a register_sim_regno gdbarch hook, and thus when fetching
> registers off of the sim, we end up in legacy_register_sim_regno
> trying to figure out the sim register number for the raw CCR register:
> 
> int
> legacy_register_sim_regno (struct gdbarch *gdbarch, int regnum)
> {
>   /* Only makes sense to supply raw registers.  */
>   gdb_assert (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch));
>   /* NOTE: cagney/2002-05-13: The old code did it this way and it is
>      suspected that some GDB/SIM combinations may rely on this
>      behavour.  The default should be one2one_register_sim_regno
>      (below).  */
>   if (gdbarch_register_name (gdbarch, regnum) != NULL
>       && gdbarch_register_name (gdbarch, regnum)[0] != '\0')
>     return regnum;
>   else
>     return LEGACY_SIM_REGNO_IGNORE;
> }
> 
> And because the raw ccr register does not have a name, that returns
> LEGACY_SIM_REGNO_IGNORE.  Which means that we never actually
> read the ccr raw value.  Before the <unavailable> support, this
> must have meant that ccr was _always_ read as 0...  At least, I'm
> not seeing how this ever worked.
> 
> Looking at sim/h8300/sim-main.h, it seems like the sim's register
> numbers are compatible with gdb's.
> 
> This patch below "works" for me, as in, I can now print CCR,
> but that's about all I tested (and am willing to test) myself.
> 
> Look me know how this looks to you.
>

It works fine (add my workaround).
But still abort.
I think reproduce "MALLOC_CHECK_=3 gdb".
backtrace in bellow.

Program received signal SIGABRT, Aborted.
0x00007ffff6aaf1d5 in __GI_raise (sig=sig@entry=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56	../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff6aaf1d5 in __GI_raise (sig=sig@entry=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff6ab2388 in __GI_abort () at abort.c:90
#2  0x00007ffff6aea7bb in __libc_message (do_abort=do_abort@entry=1, 
    fmt=fmt@entry=0x7ffff6be4bee "%s")
    at ../sysdeps/unix/sysv/linux/libc_fatal.c:199
#3  0x00007ffff6aea89e in __GI___libc_fatal (
    message=0x7ffff6be8328 "memory clobbered past end of allocated block\n")
    at ../sysdeps/unix/sysv/linux/libc_fatal.c:210
#4  0x00007ffff6afaca5 in mabort (status=<optimized out>) at mcheck.c:364
#5  0x00007ffff6afad6b in checkhdr (hdr=<optimized out>) at mcheck.c:115
#6  checkhdr (hdr=<optimized out>) at mcheck.c:86
#7  0x00007ffff6afb0f5 in freehook (ptr=0xe804a0, caller=0x674f6e <xfree+31>)
    at mcheck.c:188
#8  0x0000000000674f6e in xfree (ptr=0xe804a0)
    at ../../gdb/common/common-utils.c:108
#9  0x00000000004c8cc9 in value_free (val=0xe7e350) at ../../gdb/value.c:1437
#10 0x0000000000641c4b in frame_register_unwind (frame=0xe33370, regnum=13, 
    optimizedp=0x7fffffffdcec, unavailablep=0x7fffffffdce8, 
    lvalp=0x7fffffffdcd8, addrp=0x7fffffffdce0, realnump=0x7fffffffdcdc, 
    bufferp=0x7fffffffdd10 "") at ../../gdb/frame.c:1032
#11 0x0000000000641dfc in frame_unwind_register (frame=0xe33370, regnum=13, 
    buf=0x7fffffffdd10 "") at ../../gdb/frame.c:1064
---Type <return> to continue, or q <return> to quit---
#12 0x00000000006421e2 in frame_unwind_register_signed (frame=0xe33370, 
    regnum=13) at ../../gdb/frame.c:1162
#13 0x000000000064221f in get_frame_register_signed (frame=0xe33430, regnum=13)
    at ../../gdb/frame.c:1169
#14 0x0000000000407da4 in h8300_print_register (gdbarch=0xe64970, 
    file=0xe54f70, frame=0xe33430, regno=13) at ../../gdb/h8300-tdep.c:1021
#15 0x00000000004084aa in h8300_print_registers_info (gdbarch=0xe64970, 
    file=0xe54f70, frame=0xe33430, regno=13, cpregs=0)
    at ../../gdb/h8300-tdep.c:1131
#16 0x0000000000544d01 in gdbarch_print_registers_info (gdbarch=0xe64970, 
    file=0xe54f70, frame=0xe33430, regnum=13, all=0)
    at ../../gdb/gdbarch.c:2357
#17 0x00000000005149b1 in registers_info (addr_exp=0xdac3b2 "", fpregs=0)
    at ../../gdb/infcmd.c:2212
#18 0x0000000000514b18 in nofp_registers_info (addr_exp=0xdac3af "ccr", 
    from_tty=1) at ../../gdb/infcmd.c:2264
#19 0x0000000000442f49 in do_cfunc (c=0xe12130, args=0xdac3af "ccr", 
    from_tty=1) at ../../gdb/cli/cli-decode.c:107
#20 0x000000000044603d in cmd_func (cmd=0xe12130, args=0xdac3af "ccr", 
    from_tty=1) at ../../gdb/cli/cli-decode.c:1886
#21 0x000000000063673d in execute_command (p=0xdac3b1 "r", from_tty=1)
    at ../../gdb/top.c:458
#22 0x000000000053d1d9 in command_handler (
---Type <return> to continue, or q <return> to quit---
    command=0xdac3a0 "info registers ccr") at ../../gdb/event-top.c:435
#23 0x000000000053d792 in command_line_handler (rl=0xe806c0 "")
    at ../../gdb/event-top.c:632
#24 0x00000000006c45b8 in rl_callback_read_char ()
    at ../../readline/callback.c:220
#25 0x000000000053cd0c in rl_callback_read_char_wrapper (client_data=0x0)
    at ../../gdb/event-top.c:164
#26 0x000000000053d0f0 in stdin_event_handler (error=0, client_data=0x0)
    at ../../gdb/event-top.c:375
#27 0x000000000053bcd7 in handle_file_event (data=...)
    at ../../gdb/event-loop.c:768
#28 0x000000000053b1b9 in process_event () at ../../gdb/event-loop.c:342
#29 0x000000000053b280 in gdb_do_one_event () at ../../gdb/event-loop.c:406
#30 0x000000000053b2d0 in start_event_loop () at ../../gdb/event-loop.c:431
#31 0x000000000053cd3e in cli_command_loop (data=0x0)
    at ../../gdb/event-top.c:179
#32 0x00000000005333ab in current_interp_command_loop ()
    at ../../gdb/interps.c:327
#33 0x000000000053441d in captured_command_loop (data=0x0)
    at ../../gdb/main.c:266
#34 0x0000000000530872 in catch_errors (func=0x534402 <captured_command_loop>, 
    func_args=0x0, errstring=0x7c8b42 "", mask=RETURN_MASK_ALL)
    at ../../gdb/exceptions.c:524
---Type <return> to continue, or q <return> to quit---
#35 0x00000000005357a1 in captured_main (data=0x7fffffffe3f0)
    at ../../gdb/main.c:1054
#36 0x0000000000530872 in catch_errors (func=0x5346b5 <captured_main>, 
    func_args=0x7fffffffe3f0, errstring=0x7c8b42 "", mask=RETURN_MASK_ALL)
    at ../../gdb/exceptions.c:524
#37 0x00000000005357ca in gdb_main (args=0x7fffffffe3f0)
    at ../../gdb/main.c:1062
#38 0x0000000000406584 in main (argc=2, argv=0x7fffffffe4f8)
    at ../../gdb/gdb.c:33

-- 
Yoshinori Sato
<ysato@users.sourceforge.jp>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]