mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-09-25 16:36:51 +08:00
[gdb/testsuite] Add test-case gdb.dwarf2/dw2-lines.exp
Add a new test-case gdb.dwarf2/dw2-lines.exp that tests various .debug_line sections. Tested on x86_64-linux.
This commit is contained in:
45
gdb/testsuite/gdb.dwarf2/dw2-lines.c
Normal file
45
gdb/testsuite/gdb.dwarf2/dw2-lines.c
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2021 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/>. */
|
||||||
|
|
||||||
|
void
|
||||||
|
foo (int x)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
bar (void)
|
||||||
|
{
|
||||||
|
asm ("bar_label: .globl bar_label");
|
||||||
|
foo (1);
|
||||||
|
asm ("bar_label_2: .globl bar_label_2");
|
||||||
|
foo (2);
|
||||||
|
asm ("bar_label_3: .globl bar_label_3");
|
||||||
|
foo (3);
|
||||||
|
asm ("bar_label_4: .globl bar_label_4");
|
||||||
|
foo (4);
|
||||||
|
asm ("bar_label_5: .globl bar_label_5");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
asm ("main_label: .globl main_label");
|
||||||
|
|
||||||
|
bar ();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
156
gdb/testsuite/gdb.dwarf2/dw2-lines.exp
Normal file
156
gdb/testsuite/gdb.dwarf2/dw2-lines.exp
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
# Copyright 2021 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 line number information in various configurations.
|
||||||
|
|
||||||
|
load_lib dwarf.exp
|
||||||
|
|
||||||
|
# This test can only be run on targets which support DWARF-2 and use gas.
|
||||||
|
require dwarf2_support 1
|
||||||
|
|
||||||
|
standard_testfile .c -dw.S
|
||||||
|
|
||||||
|
with_shared_gdb {
|
||||||
|
set func_info_vars \
|
||||||
|
[concat \
|
||||||
|
[get_func_info main] \
|
||||||
|
[get_func_info bar]]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Helper function.
|
||||||
|
proc line_for { l } {
|
||||||
|
global srcfile
|
||||||
|
set line [gdb_get_line_number "$l:" $srcfile]
|
||||||
|
return [expr $line + 1]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute test.
|
||||||
|
proc test_1 { _cv _cdw64 _lv _ldw64 } {
|
||||||
|
global srcfile srcfile2 testfile
|
||||||
|
global cv cdw64 lv ldw64
|
||||||
|
set cv $_cv
|
||||||
|
set cdw64 $_cdw64
|
||||||
|
set lv $_lv
|
||||||
|
set ldw64 $_ldw64
|
||||||
|
|
||||||
|
set asm_file [standard_output_file $srcfile2]
|
||||||
|
Dwarf::assemble $asm_file {
|
||||||
|
declare_labels Llines
|
||||||
|
global srcdir subdir srcfile cv cdw64 lv ldw64
|
||||||
|
global func_info_vars
|
||||||
|
foreach var $func_info_vars {
|
||||||
|
global $var
|
||||||
|
}
|
||||||
|
|
||||||
|
cu { version $cv is_64 $cdw64 } {
|
||||||
|
compile_unit {
|
||||||
|
{language @DW_LANG_C}
|
||||||
|
{name $srcfile}
|
||||||
|
{stmt_list $Llines DW_FORM_sec_offset}
|
||||||
|
} {
|
||||||
|
subprogram {
|
||||||
|
{external 1 flag}
|
||||||
|
{name main}
|
||||||
|
{low_pc $main_start addr}
|
||||||
|
{high_pc "$main_start + $main_len" addr}
|
||||||
|
}
|
||||||
|
subprogram {
|
||||||
|
{external 1 flag}
|
||||||
|
{name bar}
|
||||||
|
{low_pc $bar_start addr}
|
||||||
|
{high_pc "$bar_start + $bar_len" addr}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lines [list version $lv is_64 $ldw64] Llines {
|
||||||
|
include_dir "${srcdir}/${subdir}"
|
||||||
|
file_name "$srcfile" 1
|
||||||
|
|
||||||
|
program {
|
||||||
|
{DW_LNE_set_address bar_label}
|
||||||
|
{line [line_for bar_label]}
|
||||||
|
{DW_LNS_copy}
|
||||||
|
|
||||||
|
{DW_LNE_set_address bar_label_2}
|
||||||
|
{line [line_for bar_label_2]}
|
||||||
|
{DW_LNS_copy}
|
||||||
|
|
||||||
|
{DW_LNE_set_address bar_label_3}
|
||||||
|
{line [line_for bar_label_3]}
|
||||||
|
{DW_LNS_copy}
|
||||||
|
|
||||||
|
{DW_LNE_set_address bar_label_4}
|
||||||
|
{line [line_for bar_label_4]}
|
||||||
|
{DW_LNS_copy}
|
||||||
|
|
||||||
|
{DW_LNE_set_address bar_label_5}
|
||||||
|
{DW_LNE_end_sequence}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if { [prepare_for_testing "failed to prepare" ${testfile} \
|
||||||
|
[list $srcfile $asm_file] {nodebug}] } {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
if ![runto_main] {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
|
||||||
|
gdb_breakpoint "bar"
|
||||||
|
gdb_continue_to_breakpoint "foo \\(1\\)"
|
||||||
|
|
||||||
|
gdb_test "next" "foo \\(2\\).*" "next to foo (2)"
|
||||||
|
gdb_test "next" "foo \\(3\\).*" "next to foo (3)"
|
||||||
|
gdb_test "next" "foo \\(4\\).*" "next to foo (4)"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Add unique test prefix.
|
||||||
|
proc test { cv cdw64 lv ldw64 } {
|
||||||
|
with_test_prefix cv=$cv {
|
||||||
|
with_test_prefix cdw=[expr $cdw64 ? 64 : 32] {
|
||||||
|
with_test_prefix lv=$lv {
|
||||||
|
with_test_prefix ldw=[expr $ldw64 ? 64 : 32] {
|
||||||
|
test_1 $cv $cdw64 $lv $ldw64
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
set cv_low 2
|
||||||
|
set cv_high 4
|
||||||
|
|
||||||
|
set lv_low 2
|
||||||
|
set lv_high 3
|
||||||
|
|
||||||
|
for { set cv $cv_low } { $cv <= $cv_high } { incr cv } {
|
||||||
|
for { set lv $lv_low } { $lv <= $lv_high } { incr lv } {
|
||||||
|
# I'm not sure if it makes sense to have a dwarf vx CU with
|
||||||
|
# a dwarf vx+1 line unit.
|
||||||
|
if { $lv > $lv } {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach cdw64 { 0 1 } {
|
||||||
|
foreach ldw64 { 0 1 } {
|
||||||
|
test $cv $cdw64 $lv $ldw64
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -411,6 +411,7 @@ proc function_range { func src {options {debug}} } {
|
|||||||
|
|
||||||
# Extract the start, length, and end for function called NAME and
|
# Extract the start, length, and end for function called NAME and
|
||||||
# create suitable variables in the callers scope.
|
# create suitable variables in the callers scope.
|
||||||
|
# Return the list of created variables.
|
||||||
proc get_func_info { name {options {debug}} } {
|
proc get_func_info { name {options {debug}} } {
|
||||||
global srcdir subdir srcfile
|
global srcdir subdir srcfile
|
||||||
|
|
||||||
@ -423,6 +424,11 @@ proc get_func_info { name {options {debug}} } {
|
|||||||
${options}] \
|
${options}] \
|
||||||
func_start func_len
|
func_start func_len
|
||||||
set func_end "$func_start + $func_len"
|
set func_end "$func_start + $func_len"
|
||||||
|
|
||||||
|
return [list \
|
||||||
|
"${name}_start" \
|
||||||
|
"${name}_len" \
|
||||||
|
"${name}_end"]
|
||||||
}
|
}
|
||||||
|
|
||||||
# A DWARF assembler.
|
# A DWARF assembler.
|
||||||
|
Reference in New Issue
Block a user