This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Revert: Code cleanup: Move print_command_1 expr variable scope
- From: Jan Kratochvil <jkratoch at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 27 Mar 2015 19:20:49 -0000
- Subject: [binutils-gdb] Revert: Code cleanup: Move print_command_1 expr variable scope
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=1c4ff0802b0c4c8c820dcec503ffea024ea68f45
commit 1c4ff0802b0c4c8c820dcec503ffea024ea68f45
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date: Fri Mar 27 20:19:37 2015 +0100
Revert: Code cleanup: Move print_command_1 expr variable scope
Simon Marchi:
I think this patch is wrong. Starting with that commit (f30d5c7),
some tests (e.g. mi-break.exp) started to fail for me, because
of gdb segfaulting.
The address of expr is passed to the cleanup. When the cleanup is ran,
expr is no longer in scope, so what is at that address is probably not
safe to use anymore. That's my guess.
gdb/ChangeLog
2015-03-27 Jan Kratochvil <jan.kratochvil@redhat.com>
Revert:
2015-03-26 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup.
* printcmd.c (print_command_1): Move expr variable scope.
Diff:
---
gdb/ChangeLog | 7 +++++++
gdb/printcmd.c | 3 +--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 72940b0..6c6b94e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,10 @@
+2015-03-27 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ Revert:
+ 2015-03-26 Jan Kratochvil <jan.kratochvil@redhat.com>
+ Code cleanup.
+ * printcmd.c (print_command_1): Move expr variable scope.
+
2015-03-27 Joel Brobecker <brobecker@adacore.com>
* dtrace-probe.c (dtrace_process_dof_probe): Initialize expr to NULL.
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index a1451f8..deb501a 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -946,6 +946,7 @@ validate_format (struct format_data fmt, const char *cmdname)
static void
print_command_1 (const char *exp, int voidprint)
{
+ struct expression *expr;
struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
char format = 0;
struct value *val;
@@ -968,8 +969,6 @@ print_command_1 (const char *exp, int voidprint)
if (exp && *exp)
{
- struct expression *expr;
-
expr = parse_expression (exp);
make_cleanup (free_current_contents, &expr);
val = evaluate_expression (expr);