diff options
author | Caroline Tice <cmtice@google.com> | 2020-07-01 12:39:08 -0700 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2020-07-16 11:37:15 -0400 |
commit | d0ce17d8537fb51583891073abe18d5bb60c0c24 (patch) | |
tree | 4997f10db6c2b90a0e0c9694b66f902e03116f76 /gdb/testsuite/gdb.dwarf2 | |
parent | 853772cc1874a858406ad9b02cdb14cc8b88392a (diff) | |
download | fsf-binutils-gdb-d0ce17d8537fb51583891073abe18d5bb60c0c24.zip fsf-binutils-gdb-d0ce17d8537fb51583891073abe18d5bb60c0c24.tar.gz fsf-binutils-gdb-d0ce17d8537fb51583891073abe18d5bb60c0c24.tar.bz2 |
gdb: fix issues with handling DWARF v5 rnglists & .dwo files.
While experimenting with GDB on DWARF 5 with split debug (dwo files),
I discovered that GDB was not reading the rnglist index
properly (it needed to be reprocessed in the same way the loclist
index does), and that there was no code for reading rnglists out of
dwo files at all. Also, the rnglist address reading function
(dwarf2_rnglists_process) was adding the base address to all rnglist
entries, when it's only supposed to add it to the DW_RLE_offset_pair
entries (http://dwarfstd.org/doc/DWARF5.pdf, p. 53), and was not
handling several entry types.
- Added 'reprocessing' for reading rnglist index (as is done for loclist
index).
- Added code for reading rnglists out of .dwo files.
- Added several missing rnglist forms to dwarf2_rnglists_process.
- Fixed bug that was alwayas adding base address for rnglists (only
one form needs that).
- Updated dwarf2_rnglists_process to read rnglist out of dwo file when
appropriate.
- Added new functions cu_debug_rnglist_section & read_rnglist_index.
- Added new testcase, dw5-rnglist-test.{cc,exp}
Special note about the new testcase:
In order for the test case to test anything meaningful, it must be
compiled with clang, not GCC. The way to do this is as follows:
$ make check RUNTESTFLAGS="CC_FOR_TARGET=/path/to/clang CXX_FOR_TARGET=/path/to/clang++ dw5-rnglist-test.exp"
This following version of clang was used for this testing:
clang version 9.0.1-11
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Change-Id: I3053c5ddc345720b8ed81e23a88fe537ab38748d
Diffstat (limited to 'gdb/testsuite/gdb.dwarf2')
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/dw5-rnglist-test.cc | 97 | ||||
-rw-r--r-- | gdb/testsuite/gdb.dwarf2/dw5-rnglist-test.exp | 40 |
2 files changed, 137 insertions, 0 deletions
diff --git a/gdb/testsuite/gdb.dwarf2/dw5-rnglist-test.cc b/gdb/testsuite/gdb.dwarf2/dw5-rnglist-test.cc new file mode 100644 index 0000000..81693f5 --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw5-rnglist-test.cc @@ -0,0 +1,97 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2020 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/>. */ + +#include <iostream> +#include <vector> + +struct node { + int id; + node *left; + node *right; + bool visited; +}; + +node node_array[50]; +unsigned int CUR_IDX = 0; + +node * +make_node (int val) +{ + node *new_node = &(node_array[CUR_IDX++]); + new_node->left = NULL; + new_node->right = NULL; + new_node->id = val; + new_node->visited = false; + + return new_node; +} + +void +tree_insert (node *root, int val) +{ + if (val < root->id) + { + if (root->left) + tree_insert (root->left, val); + else + root->left = make_node(val); + } + else if (val > root->id) + { + if (root->right) + tree_insert (root->right, val); + else + root->right = make_node(val); + } +} + +void +inorder (node *root) +{ + std::vector<node *> todo; + todo.push_back (root); + while (!todo.empty()) + { + node *curr = todo.back(); + todo.pop_back(); /* break-here */ + if (curr->visited) + std::cout << curr->id << " "; + else + { + curr->visited = true; + if (curr->right) + todo.push_back (curr->right); + todo.push_back (curr); + if (curr->left) + todo.push_back (curr->left); + } + } +} + +int +main (int argc, char **argv) +{ + node *root = make_node (35); + + tree_insert (root, 28); + tree_insert (root, 20); + tree_insert (root, 60); + + inorder (root); + + return 0; +} diff --git a/gdb/testsuite/gdb.dwarf2/dw5-rnglist-test.exp b/gdb/testsuite/gdb.dwarf2/dw5-rnglist-test.exp new file mode 100644 index 0000000..af6c34b --- /dev/null +++ b/gdb/testsuite/gdb.dwarf2/dw5-rnglist-test.exp @@ -0,0 +1,40 @@ +# Copyright 2020 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/>. + +# Check that GDB can find the variables in a lexical block with a +# DW_FORM_rnglistx DW_AT_ranges field. This test is intended for DWARF-5, +# compiled with clang++. + +standard_testfile .cc + +# This test is intended for targets which support DWARF-5. +# Since we pass an explicit -gdwarf-5 to the compiler, +# we let that be the test of whether the target supports it. + +if { [prepare_for_testing "failed to prepare" "${testfile}" \ + $srcfile {debug c++ additional_flags=-gdwarf-5 \ + additional_flags=-O0}] } { + return -1 +} + +if ![runto_main] { + return -1 +} + +gdb_breakpoint [gdb_get_line_number "break-here"] +gdb_continue_to_breakpoint "break-here" ".* break-here .*" + +gdb_test "print curr" "\\\(node \\\*\\\) $hex <node_array>" +gdb_test "print *curr" "= {id = 35, left = $hex <node_array\\+$decimal>, right = $hex <node_array\\+$decimal>, visited = false}" |