From patchwork Thu Oct 13 16:01:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guinevere Larsen X-Patchwork-Id: 58751 From: blarsen@redhat.com (Bruno Larsen) Date: Thu, 13 Oct 2022 18:01:15 +0200 List-Id: gdb-patches mailing list Subject: [PATCH 1/2] gdb/testsuite: allowed for function_range to deal with mangled functions In-Reply-To: <20221013160114.4143323-1-blarsen@redhat.com> References: <20221013160114.4143323-1-blarsen@redhat.com> Message-ID: <20221013160114.4143323-2-blarsen@redhat.com> When calling get_func_info inside a test case, it would cause failures if the function was printed using a C++ style mangled name. The current patch fixes this by allowing for mangled names along with the current rules. --- gdb/testsuite/lib/dwarf.exp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp index b85ec290299..351fc8fad6f 100644 --- a/gdb/testsuite/lib/dwarf.exp +++ b/gdb/testsuite/lib/dwarf.exp @@ -397,18 +397,28 @@ proc function_range { func src {options {debug}} } { # Take this into account by optionally allowing an argument list after # the function name. set func_pattern "$func\(\?\:\\(\.\*\\)\)?" + # It is also possible that the function is printed as + # <'mangled_func'base+[0-9]*> or similar. Therefore, allow for starting + # with a mangled name, and followed by more mangling and offsets. + set func_mangled "\_\[a-zA-Z0-9\]\*$func.\*" if { $func_length != 0 } { set func_pattern "$func_pattern\\+$func_length" } set test "x/2i $func+$func_length" gdb_test_multiple $test $test { -re ".*($hex) <$func_pattern>:\[^\r\n\]+\r\n\[ \]+($hex).*\.\r\n$gdb_prompt $" { set start $expect_out(1,string) set end $expect_out(2,string) + set func_length [expr $func_length + $end - $start] + } + -re ".*($hex) <$func_mangled>:\[^\r\n\]+\r\n\[ \]+($hex).*\.\r\n$gdb_prompt $" { + set start $expect_out(1,string) + set end $expect_out(2,string) + set func_length [expr $func_length + $end - $start] } } shared_gdb_end_use