* [PATCH 0/2] Fix crash in 'bt' with Ada
@ 2021-04-01 17:58 Tom Tromey
2021-04-01 17:58 ` [PATCH 1/2] Use common_val_print_checked in print_variable_and_value Tom Tromey
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Tom Tromey @ 2021-04-01 17:58 UTC (permalink / raw)
To: gdb-patches
GDB was crashing when doing a 'bt' of a complicated Ada program.
I tracked this down to a combination of two bugs.
I couldn't write a test that would reproduce the crash, but I did
manage to write one that shows a related problem. This is included in
the second patch.
The first patch is not Ada-specific. I couldn't come up with an
isolated test for this change.
Regression tested on x86-64 Fedora 32.
Tom
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] Use common_val_print_checked in print_variable_and_value
2021-04-01 17:58 [PATCH 0/2] Fix crash in 'bt' with Ada Tom Tromey
@ 2021-04-01 17:58 ` Tom Tromey
2021-04-16 10:45 ` Tom de Vries
2021-04-01 17:58 ` [PATCH 2/2] Avoid crash in Ada value printing with optimized-out array Tom Tromey
2021-04-15 16:08 ` [PATCH 0/2] Fix crash in 'bt' with Ada Tom Tromey
2 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2021-04-01 17:58 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
GDB was crashing in "bt full" for a large Ada program. I tracked this
down to a combination of bugs.
The first bug, fixed here, is that print_variable_and_value calls
common_val_print. Normally only the value-printing implementation
should call this; from the top level, common_val_print_checked is
preferred, because it correctly handles values that are wholly
optimized out.
I wasn't able to write a test case for this.
gdb/ChangeLog
2021-04-01 Tom Tromey <tromey@adacore.com>
* printcmd.c (print_variable_and_value): Use
common_val_print_checked.
---
gdb/ChangeLog | 5 +++++
gdb/printcmd.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index c82f709136f..a4f62f207d0 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -2387,7 +2387,7 @@ print_variable_and_value (const char *name, struct symbol *var,
val = read_var_value (var, NULL, frame);
get_user_print_options (&opts);
opts.deref_ref = 1;
- common_val_print (val, stream, indent, &opts, current_language);
+ common_val_print_checked (val, stream, indent, &opts, current_language);
/* common_val_print invalidates FRAME when a pretty printer calls inferior
function. */
--
2.26.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/2] Avoid crash in Ada value printing with optimized-out array
2021-04-01 17:58 [PATCH 0/2] Fix crash in 'bt' with Ada Tom Tromey
2021-04-01 17:58 ` [PATCH 1/2] Use common_val_print_checked in print_variable_and_value Tom Tromey
@ 2021-04-01 17:58 ` Tom Tromey
2021-04-15 16:08 ` [PATCH 0/2] Fix crash in 'bt' with Ada Tom Tromey
2 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2021-04-01 17:58 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
The Ada value-printing code could crash when printing an array which
had been optimized out.
The crash is difficult to reproduce, but I did manage to write a test
that at least shows that the previous behavior was incorrect -- before
the patch, the array is printed as if it is valid and every value is 0.
gdb/ChangeLog
2021-04-01 Tom Tromey <tromey@adacore.com>
* ada-valprint.c (ada_value_print_array): Handle optimized-out
arrays.
gdb/testsuite/ChangeLog
2021-04-01 Tom Tromey <tromey@adacore.com>
* gdb.dwarf2/arr-stride.exp: Add test.
---
gdb/ChangeLog | 5 ++++
gdb/ada-valprint.c | 5 +++-
gdb/testsuite/ChangeLog | 4 +++
gdb/testsuite/gdb.dwarf2/arr-stride.exp | 33 ++++++++++++++++++++++++-
4 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 0d5b6d73076..61c903bbed5 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -897,7 +897,10 @@ ada_value_print_array (struct value *val, struct ui_file *stream, int recurse,
fprintf_filtered (stream, "(");
print_optional_low_bound (stream, type, options);
- if (TYPE_FIELD_BITSIZE (type, 0) > 0)
+
+ if (value_entirely_optimized_out (val))
+ val_print_optimized_out (val, stream);
+ else if (TYPE_FIELD_BITSIZE (type, 0) > 0)
{
const gdb_byte *valaddr = value_contents_for_printing (val);
int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr;
diff --git a/gdb/testsuite/gdb.dwarf2/arr-stride.exp b/gdb/testsuite/gdb.dwarf2/arr-stride.exp
index bf30f10c5c8..f25518f4558 100644
--- a/gdb/testsuite/gdb.dwarf2/arr-stride.exp
+++ b/gdb/testsuite/gdb.dwarf2/arr-stride.exp
@@ -31,7 +31,7 @@ Dwarf::assemble $asm_file {
{DW_AT_comp_dir /tmp}
} {
declare_labels integer_label array_elt_label array_label \
- big_array_label
+ big_array_label struct_label
integer_label: DW_TAG_base_type {
{DW_AT_byte_size 4 DW_FORM_sdata}
@@ -79,6 +79,34 @@ Dwarf::assemble $asm_file {
{DW_AT_upper_bound 4 DW_FORM_data1}
}
}
+
+ struct_label: DW_TAG_structure_type {
+ {name struct_type}
+ {byte_size 16 DW_FORM_sdata}
+ } {
+ member {
+ {name intfield}
+ {type :$integer_label}
+ {data_member_location 0 DW_FORM_sdata}
+ }
+ member {
+ {name arrayfield}
+ {type :$array_label}
+ {data_member_location 4 DW_FORM_sdata}
+ }
+ }
+
+ DW_TAG_variable {
+ {name the_struct}
+ {external 1 DW_FORM_flag}
+ {location {
+ DW_OP_const1u 1
+ DW_OP_stack_value
+ DW_OP_piece 4
+ DW_OP_piece 12
+ } SPECIAL_expr}
+ {type :$struct_label}
+ }
}
}
}
@@ -95,3 +123,6 @@ gdb_test "ptype pck.table" \
gdb_test "ptype pck.big_table" \
"type = array \\(0 \\.\\. 4\\) of pck\\.item <packed: 8-bit elements>"
+
+gdb_test "print the_struct" \
+ "\\(intfield => 1, arrayfield => \\(0 => <optimized out>\\)\\)"
--
2.26.2
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 0/2] Fix crash in 'bt' with Ada
2021-04-01 17:58 [PATCH 0/2] Fix crash in 'bt' with Ada Tom Tromey
2021-04-01 17:58 ` [PATCH 1/2] Use common_val_print_checked in print_variable_and_value Tom Tromey
2021-04-01 17:58 ` [PATCH 2/2] Avoid crash in Ada value printing with optimized-out array Tom Tromey
@ 2021-04-15 16:08 ` Tom Tromey
2 siblings, 0 replies; 7+ messages in thread
From: Tom Tromey @ 2021-04-15 16:08 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
>>>>> "Tom" == Tom Tromey <tromey@adacore.com> writes:
Tom> GDB was crashing when doing a 'bt' of a complicated Ada program.
Tom> I tracked this down to a combination of two bugs.
I'm going to check these in shortly.
Tom
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] Use common_val_print_checked in print_variable_and_value
2021-04-01 17:58 ` [PATCH 1/2] Use common_val_print_checked in print_variable_and_value Tom Tromey
@ 2021-04-16 10:45 ` Tom de Vries
2021-04-16 20:11 ` Tom Tromey
0 siblings, 1 reply; 7+ messages in thread
From: Tom de Vries @ 2021-04-16 10:45 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
On 4/1/21 7:58 PM, Tom Tromey wrote:
> GDB was crashing in "bt full" for a large Ada program. I tracked this
> down to a combination of bugs.
>
> The first bug, fixed here, is that print_variable_and_value calls
> common_val_print. Normally only the value-printing implementation
> should call this; from the top level, common_val_print_checked is
> preferred, because it correctly handles values that are wholly
> optimized out.
>
> I wasn't able to write a test case for this.
>
Caused:
...
FAIL: gdb.opt/inline-locals.exp: info locals above bar 2
FAIL: gdb.opt/inline-locals.exp: info locals above bar 3
...
filed as https://sourceware.org/bugzilla/show_bug.cgi?id=27742 .
Thanks,
- Tom
> gdb/ChangeLog
> 2021-04-01 Tom Tromey <tromey@adacore.com>
>
> * printcmd.c (print_variable_and_value): Use
> common_val_print_checked.
> ---
> gdb/ChangeLog | 5 +++++
> gdb/printcmd.c | 2 +-
> 2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/printcmd.c b/gdb/printcmd.c
> index c82f709136f..a4f62f207d0 100644
> --- a/gdb/printcmd.c
> +++ b/gdb/printcmd.c
> @@ -2387,7 +2387,7 @@ print_variable_and_value (const char *name, struct symbol *var,
> val = read_var_value (var, NULL, frame);
> get_user_print_options (&opts);
> opts.deref_ref = 1;
> - common_val_print (val, stream, indent, &opts, current_language);
> + common_val_print_checked (val, stream, indent, &opts, current_language);
>
> /* common_val_print invalidates FRAME when a pretty printer calls inferior
> function. */
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] Use common_val_print_checked in print_variable_and_value
2021-04-16 10:45 ` Tom de Vries
@ 2021-04-16 20:11 ` Tom Tromey
2021-04-17 12:38 ` Tom de Vries
0 siblings, 1 reply; 7+ messages in thread
From: Tom Tromey @ 2021-04-16 20:11 UTC (permalink / raw)
To: Tom de Vries; +Cc: Tom Tromey, gdb-patches
Tom> Caused:
Tom> ...
Tom> FAIL: gdb.opt/inline-locals.exp: info locals above bar 2
Tom> FAIL: gdb.opt/inline-locals.exp: info locals above bar 3
Tom> ...
Tom> filed as https://sourceware.org/bugzilla/show_bug.cgi?id=27742 .
I don't have the compiler needed to reproduce.
Could you try the appended?
thanks,
Tom
commit 0d00bb54e39ae86c9344ea3a509720255fb6f147
Author: Tom Tromey <tromey@adacore.com>
Date: Fri Apr 16 14:08:49 2021 -0600
Fix kfail patterns in inline-locals.exp
PR gdb/27742 points out that my recent change to
print_variable_and_value caused a regression in inline-locals.exp. I
can't reproduce this, but I came up with this patch based on the
output shown in the bug.
gdb/testsuite/ChangeLog
2021-04-16 Tom Tromey <tromey@adacore.com>
PR gdb/27742:
* gdb.opt/inline-locals.exp: Update kfail patterns.
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 212f2ae0c5b..2fa302cf338 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2021-04-16 Tom Tromey <tromey@adacore.com>
+
+ PR gdb/27742:
+ * gdb.opt/inline-locals.exp: Update kfail patterns.
+
2021-04-16 Simon Marchi <simon.marchi@efficios.com>
* boards/simavr.exp: Set debug_flags.
diff --git a/gdb/testsuite/gdb.opt/inline-locals.exp b/gdb/testsuite/gdb.opt/inline-locals.exp
index d0acb4ae8b5..ff9dd1b49ed 100644
--- a/gdb/testsuite/gdb.opt/inline-locals.exp
+++ b/gdb/testsuite/gdb.opt/inline-locals.exp
@@ -45,7 +45,7 @@ if { ! $no_frames } {
gdb_test "info frame" ".*inlined into frame.*" "func1 inlined 2"
set pass_re "array = \\{0 <repeats 64 times>\\}"
set kfail_re [multi_line $pass_re \
- "array = {<optimized out> <repeats 64 times>}"]
+ "array = <optimized out>"]
gdb_test_multiple "info locals" "info locals above bar 2" {
-re -wrap $pass_re {
pass $gdb_test_name
@@ -94,7 +94,7 @@ if { ! $no_frames } {
gdb_test "info frame" ".*inlined into frame.*" "func1 inlined 3"
set pass_re "array = {$decimal, \[^\r\n\]*}"
set kfail_re [multi_line $pass_re \
- "array = {<optimized out> <repeats 64 times>}"]
+ "array = <optimized out>"]
gdb_test_multiple "info locals" "info locals above bar 3" {
-re -wrap $pass_re {
pass $gdb_test_name
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/2] Use common_val_print_checked in print_variable_and_value
2021-04-16 20:11 ` Tom Tromey
@ 2021-04-17 12:38 ` Tom de Vries
0 siblings, 0 replies; 7+ messages in thread
From: Tom de Vries @ 2021-04-17 12:38 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 4/16/21 10:11 PM, Tom Tromey wrote:
> Tom> Caused:
> Tom> ...
> Tom> FAIL: gdb.opt/inline-locals.exp: info locals above bar 2
> Tom> FAIL: gdb.opt/inline-locals.exp: info locals above bar 3
> Tom> ...
> Tom> filed as https://sourceware.org/bugzilla/show_bug.cgi?id=27742 .
>
> I don't have the compiler needed to reproduce.
> Could you try the appended?
>
Ack, that fixes it.
Thanks,
- Tom
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-04-17 12:38 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-01 17:58 [PATCH 0/2] Fix crash in 'bt' with Ada Tom Tromey
2021-04-01 17:58 ` [PATCH 1/2] Use common_val_print_checked in print_variable_and_value Tom Tromey
2021-04-16 10:45 ` Tom de Vries
2021-04-16 20:11 ` Tom Tromey
2021-04-17 12:38 ` Tom de Vries
2021-04-01 17:58 ` [PATCH 2/2] Avoid crash in Ada value printing with optimized-out array Tom Tromey
2021-04-15 16:08 ` [PATCH 0/2] Fix crash in 'bt' with Ada Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).