Skip to content

Commit 9d1447e

Browse files
author
Sergio Durigan Junior
committed
Destroy allocated values when exiting GDB
When the user exits GDB, we might still have some allocated values in the chain, which, in specific scenarios, can cause problems when GDB attempts to destroy them in "quit_force". For example, see the bug reported at: https://bugzilla.redhat.com/show_bug.cgi?id=1690120 And the thread starting at: https://sourceware.org/ml/gdb-patches/2019-03/msg00475.html Message-ID: <[email protected]> In order to avoid that, and to be more aware of our allocated resources, this commit implements a new function "finalize_values" and calls it from inside "quit_force". Tested by the BuildBot. 2019-04-01 Sergio Durigan Junior <[email protected]> Pedro Alves <[email protected]> * top.c (quit_force): Call 'finalize_values'. * value.c (finalize_values): New function. * value.h (finalize_values): Declare.
1 parent 34ef62f commit 9d1447e

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

gdb/ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2019-04-01 Sergio Durigan Junior <[email protected]>
2+
Pedro Alves <[email protected]>
3+
4+
* top.c (quit_force): Call 'finalize_values'.
5+
* value.c (finalize_values): New function.
6+
* value.h (finalize_values): Declare.
7+
18
2019-03-30 Eli Zaretskii <[email protected]>
29

310
* NEWS: Announce $_gdb_major and $_gdb_minor.

gdb/top.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,12 @@ quit_force (int *exit_arg, int from_tty)
16731673
}
16741674
END_CATCH
16751675

1676+
/* Destroy any values currently allocated now instead of leaving it
1677+
to global destructors, because that may be too late. For
1678+
example, the destructors of xmethod values call into the Python
1679+
runtime, which is finalized via a final cleanup. */
1680+
finalize_values ();
1681+
16761682
/* Do any final cleanups before exiting. */
16771683
TRY
16781684
{

gdb/value.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4132,3 +4132,11 @@ prevents future values, larger than this size, from being allocated."),
41324132
selftests::test_insert_into_bit_range_vector);
41334133
#endif
41344134
}
4135+
4136+
/* See value.h. */
4137+
4138+
void
4139+
finalize_values ()
4140+
{
4141+
all_values.clear ();
4142+
}

gdb/value.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,4 +1189,8 @@ extern struct value *call_xmethod (struct value *method,
11891189
extern int value_union_variant (struct type *union_type,
11901190
const gdb_byte *contents);
11911191

1192+
/* Destroy the values currently allocated. This is called when GDB is
1193+
exiting (e.g., on quit_force). */
1194+
extern void finalize_values ();
1195+
11921196
#endif /* !defined (VALUE_H) */

0 commit comments

Comments
 (0)