diff options
author | Luis Machado <luis.machado@linaro.org> | 2019-11-01 10:11:17 -0300 |
---|---|---|
committer | Luis Machado <luis.machado@linaro.org> | 2019-11-01 10:11:17 -0300 |
commit | bd5766ec689140aa80e5d4fd5c0bf9c990f5a38b (patch) | |
tree | e01a47729932a5823db698dafb63736d6f209aad /gdb/testsuite/gdb.arch | |
parent | d0d6922c6855c7473d0d2dda45674443ba503cb5 (diff) | |
download | gdb-bd5766ec689140aa80e5d4fd5c0bf9c990f5a38b.zip gdb-bd5766ec689140aa80e5d4fd5c0bf9c990f5a38b.tar.gz gdb-bd5766ec689140aa80e5d4fd5c0bf9c990f5a38b.tar.bz2 |
[ARM, thumb] Fix disassembling bug after reloading a symbol file
The speed optimization from commit 5f6cac4085c95c5339b9549dc06d4f9184184fa6
made GDB skip reloading all symbols when the same symbol file is reloaded.
As a result, ARM targets only read the mapping symbols the first time we
load a symbol file. When reloaded, the speed optimization above will
cause an early return and gdbarch_record_special_symbol won't be called to
save mapping symbol data, which in turn affects disassembling of thumb
instructions.
First load and correct disassemble output:
Dump of assembler code for function main:
0x0000821c <+0>: bx pc
0x0000821e <+2>: nop
0x00008220 <+4>: mov r0, #0
0x00008224 <+8>: bx lr
Second load and incorrect disassemble output:
Dump of assembler code for function main:
0x0000821c <+0>: bx pc
0x0000821e <+2>: nop
0x00008220 <+4>: movs r0, r0
0x00008222 <+6>: b.n 0x8966
0x00008224 <+8>: vrhadd.u16 d14, d14, d31
This happens because the mapping symbol data is stored in an objfile_key-based
container, and that data isn't preserved across the two symbol loading
operations.
The following patch fixes this by storing the mapping symbol data in a
bfd_key-based container, which doesn't change as long as the bfd is the same.
I've also added a new test to verify the correct disassemble output.
gdb/ChangeLog:
2019-11-01 Luis Machado <luis.machado@linaro.org>
PR gdb/25124
* arm-tdep.c (arm_per_objfile): Rename to ...
(arm_per_bfd): ... this.
(arm_objfile_data_key): Rename to ...
(arm_bfd_data_key): ... this.
(arm_find_mapping_symbol): Adjust access to new bfd_key-based
data.
(arm_record_special_symbol): Likewise.
gdb/testsuite/ChangeLog:
2019-11-01 Luis Machado <luis.machado@linaro.org>
PR gdb/25124
* gdb.arch/pr25124.S: New file.
* gdb.arch/pr25124.exp: New file.
Change-Id: I22c3e6ebe9bfedad66d56fe9656994fa1761c485
Diffstat (limited to 'gdb/testsuite/gdb.arch')
-rw-r--r-- | gdb/testsuite/gdb.arch/pr25124.S | 35 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/pr25124.exp | 49 |
2 files changed, 84 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.arch/pr25124.S b/gdb/testsuite/gdb.arch/pr25124.S new file mode 100644 index 0000000..79f82c7 --- /dev/null +++ b/gdb/testsuite/gdb.arch/pr25124.S @@ -0,0 +1,35 @@ +/* Test proper disassembling of ARM thumb instructions when reloading a symbol + file. + + Copyright 2012-2019 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + + .syntax unified + .thumb + .text + .p2align 2 + .global main + .thumb + .thumb_func + .type main, %function +main: + bx pc + nop +.code 32 + mov r0, #0 + bx lr + .size main, .-main diff --git a/gdb/testsuite/gdb.arch/pr25124.exp b/gdb/testsuite/gdb.arch/pr25124.exp new file mode 100644 index 0000000..656079c --- /dev/null +++ b/gdb/testsuite/gdb.arch/pr25124.exp @@ -0,0 +1,49 @@ +# Copyright 2019 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Test proper disassembling of ARM thumb instructions when reloading a symbol +# file. + +if {![is_aarch32_target]} then { + verbose "Skipping ARM tests." + return +} + +standard_testfile .S + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug] != "" } { + untested "failed to compile" + return -1 +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir + +# Load the symbol file the first time. +gdb_load ${binfile} + +# Check if the disassemble ouput is correct. +gdb_test "x /i main+8" \ + "$hex <main\\+8>:\[ \t\]+bx\[ \t\]+lr" \ + "disassemble thumb instruction (1st try)" + +# Reload the symbol file to trigger the bug. +gdb_load ${binfile} + +# Check if the disassemble output is the same as above. +gdb_test "x /i main+8" \ + "$hex <main\\+8>:\[ \t\]+bx\[ \t\]+lr" \ + "disassemble thumb instruction (2nd try)" |