Bug 20954 - GDB crashes if "set architecture rx"
Summary: GDB crashes if "set architecture rx"
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: tdep (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: 7.12.1
Assignee: Yao Qi
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-09 12:37 UTC by Yao Qi
Modified: 2016-12-09 16:01 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yao Qi 2016-12-09 12:37:14 UTC
(gdb) set architecture rx
Segmentation fault
Comment 1 cvs-commit@gcc.gnu.org 2016-12-09 15:32:57 UTC
The master branch has been updated by Yao Qi <qiyao@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a28aa6edd4ba848c110cd73fd4e29c2bbdb2cb72

commit a28aa6edd4ba848c110cd73fd4e29c2bbdb2cb72
Author: Yao Qi <yao.qi@linaro.org>
Date:   Fri Dec 9 15:27:43 2016 +0000

    Create tdep->rx_psw_type and tdep->rx_fpsw_type lazily
    
    I build GDB with all targets enabled, and "set architecture rx",
    GDB crashes,
    
    (gdb) set architecture rx
    
    Program received signal SIGSEGV, Segmentation fault.
    append_flags_type_flag (type=0x20cc360, bitpos=bitpos@entry=0, name=name@entry=0xd27529 "C") at ../../binutils-gdb/gdb/gdbtypes.c:4926
    4926				   name);
    (gdb) bt 10
     #0  append_flags_type_flag (type=0x20cc360, bitpos=bitpos@entry=0, name=name@entry=0xd27529 "C") at ../../binutils-gdb/gdb/gdbtypes.c:4926
     #1  0x00000000004ce725 in rx_gdbarch_init (info=..., arches=<optimized out>) at ../../binutils-gdb/gdb/rx-tdep.c:1051
     #2  0x00000000006b05a4 in gdbarch_find_by_info (info=...) at ../../binutils-gdb/gdb/gdbarch.c:5269
     #3  0x000000000060eee4 in gdbarch_update_p (info=...) at ../../binutils-gdb/gdb/arch-utils.c:557
     #4  0x000000000060f8a8 in set_architecture (ignore_args=<optimized out>, from_tty=1, c=<optimized out>) at ../../binutils-gdb/gdb/arch-utils.c:531
     #5  0x0000000000593d0b in do_set_command (arg=<optimized out>, arg@entry=0x20bee81 "rx ", from_tty=from_tty@entry=1, c=c@entry=0x20b1540)
        at ../../binutils-gdb/gdb/cli/cli-setshow.c:455
     #6  0x00000000007665c3 in execute_command (p=<optimized out>, p@entry=0x20bee70 "set architecture rx ", from_tty=1) at ../../binutils-gdb/gdb/top.c:666
     #7  0x00000000006935f4 in command_handler (command=0x20bee70 "set architecture rx ") at ../../binutils-gdb/gdb/event-top.c:577
     #8  0x00000000006938d8 in command_line_handler (rl=<optimized out>) at ../../binutils-gdb/gdb/event-top.c:767
     #9  0x0000000000692c2c in gdb_rl_callback_handler (rl=0x20be7f0 "") at ../../binutils-gdb/gdb/event-top.c:200
    
    The cause is that we want to access some builtin types in gdbarch init, but
    it is not initialized yet.  I fix it by creating the type when it is to be
    used.  We've already done this in sparc, sparc64 and m68k.
    
    gdb:
    
    2016-12-09  Yao Qi  <yao.qi@linaro.org>
    
    	PR tdep/20954
    	* rx-tdep.c (rx_psw_type): New function.
    	(rx_fpsw_type): New function.
    	(rx_register_type): Call rx_psw_type and rx_fpsw_type.
    	(rx_gdbarch_init): Move code to rx_psw_type and
    	rx_fpsw_type.
    
    gdb/testsuite:
    
    2016-12-09  Yao Qi  <yao.qi@linaro.org>
    
    	* gdb.base/all-architectures.exp.in: Remove kfail for "rx".
Comment 2 cvs-commit@gcc.gnu.org 2016-12-09 15:59:52 UTC
The gdb-7.12-branch branch has been updated by Yao Qi <qiyao@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=fa897675de62473e5c04330c5d5b782cd1ae04e9

commit fa897675de62473e5c04330c5d5b782cd1ae04e9
Author: Yao Qi <yao.qi@linaro.org>
Date:   Fri Dec 9 15:53:58 2016 +0000

    Create tdep->rx_psw_type and tdep->rx_fpsw_type lazily
    
    I build GDB with all targets enabled, and "set architecture rx",
    GDB crashes,
    
    (gdb) set architecture rx
    
    Program received signal SIGSEGV, Segmentation fault.
    append_flags_type_flag (type=0x20cc360, bitpos=bitpos@entry=0, name=name@entry=0xd27529 "C") at ../../binutils-gdb/gdb/gdbtypes.c:4926
    4926                               name);
    (gdb) bt 10
     #0  append_flags_type_flag (type=0x20cc360, bitpos=bitpos@entry=0, name=name@entry=0xd27529 "C") at ../../binutils-gdb/gdb/gdbtypes.c:4926
     #1  0x00000000004ce725 in rx_gdbarch_init (info=..., arches=<optimized out>) at ../../binutils-gdb/gdb/rx-tdep.c:1051
     #2  0x00000000006b05a4 in gdbarch_find_by_info (info=...) at ../../binutils-gdb/gdb/gdbarch.c:5269
     #3  0x000000000060eee4 in gdbarch_update_p (info=...) at ../../binutils-gdb/gdb/arch-utils.c:557
     #4  0x000000000060f8a8 in set_architecture (ignore_args=<optimized out>, from_tty=1, c=<optimized out>) at ../../binutils-gdb/gdb/arch-utils.c:531
     #5  0x0000000000593d0b in do_set_command (arg=<optimized out>, arg@entry=0x20bee81 "rx ", from_tty=from_tty@entry=1, c=c@entry=0x20b1540)
        at ../../binutils-gdb/gdb/cli/cli-setshow.c:455
     #6  0x00000000007665c3 in execute_command (p=<optimized out>, p@entry=0x20bee70 "set architecture rx ", from_tty=1) at ../../binutils-gdb/gdb/top.c:666
     #7  0x00000000006935f4 in command_handler (command=0x20bee70 "set architecture rx ") at ../../binutils-gdb/gdb/event-top.c:577
     #8  0x00000000006938d8 in command_line_handler (rl=<optimized out>) at ../../binutils-gdb/gdb/event-top.c:767
     #9  0x0000000000692c2c in gdb_rl_callback_handler (rl=0x20be7f0 "") at ../../binutils-gdb/gdb/event-top.c:200
    
    The cause is that we want to access some builtin types in gdbarch init, but
    it is not initialized yet.  I fix it by creating the type when it is to be
    used.  We've already done this in sparc, sparc64 and m68k.
    
    gdb:
    
    2016-12-09  Yao Qi  <yao.qi@linaro.org>
    
    	PR tdep/20954
    	* rx-tdep.c (rx_psw_type): New function.
    	(rx_fpsw_type): New function.
    	(rx_register_type): Call rx_psw_type and rx_fpsw_type.
    	(rx_gdbarch_init): Move code to rx_psw_type and
    	rx_fpsw_type.
Comment 3 Yao Qi 2016-12-09 16:01:43 UTC
Patch is pushed into master and 7.12 branch.