aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli/cli-cmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/cli/cli-cmds.c')
-rw-r--r--gdb/cli/cli-cmds.c47
1 files changed, 39 insertions, 8 deletions
diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c
index 2ec2dd3..e9664c9 100644
--- a/gdb/cli/cli-cmds.c
+++ b/gdb/cli/cli-cmds.c
@@ -38,6 +38,7 @@
#include "disasm.h"
#include "tracepoint.h"
#include "filestuff.h"
+#include "location.h"
#include "ui-out.h"
@@ -782,7 +783,6 @@ edit_command (char *arg, int from_tty)
struct symtabs_and_lines sals;
struct symtab_and_line sal;
struct symbol *sym;
- char *arg1;
char *editor;
char *p;
const char *fn;
@@ -804,21 +804,28 @@ edit_command (char *arg, int from_tty)
}
else
{
- /* Now should only be one argument -- decode it in SAL. */
+ struct cleanup *cleanup;
+ struct event_location *location;
+ char *arg1;
+ /* Now should only be one argument -- decode it in SAL. */
arg1 = arg;
- sals = decode_line_1 (&arg1, DECODE_LINE_LIST_MODE, 0, 0);
+ location = string_to_event_location (&arg1, current_language);
+ cleanup = make_cleanup_delete_event_location (location);
+ sals = decode_line_1 (location, DECODE_LINE_LIST_MODE, 0, 0);
filter_sals (&sals);
if (! sals.nelts)
{
/* C++ */
+ do_cleanups (cleanup);
return;
}
if (sals.nelts > 1)
{
ambiguous_line_spec (&sals);
xfree (sals.sals);
+ do_cleanups (cleanup);
return;
}
@@ -860,6 +867,7 @@ edit_command (char *arg, int from_tty)
if (sal.symtab == 0)
error (_("No line number known for %s."), arg);
+ do_cleanups (cleanup);
}
if ((editor = (char *) getenv ("EDITOR")) == NULL)
@@ -888,6 +896,9 @@ list_command (char *arg, int from_tty)
int dummy_beg = 0;
int linenum_beg = 0;
char *p;
+ struct cleanup *cleanup;
+
+ cleanup = make_cleanup (null_cleanup, NULL);
/* Pull in the current default source line if necessary. */
if (arg == 0 || arg[0] == '+' || arg[0] == '-')
@@ -951,15 +962,24 @@ list_command (char *arg, int from_tty)
dummy_beg = 1;
else
{
- sals = decode_line_1 (&arg1, DECODE_LINE_LIST_MODE, 0, 0);
+ struct event_location *location;
+
+ location = string_to_event_location (&arg1, current_language);
+ make_cleanup_delete_event_location (location);
+ sals = decode_line_1 (location, DECODE_LINE_LIST_MODE, 0, 0);
filter_sals (&sals);
if (!sals.nelts)
- return; /* C++ */
+ {
+ /* C++ */
+ do_cleanups (cleanup);
+ return;
+ }
if (sals.nelts > 1)
{
ambiguous_line_spec (&sals);
xfree (sals.sals);
+ do_cleanups (cleanup);
return;
}
@@ -984,18 +1004,28 @@ list_command (char *arg, int from_tty)
dummy_end = 1;
else
{
+ struct event_location *location;
+
+ location = string_to_event_location (&arg1, current_language);
+ make_cleanup_delete_event_location (location);
if (dummy_beg)
- sals_end = decode_line_1 (&arg1, DECODE_LINE_LIST_MODE, 0, 0);
+ sals_end = decode_line_1 (location,
+ DECODE_LINE_LIST_MODE, 0, 0);
else
- sals_end = decode_line_1 (&arg1, DECODE_LINE_LIST_MODE,
+ sals_end = decode_line_1 (location, DECODE_LINE_LIST_MODE,
sal.symtab, sal.line);
+
filter_sals (&sals_end);
if (sals_end.nelts == 0)
- return;
+ {
+ do_cleanups (cleanup);
+ return;
+ }
if (sals_end.nelts > 1)
{
ambiguous_line_spec (&sals_end);
xfree (sals_end.sals);
+ do_cleanups (cleanup);
return;
}
sal_end = sals_end.sals[0];
@@ -1076,6 +1106,7 @@ list_command (char *arg, int from_tty)
? sal.line + get_lines_to_list ()
: sal_end.line + 1),
0);
+ do_cleanups (cleanup);
}
/* Subroutine of disassemble_command to simplify it.