2018-01-01 05:43:02 +01:00
|
|
|
# Copyright 2013-2018 Free Software Foundation, Inc.
|
2013-08-24 03:53:06 +02:00
|
|
|
|
|
|
|
# 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/>.
|
|
|
|
load_lib dwarf.exp
|
|
|
|
|
|
|
|
# This test can only be run on targets which support DWARF-2 and use gas.
|
|
|
|
if {![dwarf2_support]} {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
standard_testfile .c entry-values-dw.S
|
|
|
|
|
|
|
|
if {[gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile}1.o \
|
|
|
|
object {nodebug}] != ""} {
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
2016-03-06 17:20:08 +01:00
|
|
|
if {[gdb_compile [list ${binfile}1.o] \
|
|
|
|
"${binfile}1" executable {}] != ""} {
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Start GDB and load executable file, compute the offset of the
|
2014-12-29 04:56:51 +01:00
|
|
|
# instruction in bar returned from foo. It is needed in the Dwarf
|
|
|
|
# Assembler.
|
2013-08-24 03:53:06 +02:00
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
gdb_start
|
|
|
|
gdb_reinitialize_dir $srcdir/$subdir
|
2016-03-06 17:20:08 +01:00
|
|
|
gdb_load ${binfile}1
|
2013-08-24 03:53:06 +02:00
|
|
|
|
2014-12-29 04:56:51 +01:00
|
|
|
set returned_from_foo ""
|
2013-08-24 03:53:06 +02:00
|
|
|
|
2013-10-02 20:09:26 +02:00
|
|
|
if { [istarget "arm*-*-*"] || [istarget "aarch64*-*-*"] } {
|
|
|
|
set call_insn "bl"
|
2014-01-22 16:37:41 +01:00
|
|
|
} elseif { [istarget "s390*-*-*"] } {
|
|
|
|
set call_insn "brasl"
|
2014-07-02 12:59:02 +02:00
|
|
|
} elseif { [istarget "powerpc*-*-*"] } {
|
|
|
|
set call_insn "bl"
|
2014-12-30 07:40:49 +01:00
|
|
|
} elseif { [istarget "mips*-*-*"] } {
|
|
|
|
# Skip the delay slot after the instruction used to make a call
|
|
|
|
# (which can be a jump or a branch) if it has one.
|
|
|
|
#
|
|
|
|
# JUMP (or BRANCH) foo
|
|
|
|
# insn1
|
|
|
|
# insn2
|
|
|
|
#
|
|
|
|
# Most MIPS instructions used to make calls have a delay slot.
|
|
|
|
# These include JAL, JALS, JALX, JALR, JALRS, BAL and BALS.
|
|
|
|
# In this case the program continues from `insn2' when `foo'
|
|
|
|
# returns. The only exception is JALRC, in which case execution
|
|
|
|
# resumes from `insn1' instead.
|
|
|
|
set call_insn {jalrc|[jb]al[sxr]*[ \t][^\r\n]+\r\n}
|
2016-02-19 20:29:23 +01:00
|
|
|
} elseif [is_amd64_regs_target] {
|
|
|
|
set call_insn "callq"
|
2013-10-02 20:09:26 +02:00
|
|
|
} else {
|
|
|
|
set call_insn "call"
|
|
|
|
}
|
|
|
|
|
2014-12-29 04:56:51 +01:00
|
|
|
# Calculate the offset of the instruction in bar returned from foo.
|
2013-08-24 03:53:06 +02:00
|
|
|
set test "disassemble bar"
|
|
|
|
gdb_test_multiple $test $test {
|
2016-02-19 20:29:23 +01:00
|
|
|
-re ".*$hex <\\+$decimal>:\[ \t\]+\\y$call_insn\\y\[^\r\n\]+\r\n\[ \]+$hex <\\+($decimal)>:.*$gdb_prompt $" {
|
2014-12-29 04:56:51 +01:00
|
|
|
set returned_from_foo $expect_out(1,string)
|
2013-08-24 03:53:06 +02:00
|
|
|
}
|
|
|
|
-re ".*$gdb_prompt $" {
|
|
|
|
fail $test
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-29 04:56:51 +01:00
|
|
|
if { [string equal $returned_from_foo ""] } {
|
2016-12-01 21:40:05 +01:00
|
|
|
fail "find the call or branch instruction offset in bar"
|
2013-08-24 03:53:06 +02:00
|
|
|
# The following test makes no sense if the offset is unknown. We need
|
|
|
|
# to update the pattern above to match call or branch instruction for
|
|
|
|
# the target architecture.
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
gdb_exit
|
|
|
|
|
|
|
|
# Make some DWARF for the test.
|
|
|
|
set asm_file [standard_output_file $srcfile2]
|
|
|
|
Dwarf::assemble $asm_file {
|
|
|
|
declare_labels int_label foo_label
|
2014-12-29 04:56:51 +01:00
|
|
|
global returned_from_foo
|
2014-11-22 14:28:31 +01:00
|
|
|
global srcdir subdir srcfile
|
|
|
|
|
|
|
|
set bar_result [function_range bar ${srcdir}/${subdir}/${srcfile}]
|
|
|
|
set bar_start [lindex $bar_result 0]
|
|
|
|
set bar_length [lindex $bar_result 1]
|
2013-08-24 03:53:06 +02:00
|
|
|
|
|
|
|
cu {} {
|
|
|
|
compile_unit {{language @DW_LANG_C}} {
|
|
|
|
int_label: base_type {
|
|
|
|
{name int}
|
|
|
|
{encoding @DW_ATE_signed}
|
|
|
|
{byte_size 4 DW_FORM_sdata}
|
|
|
|
}
|
|
|
|
|
|
|
|
foo_label: subprogram {
|
2015-01-12 00:45:43 +01:00
|
|
|
{decl_file 1 sdata}
|
2014-11-22 14:28:31 +01:00
|
|
|
{MACRO_AT_func { foo ${srcdir}/${subdir}/${srcfile} }}
|
2013-08-24 03:53:06 +02:00
|
|
|
} {
|
|
|
|
formal_parameter {
|
|
|
|
{type :$int_label}
|
|
|
|
{name i}
|
|
|
|
{location {DW_OP_reg0} SPECIAL_expr}
|
|
|
|
}
|
|
|
|
formal_parameter {
|
|
|
|
{type :$int_label}
|
|
|
|
{name j}
|
|
|
|
{location {DW_OP_reg1} SPECIAL_expr}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
subprogram {
|
|
|
|
{name bar}
|
2015-01-12 00:45:43 +01:00
|
|
|
{decl_file 1 sdata}
|
2014-11-22 14:28:31 +01:00
|
|
|
{low_pc $bar_start addr}
|
|
|
|
{high_pc "$bar_start + $bar_length" addr}
|
2015-01-12 00:45:43 +01:00
|
|
|
{GNU_all_call_sites 1 sdata}
|
2013-08-24 03:53:06 +02:00
|
|
|
} {
|
|
|
|
formal_parameter {
|
|
|
|
{type :$int_label}
|
|
|
|
{name i}
|
|
|
|
}
|
|
|
|
|
|
|
|
GNU_call_site {
|
2014-12-29 04:56:51 +01:00
|
|
|
{low_pc "$bar_start + $returned_from_foo" addr}
|
2013-08-24 03:53:06 +02:00
|
|
|
{abstract_origin :$foo_label}
|
|
|
|
} {
|
|
|
|
# Faked entry values are reference to variables 'global1'
|
|
|
|
# and 'global2' and faked locations are register 0 and
|
|
|
|
# register 1.
|
|
|
|
GNU_call_site_parameter {
|
|
|
|
{location {DW_OP_reg0} SPECIAL_expr}
|
|
|
|
{GNU_call_site_value {
|
|
|
|
addr global1
|
|
|
|
deref_size 4
|
|
|
|
} SPECIAL_expr}
|
|
|
|
}
|
|
|
|
GNU_call_site_parameter {
|
|
|
|
{location {DW_OP_reg1} SPECIAL_expr}
|
|
|
|
{GNU_call_site_value {
|
|
|
|
addr global2
|
|
|
|
deref_size 4
|
|
|
|
} SPECIAL_expr}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if {[gdb_compile $asm_file ${binfile}2.o object {nodebug}] != ""} {
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
if {[gdb_compile [list ${binfile}1.o ${binfile}2.o] \
|
|
|
|
"${binfile}" executable {}] != ""} {
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
clean_restart ${testfile}
|
|
|
|
|
|
|
|
if ![runto_main] {
|
2016-12-01 21:40:05 +01:00
|
|
|
fail "can't run to main"
|
2013-08-24 03:53:06 +02:00
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
gdb_breakpoint "foo"
|
|
|
|
|
|
|
|
gdb_continue_to_breakpoint "foo"
|
|
|
|
|
|
|
|
gdb_test_no_output "set print entry-values both"
|
|
|
|
|
|
|
|
gdb_test_sequence "bt" "bt (1)" {
|
|
|
|
"\[\r\n\]#0 .* foo \\(i=[-]?[0-9]+, i@entry=2, j=[-]?[0-9]+, j@entry=3\\)"
|
|
|
|
"\[\r\n\]#1 .* bar \\(i=<optimized out>, i@entry=<optimized out>\\)"
|
2016-03-06 17:20:08 +01:00
|
|
|
"\[\r\n\]#2 .* \.?main \\(\\)"
|
2013-08-24 03:53:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Update global variables 'global1' and 'global2' and test that the
|
|
|
|
# entry values are updated too.
|
|
|
|
|
Stop assuming no-debug-info variables have type int
An earlier commit made GDB no longer assume no-debug-info functions
return int. This commit gives the same treatment to variables.
Currently, you can end misled by GDB over output like this:
(gdb) p var
$1 = -1
(gdb) p /x var
$2 = 0xffffffff
until you realize that GDB is assuming that the variable is an "int",
because:
(gdb) ptype var
type = <data variable, no debug info>
You may try to fix it by casting, but that doesn't really help:
(gdb) p /x (unsigned long long) var
$3 = 0xffffffffffffffff # incorrect
^^
That's incorrect output, because the variable was defined like this:
uint64_t var = 0x7fffffffffffffff;
^^
What happened is that with the cast, GDB did an int -> 'unsigned long
long' conversion instead of reinterpreting the variable as the cast-to
type. To get at the variable properly you have to reinterpret the
variable's address manually instead, with either:
(gdb) p /x *(unsigned long long *) &var
$4 = 0x7fffffffffffffff
(gdb) p /x {unsigned long long} &var
$5 = 0x7fffffffffffffff
After this commit GDB does it for you. This is what you'll get
instead:
(gdb) p var
'var' has unknown type; cast it to its declared type
(gdb) p /x (unsigned long long) var
$1 = 0x7fffffffffffffff
As in the functions patch, the "compile" machinery doesn't currently
have the cast-to type handy, so it continues assuming no-debug
variables have int type, though now at least it warns.
The change to gdb.cp/m-static.exp deserves an explanation:
- gdb_test "print 'gnu_obj_1::method()::sintvar'" "\\$\[0-9\]+ = 4" \
+ gdb_test "print (int) 'gnu_obj_1::method()::sintvar'" "\\$\[0-9\]+ = 4" \
That's printing the "sintvar" function local static of the
"gnu_obj_1::method()" method.
The problem with that test is that that "'S::method()::static_var'"
syntax doesn't really work in C++ as you'd expect. The way to make it
work correctly currently is to quote the method part, not the whole
expression, like:
(gdb) print 'gnu_obj_1::method()'::sintvar
If you wrap the whole expression in quotes, like in m-static.exp, what
really happens is that the parser considers the whole string as a
symbol name, but there's no debug symbol with that name. However,
local statics have linkage and are given a mangled name that demangles
to the same string as the full expression, so that's what GDB prints.
After this commit, and without the cast, the print in m-static.exp
would error out saying that the variable has unknown type:
(gdb) p 'gnu_obj_1::method()::sintvar'
'gnu_obj_1::method()::sintvar' has unknown type; cast it to its declared type
TBC, if currently (even before this series) you try to print any
function local static variable of type other than int, you'll get
bogus results. You can see that with m-static.cc as is, even.
Printing the "svar" local, which is a boolean (1 byte) still prints as
"int" (4 bytes):
(gdb) p 'gnu_obj_1::method()::svar'
$1 = 1
(gdb) ptype 'gnu_obj_1::method()::svar'
type = <data variable, no debug info>
This probably prints some random bogus value on big endian machines.
If 'svar' was of some aggregate type (etc.) we'd still print it as
int, so the problem would have been more obvious... After this
commit, you'll get instead:
(gdb) p 'gnu_obj_1::method()::svar'
'gnu_obj_1::method()::svar' has unknown type; cast it to its declared type
... so at least GDB is no longer misleading. Making GDB find the real
local static debug symbol is the subject of the following patches. In
the end, it'll all "Just Work".
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* ax-gdb.c: Include "typeprint.h".
(gen_expr_for_cast): New function.
(gen_expr) <OP_CAST, OP_CAST_TYPE>: Use it.
<OP_VAR_VALUE, OP_MSYM_VAR_VALUE>: Error out if the variable's
type is unknown.
* dwarf2read.c (new_symbol_full): Fallback to int instead of
nodebug_data_symbol.
* eval.c: Include "typeprint.h".
(evaluate_subexp_standard) <OP_VAR_VALUE, OP_VAR_MSYM_VALUE>:
Error out if symbol has unknown type.
<UNOP_CAST, UNOP_CAST_TYPE>: Common bits factored out to
evaluate_subexp_for_cast.
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof): Handle
OP_VAR_MSYM_VALUE.
(evaluate_subexp_for_cast): New function.
* gdbtypes.c (init_nodebug_var_type): New function.
(objfile_type): Use it to initialize types of variables with no
debug info.
* typeprint.c (error_unknown_type): New.
* typeprint.h (error_unknown_type): New declaration.
* compile/compile-c-types.c (convert_type_basic): Handle
TYPE_CODE_ERROR; warn and fallback to int for variables with
unknown type.
gdb/testsuite/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* gdb.asm/asm-source.exp: Add casts to int.
* gdb.base/nodebug.c (dataglobal8, dataglobal32_1, dataglobal32_2)
(dataglobal64_1, dataglobal64_2): New globals.
* gdb.base/nodebug.exp: Test different expressions involving the
new globals, with print, whatis and ptype. Add casts to int.
* gdb.base/solib-display.exp: Add casts to int.
* gdb.compile/compile-ifunc.exp: Expect warning. Add cast to int.
* gdb.cp/m-static.exp: Add cast to int.
* gdb.dwarf2/dw2-skip-prologue.exp: Add cast to int.
* gdb.threads/tls-nodebug.exp: Check that gdb errors out printing
tls variable with no debug info without a cast. Test with a cast
to int too.
* gdb.trace/entry-values.exp: Add casts.
2017-09-04 21:21:15 +02:00
|
|
|
gdb_test_no_output "set var *(int *) &global1=10"
|
|
|
|
gdb_test_no_output "set var *(int *) &global2=11"
|
2013-08-24 03:53:06 +02:00
|
|
|
|
|
|
|
gdb_test_sequence "bt" "bt (2)" {
|
|
|
|
"\[\r\n\]#0 .* foo \\(i=[-]?[0-9]+, i@entry=10, j=[-]?[0-9]+, j@entry=11\\)"
|
|
|
|
"\[\r\n\]#1 .* bar \\(i=<optimized out>, i@entry=<optimized out>\\)"
|
2016-03-06 17:20:08 +01:00
|
|
|
"\[\r\n\]#2 .* \.?main \\(\\)"
|
2013-08-24 03:53:06 +02:00
|
|
|
}
|
2013-08-24 03:54:59 +02:00
|
|
|
|
|
|
|
# Restart GDB and trace.
|
|
|
|
|
|
|
|
clean_restart $binfile
|
|
|
|
|
|
|
|
load_lib "trace-support.exp"
|
|
|
|
|
|
|
|
if ![runto_main] {
|
2016-12-01 21:40:05 +01:00
|
|
|
fail "can't run to main to check for trace support"
|
2013-08-24 03:54:59 +02:00
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
if ![gdb_target_supports_trace] {
|
|
|
|
unsupported "target does not support trace"
|
|
|
|
return -1
|
|
|
|
}
|
|
|
|
|
|
|
|
gdb_test "trace foo" "Tracepoint $decimal at .*"
|
|
|
|
|
|
|
|
# Collect arguments i and j. Collect 'global1' which is entry value
|
|
|
|
# of argument i. Don't collect 'global2' to test the entry value of
|
|
|
|
# argument j.
|
|
|
|
|
|
|
|
gdb_trace_setactions "set action for tracepoint 1" "" \
|
Stop assuming no-debug-info variables have type int
An earlier commit made GDB no longer assume no-debug-info functions
return int. This commit gives the same treatment to variables.
Currently, you can end misled by GDB over output like this:
(gdb) p var
$1 = -1
(gdb) p /x var
$2 = 0xffffffff
until you realize that GDB is assuming that the variable is an "int",
because:
(gdb) ptype var
type = <data variable, no debug info>
You may try to fix it by casting, but that doesn't really help:
(gdb) p /x (unsigned long long) var
$3 = 0xffffffffffffffff # incorrect
^^
That's incorrect output, because the variable was defined like this:
uint64_t var = 0x7fffffffffffffff;
^^
What happened is that with the cast, GDB did an int -> 'unsigned long
long' conversion instead of reinterpreting the variable as the cast-to
type. To get at the variable properly you have to reinterpret the
variable's address manually instead, with either:
(gdb) p /x *(unsigned long long *) &var
$4 = 0x7fffffffffffffff
(gdb) p /x {unsigned long long} &var
$5 = 0x7fffffffffffffff
After this commit GDB does it for you. This is what you'll get
instead:
(gdb) p var
'var' has unknown type; cast it to its declared type
(gdb) p /x (unsigned long long) var
$1 = 0x7fffffffffffffff
As in the functions patch, the "compile" machinery doesn't currently
have the cast-to type handy, so it continues assuming no-debug
variables have int type, though now at least it warns.
The change to gdb.cp/m-static.exp deserves an explanation:
- gdb_test "print 'gnu_obj_1::method()::sintvar'" "\\$\[0-9\]+ = 4" \
+ gdb_test "print (int) 'gnu_obj_1::method()::sintvar'" "\\$\[0-9\]+ = 4" \
That's printing the "sintvar" function local static of the
"gnu_obj_1::method()" method.
The problem with that test is that that "'S::method()::static_var'"
syntax doesn't really work in C++ as you'd expect. The way to make it
work correctly currently is to quote the method part, not the whole
expression, like:
(gdb) print 'gnu_obj_1::method()'::sintvar
If you wrap the whole expression in quotes, like in m-static.exp, what
really happens is that the parser considers the whole string as a
symbol name, but there's no debug symbol with that name. However,
local statics have linkage and are given a mangled name that demangles
to the same string as the full expression, so that's what GDB prints.
After this commit, and without the cast, the print in m-static.exp
would error out saying that the variable has unknown type:
(gdb) p 'gnu_obj_1::method()::sintvar'
'gnu_obj_1::method()::sintvar' has unknown type; cast it to its declared type
TBC, if currently (even before this series) you try to print any
function local static variable of type other than int, you'll get
bogus results. You can see that with m-static.cc as is, even.
Printing the "svar" local, which is a boolean (1 byte) still prints as
"int" (4 bytes):
(gdb) p 'gnu_obj_1::method()::svar'
$1 = 1
(gdb) ptype 'gnu_obj_1::method()::svar'
type = <data variable, no debug info>
This probably prints some random bogus value on big endian machines.
If 'svar' was of some aggregate type (etc.) we'd still print it as
int, so the problem would have been more obvious... After this
commit, you'll get instead:
(gdb) p 'gnu_obj_1::method()::svar'
'gnu_obj_1::method()::svar' has unknown type; cast it to its declared type
... so at least GDB is no longer misleading. Making GDB find the real
local static debug symbol is the subject of the following patches. In
the end, it'll all "Just Work".
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* ax-gdb.c: Include "typeprint.h".
(gen_expr_for_cast): New function.
(gen_expr) <OP_CAST, OP_CAST_TYPE>: Use it.
<OP_VAR_VALUE, OP_MSYM_VAR_VALUE>: Error out if the variable's
type is unknown.
* dwarf2read.c (new_symbol_full): Fallback to int instead of
nodebug_data_symbol.
* eval.c: Include "typeprint.h".
(evaluate_subexp_standard) <OP_VAR_VALUE, OP_VAR_MSYM_VALUE>:
Error out if symbol has unknown type.
<UNOP_CAST, UNOP_CAST_TYPE>: Common bits factored out to
evaluate_subexp_for_cast.
(evaluate_subexp_for_address, evaluate_subexp_for_sizeof): Handle
OP_VAR_MSYM_VALUE.
(evaluate_subexp_for_cast): New function.
* gdbtypes.c (init_nodebug_var_type): New function.
(objfile_type): Use it to initialize types of variables with no
debug info.
* typeprint.c (error_unknown_type): New.
* typeprint.h (error_unknown_type): New declaration.
* compile/compile-c-types.c (convert_type_basic): Handle
TYPE_CODE_ERROR; warn and fallback to int for variables with
unknown type.
gdb/testsuite/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* gdb.asm/asm-source.exp: Add casts to int.
* gdb.base/nodebug.c (dataglobal8, dataglobal32_1, dataglobal32_2)
(dataglobal64_1, dataglobal64_2): New globals.
* gdb.base/nodebug.exp: Test different expressions involving the
new globals, with print, whatis and ptype. Add casts to int.
* gdb.base/solib-display.exp: Add casts to int.
* gdb.compile/compile-ifunc.exp: Expect warning. Add cast to int.
* gdb.cp/m-static.exp: Add cast to int.
* gdb.dwarf2/dw2-skip-prologue.exp: Add cast to int.
* gdb.threads/tls-nodebug.exp: Check that gdb errors out printing
tls variable with no debug info without a cast. Test with a cast
to int too.
* gdb.trace/entry-values.exp: Add casts.
2017-09-04 21:21:15 +02:00
|
|
|
"collect i, j, (int) global1, \(\*\(void \*\*\) \(\$$spreg\)\) @ 128" "^$"
|
2013-08-24 03:54:59 +02:00
|
|
|
|
|
|
|
gdb_test_no_output "tstart"
|
|
|
|
|
|
|
|
gdb_breakpoint "end"
|
|
|
|
gdb_continue_to_breakpoint "end"
|
|
|
|
|
|
|
|
gdb_test_no_output "tstop"
|
|
|
|
|
|
|
|
gdb_test "tfind" "Found trace frame 0, .*" "tfind start"
|
|
|
|
|
|
|
|
# Since 'global2' is not collected, j@entry is expected to be 'unavailable'.
|
|
|
|
gdb_test "bt 1" "#0 .* foo \\(i=\[-\]?$decimal, i@entry=2, j=\[-\]?$decimal, j@entry=<unavailable>\\).*"
|
|
|
|
|
Add options to skip unavailable locals
This is the patch to add new option '--skip-unavailable' to MI
commands '-stack-list-{locals, arguments, variables}'. This patch
extends list_args_or_locals to add a new parameter 'skip_unavailable',
and don't list locals or arguments if values are unavailable and
'skip_unavailable' is true.
This is inspecting a trace frame (tfind mode), where only a few
locals have been collected.
-stack-list-locals, no switch vs new switch:
-stack-list-locals --simple-values
^done,locals=[{name="array",type="unsigned char [2]"},{name="i",type="int",value="<unavailable>"}]
-stack-list-locals --skip-unavailable --simple-values
^done,locals=[{name="array",type="unsigned char [2]"}]
-stack-list-arguments, no switch vs new switch:
-stack-list-arguments --simple-values
^done,stack-args=[frame={level="0",args=[{name="j",type="int",value="4"},{name="s",type="char *",value="<unavailable>"}]},frame={level="1",args=[]}]
-stack-list-arguments --skip-unavailable --simple-values
^done,stack-args=[frame={level="0",args=[{name="j",type="int",value="4"}]},frame={level="1",args=[]}]
-stack-list-variables, no switch vs new switch:
-stack-list-variables --simple-values
^done,variables=[{name="j",arg="1",type="int",value="4"},{name="s",arg="1",type="char *",value="<unavailable>"},{name="array",type="unsigned char [2]"},{name="i",type="int",value="<unavailable>"}]
-stack-list-variables --skip-unavailable --simple-values
^done,variables=[{name="j",arg="1",type="int",value="4"},{name="array",type="unsigned char [2]"}]
tests are added to test these new options.
gdb:
2013-08-27 Pedro Alves <pedro@codesourcery.com>
Yao Qi <yao@codesourcery.com>
* mi/mi-cmd-stack.c (list_args_or_locals): Adjust prototype.
(parse_no_frames_option): Remove.
(mi_cmd_stack_list_locals): Handle --skip-unavailable.
(mi_cmd_stack_list_args): Adjust.
(mi_cmd_stack_list_variables): Handle --skip-unavailable.
(list_arg_or_local): Add new parameter 'skip_unavailable'. Return
early if SKIP_UNAVAILABLE is true and ARG->val is unavailable.
Caller update.
(list_args_or_locals): New parameter 'skip_unavailable'.
Handle it.
* valprint.c (scalar_type_p): Rename to ...
(val_print_scalar_type_p): ... this. Make extern.
(val_print, value_check_printable): Adjust.
* valprint.h (val_print_scalar_type_p): Declare.
* value.c (value_entirely_unavailable): New function.
* value.h (value_entirely_unavailable): Declare.
* NEWS: Mention the new option "--skip-unavailable" to MI
commands '-stack-list-locals', '-stack-list-arguments' and
'-stack-list-variables'.
gdb/doc:
2013-08-27 Pedro Alves <pedro@codesourcery.com>
Yao Qi <yao@codesourcery.com>
* gdb.texinfo (GDB/MI Stack Manipulation) <-stack-list-locals>:
Document new --skip-unavailable option.
<-stack-list-variables>: Document new --skip-unavailable option.
gdb/testsuite:
2013-08-27 Yao Qi <yao@codesourcery.com>
* gdb.trace/entry-values.exp: Test unavailable entry value is
not shown when option '--skip-unavailable' is specified.
* gdb.trace/mi-trace-unavailable.exp (test_trace_unavailable):
Add tests for new option '--skip-unavailable'.
2013-08-27 07:20:57 +02:00
|
|
|
# Test that unavailable "j@entry" is not shown when command option
|
|
|
|
# --skip-unavailable is used.
|
|
|
|
gdb_test "interpreter-exec mi \"-stack-list-arguments --skip-unavailable --simple-values\"" \
|
|
|
|
"\r\n\\^done,stack-args=\\\[frame={level=\"0\",args=\\\[{name=\"i\",type=\"int\",value=\".*\"},{name=\"i@entry\",type=\"int\",value=\"2\"},{name=\"j\",type=\"int\",value=\".*\"}\\\]},frame=.*\\\].*"
|
|
|
|
|
2013-08-24 03:54:59 +02:00
|
|
|
gdb_test "tfind" "Target failed to find requested trace frame\..*"
|