diff options
author | Andrew Burgess <aburgess@broadcom.com> | 2013-12-17 17:18:44 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@broadcom.com> | 2013-12-17 17:24:15 +0000 |
commit | bdf22206150b19e4903e9cbc520de2c49b2a2b7f (patch) | |
tree | 2e00051459ac6b8c2cf911b0a2497fb18a0ee29d /gdb/testsuite | |
parent | 4a357820add595557dcd08d275288a4bcf43cbcb (diff) | |
download | gdb-bdf22206150b19e4903e9cbc520de2c49b2a2b7f.zip gdb-bdf22206150b19e4903e9cbc520de2c49b2a2b7f.tar.gz gdb-bdf22206150b19e4903e9cbc520de2c49b2a2b7f.tar.bz2 |
Convert the unavailable vector to be bit, not byte, based.
https://sourceware.org/ml/gdb-patches/2013-12/msg00144.html
The vector of unavailable parts of a value is currently byte based. Given
that we can model a value down to the bit level, we can potentially loose
information with the current implementation. After this patch we model the
unavailable information in bits.
gdb/ChangeLog
* dwarf2loc.c (read_pieced_value): Mark bits, not bytes
unavailable, use correct bit length.
* value.c (struct value): Extend comment on unavailable to
indicate that it is bit based.
(value_bits_available): New function.
(value_bytes_available): Call value_bits_available.
(value_entirely_available): Check against the bit length, not byte
length.
(mark_value_bits_unavailable): New function.
(mark_value_bytes_unavailable): Move contents to
mark_value_bits_unavailable, call to same.
(memcmp_with_bit_offsets): New function.
(value_available_contents_bits_eq): New function, takes the
functionality from value_available_contents_eq but uses
memcmp_with_bit_offsets now, and is bit not byte based.
(value_available_contents_eq): Move implementation into
value_available_contents_bits_eq, call to same.
(value_contents_copy_raw): Work on bits, not bytes.
(unpack_value_bits_as_long_1): Check availability in bits, not
bytes.
* value.h (value_bits_available): Declare new function.
(mark_value_bits_unavailable): Declare new function.
gdb/testsuite/ChangeLog
* gdb.trace/unavailable-dwarf-piece.c: New file.
* gdb.trace/unavailable-dwarf-piece.exp: New file.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.trace/unavailable-dwarf-piece.c | 86 | ||||
-rw-r--r-- | gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp | 334 |
3 files changed, 425 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index b9f98f7..0d768bc 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-12-17 Andrew Burgess <aburgess@broadcom.com> + + * gdb.trace/unavailable-dwarf-piece.c: New file. + * gdb.trace/unavailable-dwarf-piece.exp: New file. + 2013-12-15 Yao Qi <yao@codesourcery.com> * gdb.perf/skip-prologue.c: New. diff --git a/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.c b/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.c new file mode 100644 index 0000000..46474f2 --- /dev/null +++ b/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.c @@ -0,0 +1,86 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2013 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/>. */ + +struct s +{ + unsigned char a; + unsigned char b; + unsigned char c; +}; + +struct t +{ + /* First, a complete byte. */ + unsigned char a; + /* Next, 8 single bits. */ + unsigned char b : 1; + unsigned char c : 1; + unsigned char d : 1; + unsigned char e : 1; + unsigned char f : 1; + unsigned char g : 1; + unsigned char h : 1; + unsigned char i : 1; + /* Now another byte. */ + unsigned char j; +}; + +void +end (void) +{ + /* Nothing. */ +} + +void +dummy (void) +{ + /* Nothing. */ +} + +int +foo (struct s x, struct s y, struct s z) +{ + dummy (); + asm (".global foo_end_lbl\nfoo_end_lbl:"); + return 0; +} + +int +bar (struct t x, struct t y, struct t z) +{ + dummy (); + asm (".global bar_end_lbl\nbar_end_lbl:"); + return 0; +} + +int +main (void) +{ + struct s v = { 0, 1, 2 }; + struct t w = { 5, 0, 1, 0, 1, 0, 1, 0, 1, 7 }; + int ans; + + ans = foo (v, v, v); + + end (); + + ans = bar (w, w, w); + + end (); + + return ans; +} diff --git a/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp b/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp new file mode 100644 index 0000000..be38588 --- /dev/null +++ b/gdb/testsuite/gdb.trace/unavailable-dwarf-piece.exp @@ -0,0 +1,334 @@ +# Copyright (C) 2013 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/>. + +load_lib "trace-support.exp" +load_lib dwarf.exp + +if {![dwarf2_support]} { + return 0 +} + +standard_testfile .c + +set asm_file "${testfile}-dbg.s" +set opts {} + +if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${binfile}1.o \ + object {nodebug}] != "" } { + return -1 +} + +Dwarf::assemble $asm_file { + declare_labels uchar_label struct_s_label foo_label struct_t_label bar_label + + cu {} { + compile_unit {{language @DW_LANG_C}} { + uchar_label: DW_TAG_base_type { + {name "unsigned char"} + {byte_size 1 DW_FORM_sdata} + {encoding @DW_ATE_unsigned_char} + } + + struct_s_label: DW_TAG_structure_type { + {name s} + {byte_size 3 DW_FORM_sdata} + {decl_file 1} + {decl_line 1} + } { + DW_TAG_member { + {name a} + {type :$uchar_label} + {data_member_location { + DW_OP_plus_uconst 0 + } SPECIAL_expr} + } + DW_TAG_member { + {name b} + {type :$uchar_label} + {data_member_location { + DW_OP_plus_uconst 1 + } SPECIAL_expr} + } + DW_TAG_member { + {name c} + {type :$uchar_label} + {data_member_location { + DW_OP_plus_uconst 2 + } SPECIAL_expr} + } + } + + struct_t_label: DW_TAG_structure_type { + {name t} + {byte_size 3 DW_FORM_sdata} + {decl_file 1} + {decl_line 1} + } { + DW_TAG_member { + {name a} + {type :$uchar_label} + {data_member_location { + DW_OP_plus_uconst 0 + } SPECIAL_expr} + } + DW_TAG_member { + {name b} + {type :$uchar_label} + {byte_size 1 DW_FORM_sdata} + {bit_size 1 DW_FORM_sdata} + {bit_offset 7 DW_FORM_sdata} + {data_member_location { + DW_OP_plus_uconst 1 + } SPECIAL_expr} + } + DW_TAG_member { + {name c} + {type :$uchar_label} + {byte_size 1 DW_FORM_sdata} + {bit_size 1 DW_FORM_sdata} + {bit_offset 6 DW_FORM_sdata} + {data_member_location { + DW_OP_plus_uconst 1 + } SPECIAL_expr} + } + DW_TAG_member { + {name d} + {type :$uchar_label} + {byte_size 1 DW_FORM_sdata} + {bit_size 1 DW_FORM_sdata} + {bit_offset 5 DW_FORM_sdata} + {data_member_location { + DW_OP_plus_uconst 1 + } SPECIAL_expr} + } + DW_TAG_member { + {name e} + {type :$uchar_label} + {byte_size 1 DW_FORM_sdata} + {bit_size 1 DW_FORM_sdata} + {bit_offset 4 DW_FORM_sdata} + {data_member_location { + DW_OP_plus_uconst 1 + } SPECIAL_expr} + } + DW_TAG_member { + {name f} + {type :$uchar_label} + {byte_size 1 DW_FORM_sdata} + {bit_size 1 DW_FORM_sdata} + {bit_offset 3 DW_FORM_sdata} + {data_member_location { + DW_OP_plus_uconst 1 + } SPECIAL_expr} + } + DW_TAG_member { + {name g} + {type :$uchar_label} + {byte_size 1 DW_FORM_sdata} + {bit_size 1 DW_FORM_sdata} + {bit_offset 2 DW_FORM_sdata} + {data_member_location { + DW_OP_plus_uconst 1 + } SPECIAL_expr} + } + DW_TAG_member { + {name h} + {type :$uchar_label} + {byte_size 1 DW_FORM_sdata} + {bit_size 1 DW_FORM_sdata} + {bit_offset 1 DW_FORM_sdata} + {data_member_location { + DW_OP_plus_uconst 1 + } SPECIAL_expr} + } + DW_TAG_member { + {name i} + {type :$uchar_label} + {byte_size 1 DW_FORM_sdata} + {bit_size 1 DW_FORM_sdata} + {bit_offset 0 DW_FORM_sdata} + {data_member_location { + DW_OP_plus_uconst 1 + } SPECIAL_expr} + } + DW_TAG_member { + {name j} + {type :$uchar_label} + {data_member_location { + DW_OP_plus_uconst 2 + } SPECIAL_expr} + } + } + + DW_TAG_subprogram { + {name foo} + {decl_file 1} + {low_pc foo addr} + {high_pc foo_end_lbl addr} + } { + DW_TAG_formal_parameter { + {type :$struct_s_label} + {name x} + {location { + DW_OP_lit0 + DW_OP_stack_value + DW_OP_piece 2 + DW_OP_reg0 + DW_OP_piece 1 + } SPECIAL_expr} + } + DW_TAG_formal_parameter { + {type :$struct_s_label} + {name y} + {location { + DW_OP_lit0 + DW_OP_stack_value + DW_OP_piece 1 + DW_OP_reg0 + DW_OP_piece 1 + DW_OP_lit0 + DW_OP_stack_value + DW_OP_piece 1 + } SPECIAL_expr} + } + DW_TAG_formal_parameter { + {type :$struct_s_label} + {name z} + {location { + DW_OP_reg0 + DW_OP_piece 1 + DW_OP_lit0 + DW_OP_stack_value + DW_OP_piece 2 + } SPECIAL_expr} + } + } + + + DW_TAG_subprogram { + {name bar} + {decl_file 1} + {low_pc bar addr} + {high_pc bar_end_lbl addr} + } { + DW_TAG_formal_parameter { + {type :$struct_t_label} + {name x} + {location { + DW_OP_lit0 + DW_OP_stack_value + DW_OP_piece 1 + DW_OP_reg0 + DW_OP_bit_piece 1 0 + DW_OP_lit0 + DW_OP_stack_value + DW_OP_bit_piece 7 0 + DW_OP_lit0 + DW_OP_stack_value + DW_OP_piece 1 + } SPECIAL_expr} + } + DW_TAG_formal_parameter { + {type :$struct_t_label} + {name y} + {location { + DW_OP_lit0 + DW_OP_stack_value + DW_OP_piece 1 + DW_OP_lit0 + DW_OP_stack_value + DW_OP_bit_piece 3 0 + DW_OP_reg0 + DW_OP_bit_piece 1 0 + DW_OP_lit0 + DW_OP_stack_value + DW_OP_bit_piece 4 0 + DW_OP_lit0 + DW_OP_stack_value + DW_OP_piece 1 + } SPECIAL_expr} + } + DW_TAG_formal_parameter { + {type :$struct_t_label} + {name z} + {location { + DW_OP_lit0 + DW_OP_stack_value + DW_OP_piece 1 + DW_OP_lit0 + DW_OP_stack_value + DW_OP_bit_piece 7 0 + DW_OP_reg0 + DW_OP_bit_piece 1 0 + DW_OP_lit0 + DW_OP_stack_value + DW_OP_piece 1 + } 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] { + return -1 +} + +if ![gdb_target_supports_trace] { + unsupported "target does not support trace" + return -1 +} + +gdb_breakpoint "end" + +with_test_prefix "tracing foo" { + gdb_test "trace foo" ".*" + gdb_test_no_output "tstart" + gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" + gdb_test_no_output "tstop" + + gdb_test "tfind 0" "Found trace frame 0, tracepoint .*" + gdb_test "p/d x" "\\\$${decimal} = {a = 0, b = 0, c = <unavailable>}" + gdb_test "p/d y" "\\\$${decimal} = {a = 0, b = <unavailable>, c = 0}" + gdb_test "p/d z" "\\\$${decimal} = {a = <unavailable>, b = 0, c = 0}" + + gdb_test "tfind none" "No longer looking at any trace frame.*" +} + +with_test_prefix "tracing bar" { + gdb_test "trace bar" ".*" + gdb_test_no_output "tstart" + gdb_test "continue" "Continuing\\.\[ \r\n\]+Breakpoint.*" + gdb_test_no_output "tstop" + + gdb_test "tfind 0" "Found trace frame 0, tracepoint .*" + gdb_test "p/d x" "\\\$${decimal} = {a = 0, b = <unavailable>, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = 0, j = 0}" + gdb_test "p/d y" "\\\$${decimal} = {a = 0, b = 0, c = 0, d = 0, e = <unavailable>, f = 0, g = 0, h = 0, i = 0, j = 0}" + gdb_test "p/d z" "\\\$${decimal} = {a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, i = <unavailable>, j = 0}" + + gdb_test "tfind none" "No longer looking at any trace frame.*" +} |