Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 0/1] Fix 'rw_pieced_value' for values casted to different type.
@ 2022-04-22 14:44 Stephan Rohr via Gdb-patches
  2022-04-22 14:44 ` [PATCH 1/1] gdb/dwarf2: " Stephan Rohr via Gdb-patches
  0 siblings, 1 reply; 12+ messages in thread
From: Stephan Rohr via Gdb-patches @ 2022-04-22 14:44 UTC (permalink / raw)
  To: gdb-patches; +Cc: tom, stephan.rohr

From: "Rohr, Stephan" <stephan.rohr@intel.com>

This patch provides a fix for the issue when a user wants to print a pieced
value, as described by 'DW_OP_piece' or 'DW_OP_bit_piece', casted to a
different type, e.g. 'print (<type> []) <variable>).

If a lazy value is fetched, GDB allocates space based on the enclosing type's
length and typically reads the 'full' object.  This is not implemented for 
pieced values and causes an internal error if 'type' and 'enclosing_type' of
a value are not identical, which is the case if the user explicitly casts the
variable.

However, GDB can read the value based on its type.  Thus, it should be
sufficient to check if the type's length (potentially shifted by
'embedded_offset') does not exceed the enclosing type's length which was
used for memory allocation.

Test-cases are added to 'gdb/testsuite/gdb.dwarf2/shortpiece.exp'.

The testsuite was run for the following targets:
* unix/-64
* native-gdbserver
* native-extended-gdbserver
* unix/-m32

Rohr, Stephan (1):
  gdb/dwarf2: Fix 'rw_pieced_value' for values casted to different type.

 gdb/dwarf2/expr.c                       |  6 ++----
 gdb/testsuite/gdb.dwarf2/shortpiece.exp | 12 ++++++++++++
 2 files changed, 14 insertions(+), 4 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-10-21 17:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-22 14:44 [PATCH 0/1] Fix 'rw_pieced_value' for values casted to different type Stephan Rohr via Gdb-patches
2022-04-22 14:44 ` [PATCH 1/1] gdb/dwarf2: " Stephan Rohr via Gdb-patches
2022-06-06 16:51   ` Bruno Larsen via Gdb-patches
2022-07-14  7:50   ` Rohr, Stephan via Gdb-patches
2022-07-21 12:21   ` Rohr, Stephan via Gdb-patches
2022-08-02  6:30   ` Rohr, Stephan via Gdb-patches
2022-08-11  7:09   ` Rohr, Stephan via Gdb-patches
2022-08-19  7:41   ` Rohr, Stephan via Gdb-patches
2022-08-19 16:39   ` Simon Marchi via Gdb-patches
2022-10-11  8:03     ` Rohr, Stephan via Gdb-patches
2022-10-21 17:06       ` Tom Tromey
2022-10-14 18:28     ` Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox