Explicit locations: use new location API

This patch converts the code base to use the new struct event_location
API being introduced. This patch preserves the current functionality and
adds no new features.

The "big picture" API usage introduced by this patch may be illustrated
with a simple exmaple. Where previously developers would write:

void
my_command (char *arg, int from_tty)
{
   create_breakpoint (..., arg, ...);
   ...
}

one now uses:

void
my_command (char *arg, int from_tty)
{
   struct event_locaiton *location;
   struct cleanup *back_to;

   location = string_to_event_locaiton (&arg, ...);
   back_to = make_cleanup_delete_event_location (location);
   create_breakpoint (..., location, ...);
   do_cleanups (back_to);
}

Linespec-decoding functions (now called location-decoding) such as
decode_line_full no longer skip argument pointers over processed input.
That functionality has been moved into string_to_event_location as
demonstrated above.

gdb/ChangeLog

	* ax-gdb.c: Include location.h.
	(agent_command_1) Use linespec location instead of address
	string.
	* break-catch-throw.c: Include location.h.
	(re_set_exception_catchpoint): Use linespec locations instead
	of address strings.
	* breakpoint.c: Include location.h.
	(create_overlay_event_breakpoint, create_longjmp_master_breakpoint)
	(create_std_terminate_master_breakpoint)
	(create_exception_master_breakpoint, update_breakpoints_after_exec):
	Use linespec location instead of address string.
	(print_breakpoint_location):  Use locations and
	event_location_to_string.
	Print extra_string for pending locations for non-MI streams.
	(print_one_breakpoint_location): Use locations and
	event_location_to_string.
	(init_raw_breakpoint_without_location): Initialize b->location.
	(create_thread_event_breakpoint): Use linespec location instead of
	address string.
	(init_breakpoint_sal): Likewise.
	Only save extra_string if it is non-NULL and not the empty string.
	Use event_location_to_string instead of `addr_string'.
	Constify `p' and `endp'.
	Use skip_spaces_const/skip_space_const instead of non-const versions.
	Copy the location into the breakpoint.
	If LOCATION is NULL, save the breakpoint address as a linespec location
	instead of an address string.
	(create_breakpoint_sal): Change `addr_string' parameter to a struct
	event_location. All uses updated.
	(create_breakpoints_sal): Likewise for local variable `addr_string'.
	(parse_breakpoint_sals): Use locations instead of address strings.
	Remove check for empty linespec with conditional.
	Refactor.
	(decode_static_tracepoint_spec): Make argument const and update
	function.
	(create_breakpoint): Change `arg' to a struct event_location and
	rename.
	Remove `copy_arg' and `addr_start'.
	If EXTRA_STRING is empty, set it to NULL.
	Don't populate `canonical' for pending breakpoints.
	Pass `extra_string' to find_condition_and_thread.
	Clear `extra_string' if `rest' was NULL.
	Do not error with "garbage after location" if setting a dprintf
	breakpoint.
	Copy the location into the breakpoint instead of an address string.
	(break_command_1): Use string_to_event_location and pass this to
	create_breakpoint instead of an address string.
	Check against `arg_cp' for a probe linespec.
	(dprintf_command): Use string_to_event_location and pass this to
	create_breakpoint instead of an address string.
	Throw an exception if no format string was specified.
	(print_recreate_ranged_breakpoint): Use event_location_to_string
	instead of address strings.
	(break_range_command, until_break_command)
	(init_ada_exception_breakpoint): Use locations instead
	of address strings.
	(say_where): Print out extra_string for pending locations.
	(base_breakpoint_dtor): Delete `location' and `location_range_end' of
	the breakpoint.
	(base_breakpoint_create_sals_from_location): Use struct event_location
	instead of address string.
	Remove `addr_start' and `copy_arg' parameters.
	(base_breakpoint_decode_location): Use struct event_location instead of
	address string.
	(bkpt_re_set): Use locations instead of address strings.
	Use event_location_empty_p to check for unset location.
	(bkpt_print_recreate): Use event_location_to_string instead of
	an address string.
	Print out extra_string for pending locations.
	(bkpt_create_sals_from_location, bkpt_decode_location)
 	(bkpt_probe_create_sals_from_location): Use struct event_location
	instead of address string.
	(bkpt_probe_decode_location): Use struct event_location instead of
	address string.
	(tracepoint_print_recreate): Use event_location_to_string to
	recreate the tracepoint.
	(tracepoint_create_sals_from_location, tracepoint_decode_location)
	(tracepoint_probe_create_sals_from_location)
	(tracepoint_probe_decode_location): Use struct event_location
	instead of address string.
	(dprintf_print_recreate): Use event_location_to_string to recreate
	the dprintf.
	(dprintf_re_set): Remove check for valid/missing format string.
	(strace_marker_create_sals_from_location)
	(strace_marker_create_breakpoints_sal, strace_marker_decode_location)
	(update_static_tracepoint): Use struct event_location instead of
	address string.
	(location_to_sals): Likewise.
	Pass `extra_string' to find_condition_and_thread.
	For newly resolved pending breakpoint locations, clear the location's
	string representation.
	Assert that the breakpoint's condition string is NULL when
	condition_not_parsed.
	(breakpoint_re_set_default, create_sals_from_location_default)
	(decode_location_default, trace_command, ftrace_command)
	(strace_command, create_tracepoint_from_upload): Use locations
	instead of address strings.
	* breakpoint.h (struct breakpoint_ops) <create_sals_from_location>:
	Use struct event_location instead of address string.
	Update all uses.
	<decode_location>: Likewise.
	(struct breakpoint) <addr_string>: Change to struct event_location
	and rename `location'.
	<addr_string_range_end>: Change to struct event_location and rename
	`location_range_end'.
	(create_breakpoint): Use struct event_location instead of address
	string.
	* cli/cli-cmds.c: Include location.h.
	(edit_command, list_command): Use locations instead of address strings.
	* elfread.c: Include location.h.
	(elf_gnu_ifunc_resolver_return_stop): Use event_location_to_string.
	* guile/scm-breakpoint.c: Include location.h.
	(bpscm_print_breakpoint_smob): Use event_location_to_string.
	(gdbscm_register_breakpoint): Use locations instead of address
	strings.
	* linespec.c: Include location.h.
	(struct ls_parser) <stream>: Change to const char *.
	(PARSER_STREAM): Update.
	(lionespec_lexer_lex_keyword): According to find_condition_and_thread,
	keywords must be followed by whitespace.
	(canonicalize_linespec): Save a linespec location into `canonical'.
	Save a canonical linespec into `canonical'.
	(parse_linespec): Change `argptr' to const char * and rename `arg'.
	All uses updated.
	Update function description.
	(linespec_parser_new): Initialize `parser'.
	Update initialization of  parsing stream.
	(event_location_to_sals): New function.
	(decode_line_full): Change `argptr' to a struct event_location and
	rename it `location'.
	Use locations instead of address strings.
	Call event_location_to_sals instead of parse_linespec.
	(decode_line_1): Likewise.
	(decode_line_with_current_source, decode_line_with_last_displayed)
	Use locations instead of address strings.
	(decode_objc): Likewise.
	Change `argptr' to const char * and rename `arg'.
	(destroy_linespec_result): Delete the linespec result's location
	instead of freeing the address string.
	* linespec.h (struct linespec_result) <addr_string>: Change to
	struct event_location and rename to ...
	<location>: ... this.
	(decode_line_1, decode_line_full): Change `argptr' to struct
	event_location.  All callers updated.
	* mi/mi-cmd-break.c: Include language.h, location.h, and linespec.h.
	(mi_cmd_break_insert_1): Use locations instead of address strings.
	Throw an error if there was "garbage" at the end of the specified
	linespec.
	* probe.c: Include location.h.
	(parse_probes): Change `argptr' to struct event_location.
	Use event locations instead of address strings.
	* probe.h (parse_probes): Change `argptr' to struct event_location.
	* python/py-breakpoint.c: Include location.h.
	(bppy_get_location): Constify local variable `str'.
	Use event_location_to_string.
	(bppy_init): Use locations instead of address strings.
	* python/py-finishbreakpoint.c: Include location.h.
	(bpfinishpy_init): Remove local variable `addr_str'.
	Use locations instead of address strings.
	* python/python.c: Include location.h.
	(gdbpy_decode_line): Use locations instead of address strings.
	* remote.c: Include location.h.
	(remote_download_tracepoint): Use locations instead of address
	strings.
	* spu-tdep.c: Include location.h.
	(spu_catch_start): Remove local variable `buf'.
	Use locations instead of address strings.
	* tracepoint.c: Include location.h.
	(scope_info): Use locations instead of address strings.
	(encode_source_string): Constify parameter `src'.
	* tracepoint.h (encode_source_string): Likewise.

gdb/testsuite/ChangeLog

	* gdb.base/dprintf-pending.exp: Update dprintf "without format"
	test.
	Add tests for missing ",FMT" and ",".
This commit is contained in:
Keith Seitz 2015-08-11 17:09:35 -07:00
parent c7c1b3e998
commit f00aae0f7b
22 changed files with 890 additions and 404 deletions

View File

@ -1,3 +1,177 @@
2015-08-11 Keith Seitz <keiths@redhat.com>
* ax-gdb.c: Include location.h.
(agent_command_1) Use linespec location instead of address
string.
* break-catch-throw.c: Include location.h.
(re_set_exception_catchpoint): Use linespec locations instead
of address strings.
* breakpoint.c: Include location.h.
(create_overlay_event_breakpoint, create_longjmp_master_breakpoint)
(create_std_terminate_master_breakpoint)
(create_exception_master_breakpoint, update_breakpoints_after_exec):
Use linespec location instead of address string.
(print_breakpoint_location): Use locations and
event_location_to_string.
Print extra_string for pending locations for non-MI streams.
(print_one_breakpoint_location): Use locations and
event_location_to_string.
(init_raw_breakpoint_without_location): Initialize b->location.
(create_thread_event_breakpoint): Use linespec location instead of
address string.
(init_breakpoint_sal): Likewise.
Only save extra_string if it is non-NULL and not the empty string.
Use event_location_to_string instead of `addr_string'.
Constify `p' and `endp'.
Use skip_spaces_const/skip_space_const instead of non-const versions.
Copy the location into the breakpoint.
If LOCATION is NULL, save the breakpoint address as a linespec location
instead of an address string.
(create_breakpoint_sal): Change `addr_string' parameter to a struct
event_location. All uses updated.
(create_breakpoints_sal): Likewise for local variable `addr_string'.
(parse_breakpoint_sals): Use locations instead of address strings.
Remove check for empty linespec with conditional.
Refactor.
(decode_static_tracepoint_spec): Make argument const and update
function.
(create_breakpoint): Change `arg' to a struct event_location and
rename.
Remove `copy_arg' and `addr_start'.
If EXTRA_STRING is empty, set it to NULL.
Don't populate `canonical' for pending breakpoints.
Pass `extra_string' to find_condition_and_thread.
Clear `extra_string' if `rest' was NULL.
Do not error with "garbage after location" if setting a dprintf
breakpoint.
Copy the location into the breakpoint instead of an address string.
(break_command_1): Use string_to_event_location and pass this to
create_breakpoint instead of an address string.
Check against `arg_cp' for a probe linespec.
(dprintf_command): Use string_to_event_location and pass this to
create_breakpoint instead of an address string.
Throw an exception if no format string was specified.
(print_recreate_ranged_breakpoint): Use event_location_to_string
instead of address strings.
(break_range_command, until_break_command)
(init_ada_exception_breakpoint): Use locations instead
of address strings.
(say_where): Print out extra_string for pending locations.
(base_breakpoint_dtor): Delete `location' and `location_range_end' of
the breakpoint.
(base_breakpoint_create_sals_from_location): Use struct event_location
instead of address string.
Remove `addr_start' and `copy_arg' parameters.
(base_breakpoint_decode_location): Use struct event_location instead of
address string.
(bkpt_re_set): Use locations instead of address strings.
Use event_location_empty_p to check for unset location.
(bkpt_print_recreate): Use event_location_to_string instead of
an address string.
Print out extra_string for pending locations.
(bkpt_create_sals_from_location, bkpt_decode_location)
(bkpt_probe_create_sals_from_location): Use struct event_location
instead of address string.
(bkpt_probe_decode_location): Use struct event_location instead of
address string.
(tracepoint_print_recreate): Use event_location_to_string to
recreate the tracepoint.
(tracepoint_create_sals_from_location, tracepoint_decode_location)
(tracepoint_probe_create_sals_from_location)
(tracepoint_probe_decode_location): Use struct event_location
instead of address string.
(dprintf_print_recreate): Use event_location_to_string to recreate
the dprintf.
(dprintf_re_set): Remove check for valid/missing format string.
(strace_marker_create_sals_from_location)
(strace_marker_create_breakpoints_sal, strace_marker_decode_location)
(update_static_tracepoint): Use struct event_location instead of
address string.
(location_to_sals): Likewise.
Pass `extra_string' to find_condition_and_thread.
For newly resolved pending breakpoint locations, clear the location's
string representation.
Assert that the breakpoint's condition string is NULL when
condition_not_parsed.
(breakpoint_re_set_default, create_sals_from_location_default)
(decode_location_default, trace_command, ftrace_command)
(strace_command, create_tracepoint_from_upload): Use locations
instead of address strings.
* breakpoint.h (struct breakpoint_ops) <create_sals_from_location>:
Use struct event_location instead of address string.
Update all uses.
<decode_location>: Likewise.
(struct breakpoint) <addr_string>: Change to struct event_location
and rename `location'.
<addr_string_range_end>: Change to struct event_location and rename
`location_range_end'.
(create_breakpoint): Use struct event_location instead of address
string.
* cli/cli-cmds.c: Include location.h.
(edit_command, list_command): Use locations instead of address strings.
* elfread.c: Include location.h.
(elf_gnu_ifunc_resolver_return_stop): Use event_location_to_string.
* guile/scm-breakpoint.c: Include location.h.
(bpscm_print_breakpoint_smob): Use event_location_to_string.
(gdbscm_register_breakpoint): Use locations instead of address
strings.
* linespec.c: Include location.h.
(struct ls_parser) <stream>: Change to const char *.
(PARSER_STREAM): Update.
(lionespec_lexer_lex_keyword): According to find_condition_and_thread,
keywords must be followed by whitespace.
(canonicalize_linespec): Save a linespec location into `canonical'.
Save a canonical linespec into `canonical'.
(parse_linespec): Change `argptr' to const char * and rename `arg'.
All uses updated.
Update function description.
(linespec_parser_new): Initialize `parser'.
Update initialization of parsing stream.
(event_location_to_sals): New function.
(decode_line_full): Change `argptr' to a struct event_location and
rename it `location'.
Use locations instead of address strings.
Call event_location_to_sals instead of parse_linespec.
(decode_line_1): Likewise.
(decode_line_with_current_source, decode_line_with_last_displayed)
Use locations instead of address strings.
(decode_objc): Likewise.
Change `argptr' to const char * and rename `arg'.
(destroy_linespec_result): Delete the linespec result's location
instead of freeing the address string.
* linespec.h (struct linespec_result) <addr_string>: Change to
struct event_location and rename to ...
<location>: ... this.
(decode_line_1, decode_line_full): Change `argptr' to struct
event_location. All callers updated.
* mi/mi-cmd-break.c: Include language.h, location.h, and linespec.h.
(mi_cmd_break_insert_1): Use locations instead of address strings.
Throw an error if there was "garbage" at the end of the specified
linespec.
* probe.c: Include location.h.
(parse_probes): Change `argptr' to struct event_location.
Use event locations instead of address strings.
* probe.h (parse_probes): Change `argptr' to struct event_location.
* python/py-breakpoint.c: Include location.h.
(bppy_get_location): Constify local variable `str'.
Use event_location_to_string.
(bppy_init): Use locations instead of address strings.
* python/py-finishbreakpoint.c: Include location.h.
(bpfinishpy_init): Remove local variable `addr_str'.
Use locations instead of address strings.
* python/python.c: Include location.h.
(gdbpy_decode_line): Use locations instead of address strings.
* remote.c: Include location.h.
(remote_download_tracepoint): Use locations instead of address
strings.
* spu-tdep.c: Include location.h.
(spu_catch_start): Remove local variable `buf'.
Use locations instead of address strings.
* tracepoint.c: Include location.h.
(scope_info): Use locations instead of address strings.
(encode_source_string): Constify parameter `src'.
* tracepoint.h (encode_source_string): Likewise.
2015-08-11 Keith Seitz <keiths@redhat.com>
* Makefile.in (SFILES): Add location.c.

View File

@ -40,6 +40,7 @@
#include "arch-utils.h"
#include "cli/cli-utils.h"
#include "linespec.h"
#include "location.h"
#include "objfiles.h"
#include "valprint.h"
@ -2642,13 +2643,16 @@ agent_command_1 (char *exp, int eval)
int ix;
struct linespec_sals *iter;
struct cleanup *old_chain;
struct event_location *location;
exp = skip_spaces (exp);
init_linespec_result (&canonical);
decode_line_full (&exp, DECODE_LINE_FUNFIRSTLINE,
location = new_linespec_location (&exp);
old_chain = make_cleanup_delete_event_location (location);
decode_line_full (location, DECODE_LINE_FUNFIRSTLINE,
(struct symtab *) NULL, 0, &canonical,
NULL, NULL);
old_chain = make_cleanup_destroy_linespec_result (&canonical);
make_cleanup_destroy_linespec_result (&canonical);
exp = skip_spaces (exp);
if (exp[0] == ',')
{

View File

@ -35,6 +35,7 @@
#include "cp-abi.h"
#include "gdb_regex.h"
#include "cp-support.h"
#include "location.h"
/* Enums for exception-handling support. */
enum exception_event_kind
@ -210,25 +211,31 @@ re_set_exception_catchpoint (struct breakpoint *self)
struct symtabs_and_lines sals_end = {0};
struct cleanup *cleanup;
enum exception_event_kind kind = classify_exception_breakpoint (self);
struct event_location *location;
/* We first try to use the probe interface. */
TRY
{
char *spec = ASTRDUP (exception_functions[kind].probe);
sals = parse_probes (&spec, NULL);
location = new_linespec_location (&spec);
cleanup = make_cleanup_delete_event_location (location);
sals = parse_probes (location, NULL);
do_cleanups (cleanup);
}
CATCH (e, RETURN_MASK_ERROR)
{
/* Using the probe interface failed. Let's fallback to the normal
catchpoint mode. */
TRY
{
char *spec = ASTRDUP (exception_functions[kind].function);
self->ops->decode_location (self, &spec, &sals);
location = new_linespec_location (&spec);
cleanup = make_cleanup_delete_event_location (location);
self->ops->decode_location (self, location, &sals);
do_cleanups (cleanup);
}
CATCH (ex, RETURN_MASK_ERROR)
{

File diff suppressed because it is too large Load Diff

View File

@ -37,6 +37,7 @@ struct bpstats;
struct bp_location;
struct linespec_result;
struct linespec_sals;
struct event_location;
/* This is the maximum number of bytes a breakpoint instruction can
take. Feel free to increase it. It's just used in a few places to
@ -580,8 +581,9 @@ struct breakpoint_ops
`create_sals_from_location_default'.
This function is called inside `create_breakpoint'. */
void (*create_sals_from_location) (char **, struct linespec_result *,
enum bptype, char *, char **);
void (*create_sals_from_location) (const struct event_location *location,
struct linespec_result *canonical,
enum bptype type_wanted);
/* This method will be responsible for creating a breakpoint given its SALs.
Usually, it just calls `create_breakpoints_sal' (for ordinary
@ -602,8 +604,9 @@ struct breakpoint_ops
it calls `decode_line_full'.
This function is called inside `location_to_sals'. */
void (*decode_location) (struct breakpoint *, char **,
struct symtabs_and_lines *);
void (*decode_location) (struct breakpoint *b,
const struct event_location *location,
struct symtabs_and_lines *sals);
/* Return true if this breakpoint explains a signal. See
bpstat_explains_signal. */
@ -702,17 +705,17 @@ struct breakpoint
non-thread-specific ordinary breakpoints this is NULL. */
struct program_space *pspace;
/* String we used to set the breakpoint (malloc'd). */
char *addr_string;
/* Location we used to set the breakpoint (malloc'd). */
struct event_location *location;
/* The filter that should be passed to decode_line_full when
re-setting this breakpoint. This may be NULL, but otherwise is
allocated with xmalloc. */
char *filter;
/* For a ranged breakpoint, the string we used to find
/* For a ranged breakpoint, the location we used to find
the end of the range (malloc'd). */
char *addr_string_range_end;
struct event_location *location_range_end;
/* Architecture we used to set the breakpoint. */
struct gdbarch *gdbarch;
@ -1293,10 +1296,30 @@ enum breakpoint_create_flags
CREATE_BREAKPOINT_FLAGS_INSERTED = 1 << 0
};
extern int create_breakpoint (struct gdbarch *gdbarch, char *arg,
/* Set a breakpoint. This function is shared between CLI and MI functions
for setting a breakpoint at LOCATION.
This function has two major modes of operations, selected by the
PARSE_EXTRA parameter.
If PARSE_EXTRA is zero, LOCATION is just the breakpoint's location,
with condition, thread, and extra string specified by the COND_STRING,
THREAD, and EXTRA_STRING parameters.
If PARSE_EXTRA is non-zero, this function will attempt to extract
the condition, thread, and extra string from EXTRA_STRING, ignoring
the similarly named parameters.
If INTERNAL is non-zero, the breakpoint number will be allocated
from the internal breakpoint count.
Returns true if any breakpoint was created; false otherwise. */
extern int create_breakpoint (struct gdbarch *gdbarch,
const struct event_location *location,
char *cond_string, int thread,
char *extra_string,
int parse_arg,
int parse_extra,
int tempflag, enum bptype wanted_type,
int ignore_count,
enum auto_boolean pending_break_support,

View File

@ -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.

View File

@ -45,6 +45,7 @@
#include "bcache.h"
#include "gdb_bfd.h"
#include "build-id.h"
#include "location.h"
extern void _initialize_elfread (void);
@ -989,7 +990,8 @@ elf_gnu_ifunc_resolver_return_stop (struct breakpoint *b)
resolved_pc = gdbarch_addr_bits_remove (gdbarch, resolved_pc);
gdb_assert (current_program_space == b->pspace || b->pspace == NULL);
elf_gnu_ifunc_record_cache (b->addr_string, resolved_pc);
elf_gnu_ifunc_record_cache (event_location_to_string (b->location),
resolved_pc);
sal = find_pc_line (resolved_pc, 0);
sals.nelts = 1;

View File

@ -31,6 +31,7 @@
#include "arch-utils.h"
#include "language.h"
#include "guile-internal.h"
#include "location.h"
/* The <gdb:breakpoint> smob.
N.B.: The name of this struct is known to breakpoint.h.
@ -173,6 +174,8 @@ bpscm_print_breakpoint_smob (SCM self, SCM port, scm_print_state *pstate)
/* Careful, the breakpoint may be invalid. */
if (b != NULL)
{
const char *str;
gdbscm_printf (port, " %s %s %s",
bpscm_type_to_string (b->type),
bpscm_enable_state_to_string (b->enable_state),
@ -181,8 +184,9 @@ bpscm_print_breakpoint_smob (SCM self, SCM port, scm_print_state *pstate)
gdbscm_printf (port, " hit:%d", b->hit_count);
gdbscm_printf (port, " ignore:%d", b->ignore_count);
if (b->addr_string != NULL)
gdbscm_printf (port, " @%s", b->addr_string);
str = event_location_to_string (b->location);
if (str != NULL)
gdbscm_printf (port, " @%s", str);
}
scm_puts (">", port);
@ -408,6 +412,9 @@ gdbscm_register_breakpoint_x (SCM self)
breakpoint_smob *bp_smob
= bpscm_get_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
struct gdb_exception except = exception_none;
char *location, *copy;
struct event_location *eloc;
struct cleanup *cleanup;
/* We only support registering breakpoints created with make-breakpoint. */
if (!bp_smob->is_scheme_bkpt)
@ -417,10 +424,13 @@ gdbscm_register_breakpoint_x (SCM self)
scm_misc_error (FUNC_NAME, _("breakpoint is already registered"), SCM_EOL);
pending_breakpoint_scm = self;
location = bp_smob->spec.location;
copy = location;
eloc = new_linespec_location (&copy);
cleanup = make_cleanup_delete_event_location (eloc);
TRY
{
char *location = bp_smob->spec.location;
int internal = bp_smob->spec.is_internal;
switch (bp_smob->spec.type)
@ -428,7 +438,7 @@ gdbscm_register_breakpoint_x (SCM self)
case bp_breakpoint:
{
create_breakpoint (get_current_arch (),
location, NULL, -1, NULL,
eloc, NULL, -1, NULL,
0,
0, bp_breakpoint,
0,
@ -464,6 +474,7 @@ gdbscm_register_breakpoint_x (SCM self)
/* Ensure this gets reset, even if there's an error. */
pending_breakpoint_scm = SCM_BOOL_F;
GDBSCM_HANDLE_GDB_EXCEPTION (except);
do_cleanups (cleanup);
return SCM_UNSPECIFIED;
}
@ -819,12 +830,12 @@ gdbscm_breakpoint_location (SCM self)
{
breakpoint_smob *bp_smob
= bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
char *str;
const char *str;
if (bp_smob->bp->type != bp_breakpoint)
return SCM_BOOL_F;
str = bp_smob->bp->addr_string;
str = event_location_to_string (bp_smob->bp->location);
if (! str)
str = "";

View File

@ -43,6 +43,7 @@
#include "filenames.h"
#include "ada-lang.h"
#include "stack.h"
#include "location.h"
typedef struct symbol *symbolp;
DEF_VEC_P (symbolp);
@ -281,8 +282,8 @@ struct ls_parser
const char *saved_arg;
/* Head of the input stream. */
const char **stream;
#define PARSER_STREAM(P) (*(P)->lexer.stream)
const char *stream;
#define PARSER_STREAM(P) ((P)->lexer.stream)
/* The current token. */
linespec_token current;
@ -315,7 +316,7 @@ static CORE_ADDR linespec_expression_to_pc (const char **exp_ptr);
static struct symtabs_and_lines decode_objc (struct linespec_state *self,
linespec_p ls,
const char **argptr);
const char *arg);
static VEC (symtab_ptr) *symtabs_from_filename (const char *);
@ -1785,21 +1786,29 @@ linespec_parse_basic (linespec_parser *parser)
STATE->canonical. */
static void
canonicalize_linespec (struct linespec_state *state, linespec_p ls)
canonicalize_linespec (struct linespec_state *state, const linespec_p ls)
{
char *tmp;
/* If canonicalization was not requested, no need to do anything. */
if (!state->canonical)
return;
/* Shortcut expressions, which can only appear by themselves. */
if (ls->expression != NULL)
state->canonical->addr_string = xstrdup (ls->expression);
{
tmp = ASTRDUP (ls->expression);
state->canonical->location = new_linespec_location (&tmp);
}
else
{
struct ui_file *buf;
int need_colon = 0;
struct cleanup *cleanup;
buf = mem_fileopen ();
cleanup = make_cleanup_ui_file_delete (buf);
if (ls->source_filename)
{
fputs_unfiltered (ls->source_filename, buf);
@ -1848,8 +1857,10 @@ canonicalize_linespec (struct linespec_state *state, linespec_p ls)
ls->line_offset.offset);
}
state->canonical->addr_string = ui_file_xstrdup (buf, NULL);
ui_file_delete (buf);
tmp = ui_file_xstrdup (buf, NULL);
make_cleanup (xfree, tmp);
state->canonical->location = new_linespec_location (&tmp);
do_cleanups (cleanup);
}
}
@ -2117,8 +2128,6 @@ convert_linespec_to_sals (struct linespec_state *state, linespec_p ls)
}
/* Parse a string that specifies a linespec.
Pass the address of a char * variable; that variable will be
advanced over the characters actually parsed.
The basic grammar of linespecs:
@ -2167,10 +2176,10 @@ convert_linespec_to_sals (struct linespec_state *state, linespec_p ls)
if no file is validly specified. Callers must check that.
Also, the line number returned may be invalid. */
/* Parse the linespec in ARGPTR. */
/* Parse the linespec in ARG. */
static struct symtabs_and_lines
parse_linespec (linespec_parser *parser, const char **argptr)
parse_linespec (linespec_parser *parser, const char *arg)
{
linespec_token token;
struct symtabs_and_lines values;
@ -2181,30 +2190,30 @@ parse_linespec (linespec_parser *parser, const char **argptr)
IDEs to work around bugs in the previous parser by quoting
the entire linespec, so we attempt to deal with this nicely. */
parser->is_quote_enclosed = 0;
if (!is_ada_operator (*argptr)
&& strchr (linespec_quote_characters, **argptr) != NULL)
if (!is_ada_operator (arg)
&& strchr (linespec_quote_characters, *arg) != NULL)
{
const char *end;
end = skip_quote_char (*argptr + 1, **argptr);
end = skip_quote_char (arg + 1, *arg);
if (end != NULL && is_closing_quote_enclosed (end))
{
/* Here's the special case. Skip ARGPTR past the initial
/* Here's the special case. Skip ARG past the initial
quote. */
++(*argptr);
++arg;
parser->is_quote_enclosed = 1;
}
}
parser->lexer.saved_arg = *argptr;
parser->lexer.stream = argptr;
parser->lexer.saved_arg = arg;
parser->lexer.stream = arg;
/* Initialize the default symtab and line offset. */
initialize_defaults (&PARSER_STATE (parser)->default_symtab,
&PARSER_STATE (parser)->default_line);
/* Objective-C shortcut. */
values = decode_objc (PARSER_STATE (parser), PARSER_RESULT (parser), argptr);
values = decode_objc (PARSER_STATE (parser), PARSER_RESULT (parser), arg);
if (values.sals != NULL)
return values;
@ -2390,6 +2399,7 @@ linespec_parser_new (linespec_parser *parser,
int default_line,
struct linespec_result *canonical)
{
memset (parser, 0, sizeof (linespec_parser));
parser->lexer.current.type = LSTOKEN_CONSUMED;
memset (PARSER_RESULT (parser), 0, sizeof (struct linespec));
PARSER_RESULT (parser)->line_offset.sign = LINE_OFFSET_UNKNOWN;
@ -2443,7 +2453,6 @@ linespec_lex_to_end (char **stringp)
linespec_parser parser;
struct cleanup *cleanup;
linespec_token token;
volatile struct gdb_exception e;
const char *orig;
if (stringp == NULL || *stringp == NULL)
@ -2483,10 +2492,42 @@ linespec_lex_to_end (char **stringp)
do_cleanups (cleanup);
}
/* A helper function for decode_line_full and decode_line_1 to
turn LOCATION into symtabs_and_lines. */
static struct symtabs_and_lines
event_location_to_sals (linespec_parser *parser,
const struct event_location *location)
{
struct symtabs_and_lines result = {NULL, 0};
switch (event_location_type (location))
{
case LINESPEC_LOCATION:
{
TRY
{
result = parse_linespec (parser, get_linespec_location (location));
}
CATCH (except, RETURN_MASK_ERROR)
{
throw_exception (except);
}
END_CATCH
}
break;
default:
gdb_assert_not_reached ("unhandled event location type");
}
return result;
}
/* See linespec.h. */
void
decode_line_full (char **argptr, int flags,
decode_line_full (const struct event_location *location, int flags,
struct symtab *default_symtab,
int default_line, struct linespec_result *canonical,
const char *select_mode,
@ -2497,7 +2538,6 @@ decode_line_full (char **argptr, int flags,
VEC (const_char_ptr) *filters = NULL;
linespec_parser parser;
struct linespec_state *state;
const char *copy, *orig;
gdb_assert (canonical != NULL);
/* The filter only makes sense for 'all'. */
@ -2513,13 +2553,10 @@ decode_line_full (char **argptr, int flags,
cleanups = make_cleanup (linespec_parser_delete, &parser);
save_current_program_space ();
orig = copy = *argptr;
result = parse_linespec (&parser, &copy);
*argptr += copy - orig;
result = event_location_to_sals (&parser, location);
state = PARSER_STATE (&parser);
gdb_assert (result.nelts == 1 || canonical->pre_expanded);
gdb_assert (canonical->addr_string != NULL);
canonical->pre_expanded = 1;
/* Arrange for allocated canonical names to be freed. */
@ -2563,23 +2600,20 @@ decode_line_full (char **argptr, int flags,
/* See linespec.h. */
struct symtabs_and_lines
decode_line_1 (char **argptr, int flags,
decode_line_1 (const struct event_location *location, int flags,
struct symtab *default_symtab,
int default_line)
{
struct symtabs_and_lines result;
linespec_parser parser;
struct cleanup *cleanups;
const char *copy, *orig;
linespec_parser_new (&parser, flags, current_language, default_symtab,
default_line, NULL);
cleanups = make_cleanup (linespec_parser_delete, &parser);
save_current_program_space ();
orig = copy = *argptr;
result = parse_linespec (&parser, &copy);
*argptr += copy - orig;
result = event_location_to_sals (&parser, location);
do_cleanups (cleanups);
return result;
@ -2592,6 +2626,8 @@ decode_line_with_current_source (char *string, int flags)
{
struct symtabs_and_lines sals;
struct symtab_and_line cursal;
struct event_location *location;
struct cleanup *cleanup;
if (string == 0)
error (_("Empty line specification."));
@ -2600,11 +2636,15 @@ decode_line_with_current_source (char *string, int flags)
and get a default source symtab+line or it will recursively call us! */
cursal = get_current_source_symtab_and_line ();
sals = decode_line_1 (&string, flags,
location = string_to_event_location (&string, current_language);
cleanup = make_cleanup_delete_event_location (location);
sals = decode_line_1 (location, flags,
cursal.symtab, cursal.line);
if (*string)
error (_("Junk at end of line specification: %s"), string);
do_cleanups (cleanup);
return sals;
}
@ -2614,19 +2654,25 @@ struct symtabs_and_lines
decode_line_with_last_displayed (char *string, int flags)
{
struct symtabs_and_lines sals;
struct event_location *location;
struct cleanup *cleanup;
if (string == 0)
error (_("Empty line specification."));
location = string_to_event_location (&string, current_language);
cleanup = make_cleanup_delete_event_location (location);
if (last_displayed_sal_is_valid ())
sals = decode_line_1 (&string, flags,
sals = decode_line_1 (location, flags,
get_last_displayed_symtab (),
get_last_displayed_line ());
else
sals = decode_line_1 (&string, flags, (struct symtab *) NULL, 0);
sals = decode_line_1 (location, flags, (struct symtab *) NULL, 0);
if (*string)
error (_("Junk at end of line specification: %s"), string);
do_cleanups (cleanup);
return sals;
}
@ -2679,7 +2725,7 @@ linespec_expression_to_pc (const char **exp_ptr)
the existing C++ code to let the user choose one. */
static struct symtabs_and_lines
decode_objc (struct linespec_state *self, linespec_p ls, const char **argptr)
decode_objc (struct linespec_state *self, linespec_p ls, const char *arg)
{
struct collect_info info;
VEC (const_char_ptr) *symbol_names = NULL;
@ -2697,7 +2743,7 @@ decode_objc (struct linespec_state *self, linespec_p ls, const char **argptr)
values.nelts = 0;
values.sals = NULL;
new_argptr = find_imps (*argptr, &symbol_names);
new_argptr = find_imps (arg, &symbol_names);
if (VEC_empty (const_char_ptr, symbol_names))
{
do_cleanups (cleanup);
@ -2711,9 +2757,9 @@ decode_objc (struct linespec_state *self, linespec_p ls, const char **argptr)
{
char *saved_arg;
saved_arg = alloca (new_argptr - *argptr + 1);
memcpy (saved_arg, *argptr, new_argptr - *argptr);
saved_arg[new_argptr - *argptr] = '\0';
saved_arg = alloca (new_argptr - arg + 1);
memcpy (saved_arg, arg, new_argptr - arg);
saved_arg[new_argptr - arg] = '\0';
ls->function_name = xstrdup (saved_arg);
ls->function_symbols = info.result.symbols;
@ -2722,17 +2768,23 @@ decode_objc (struct linespec_state *self, linespec_p ls, const char **argptr)
if (self->canonical)
{
char *str;
self->canonical->pre_expanded = 1;
if (ls->source_filename)
self->canonical->addr_string
= xstrprintf ("%s:%s", ls->source_filename, saved_arg);
{
str = xstrprintf ("%s:%s",
ls->source_filename, saved_arg);
}
else
self->canonical->addr_string = xstrdup (saved_arg);
str = xstrdup (saved_arg);
make_cleanup (xfree, str);
self->canonical->location = new_linespec_location (&str);
}
}
*argptr = new_argptr;
do_cleanups (cleanup);
return values;
@ -3830,7 +3882,7 @@ destroy_linespec_result (struct linespec_result *ls)
int i;
struct linespec_sals *lsal;
xfree (ls->addr_string);
delete_event_location (ls->location);
for (i = 0; VEC_iterate (linespec_sals, ls->sals, i, lsal); ++i)
{
xfree (lsal->canonical);

View File

@ -39,7 +39,7 @@ enum decode_line_flags
struct linespec_sals
{
/* This is the linespec corresponding to the sals contained in this
/* This is the location corresponding to the sals contained in this
object. It can be passed as the FILTER argument to future calls
to decode_line_full. This is freed by
destroy_linespec_result. */
@ -71,9 +71,9 @@ struct linespec_result
object. */
int pre_expanded;
/* If PRE_EXPANDED is non-zero, this is set to the linespec entered
/* If PRE_EXPANDED is non-zero, this is set to the location entered
by the user. This will be freed by destroy_linespec_result. */
char *addr_string;
struct event_location *location;
/* The sals. The vector will be freed by
destroy_linespec_result. */
@ -96,10 +96,10 @@ extern struct cleanup *
/* Decode a linespec using the provided default symtab and line. */
extern struct symtabs_and_lines
decode_line_1 (char **argptr, int flags,
decode_line_1 (const struct event_location *location, int flags,
struct symtab *default_symtab, int default_line);
/* Parse *ARGPTR as a linespec and return results. This is the "full"
/* Parse LOCATION and return results. This is the "full"
interface to this module, which handles multiple results
properly.
@ -135,7 +135,7 @@ extern struct symtabs_and_lines
strcmp sense) to FILTER will be returned; all others will be
filtered out. */
extern void decode_line_full (char **argptr, int flags,
extern void decode_line_full (const struct event_location *location, int flags,
struct symtab *default_symtab, int default_line,
struct linespec_result *canonical,
const char *select_mode,

View File

@ -28,6 +28,9 @@
#include "observer.h"
#include "mi-main.h"
#include "mi-cmd-break.h"
#include "language.h"
#include "location.h"
#include "linespec.h"
#include "gdb_obstack.h"
#include <ctype.h>
@ -177,6 +180,7 @@ mi_cmd_break_insert_1 (int dprintf, char *command, char **argv, int argc)
int tracepoint = 0;
struct cleanup *back_to = make_cleanup (null_cleanup, NULL);
enum bptype type_wanted;
struct event_location *location;
struct breakpoint_ops *ops;
char *extra_string = NULL;
@ -287,7 +291,13 @@ mi_cmd_break_insert_1 (int dprintf, char *command, char **argv, int argc)
ops = &bkpt_breakpoint_ops;
}
create_breakpoint (get_current_arch (), address, condition, thread,
location = string_to_event_location (&address, current_language);
make_cleanup_delete_event_location (location);
if (*address)
error (_("Garbage '%s' at end of location"), address);
create_breakpoint (get_current_arch (), location, condition, thread,
extra_string,
0 /* condition and thread are valid. */,
temp_p, type_wanted,

View File

@ -33,6 +33,7 @@
#include "value.h"
#include "ax.h"
#include "ax-gdb.h"
#include "location.h"
#include <ctype.h>
typedef struct bound_probe bound_probe_s;
@ -43,23 +44,24 @@ DEF_VEC_O (bound_probe_s);
/* See definition in probe.h. */
struct symtabs_and_lines
parse_probes (char **argptr, struct linespec_result *canonical)
parse_probes (const struct event_location *location,
struct linespec_result *canonical)
{
char *arg_start, *arg_end, *arg;
char *arg_end, *arg;
char *objfile_namestr = NULL, *provider = NULL, *name, *p;
struct cleanup *cleanup;
struct symtabs_and_lines result;
struct objfile *objfile;
struct program_space *pspace;
const struct probe_ops *probe_ops;
const char *cs;
const char *arg_start, *cs;
result.sals = NULL;
result.nelts = 0;
arg_start = *argptr;
arg_start = get_linespec_location (location);
cs = *argptr;
cs = arg_start;
probe_ops = probe_linespec_to_ops (&cs);
if (probe_ops == NULL)
error (_("'%s' is not a probe linespec"), arg_start);
@ -170,12 +172,15 @@ parse_probes (char **argptr, struct linespec_result *canonical)
if (canonical)
{
char *canon;
canon = savestring (arg_start, arg_end - arg_start);
make_cleanup (xfree, canon);
canonical->special_display = 1;
canonical->pre_expanded = 1;
canonical->addr_string = savestring (*argptr, arg_end - *argptr);
canonical->location = new_linespec_location (&canon);
}
*argptr = arg_end;
do_cleanups (cleanup);
return result;

View File

@ -20,6 +20,8 @@
#if !defined (PROBE_H)
#define PROBE_H 1
struct event_location;
#include "gdb_vecs.h"
/* Definition of a vector of probes. */
@ -219,9 +221,9 @@ struct bound_probe
};
/* A helper for linespec that decodes a probe specification. It returns a
symtabs_and_lines object and updates *ARGPTR or throws an error. */
symtabs_and_lines object and updates LOC or throws an error. */
extern struct symtabs_and_lines parse_probes (char **argptr,
extern struct symtabs_and_lines parse_probes (const struct event_location *loc,
struct linespec_result *canon);
/* Helper function to register the proper probe_ops to a newly created probe.

View File

@ -30,6 +30,7 @@
#include "ada-lang.h"
#include "arch-utils.h"
#include "language.h"
#include "location.h"
/* Number of live breakpoints. */
static int bppy_live;
@ -380,7 +381,7 @@ bppy_set_hit_count (PyObject *self, PyObject *newvalue, void *closure)
static PyObject *
bppy_get_location (PyObject *self, void *closure)
{
char *str;
const char *str;
gdbpy_breakpoint_object *obj = (gdbpy_breakpoint_object *) self;
BPPY_REQUIRE_VALID (obj);
@ -388,8 +389,7 @@ bppy_get_location (PyObject *self, void *closure)
if (obj->bp->type != bp_breakpoint)
Py_RETURN_NONE;
str = obj->bp->addr_string;
str = event_location_to_string (obj->bp->location);
if (! str)
str = "";
return PyString_Decode (str, strlen (str), host_charset (), NULL);
@ -670,8 +670,12 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs)
{
case bp_breakpoint:
{
struct event_location *location;
location = new_linespec_location (&copy);
make_cleanup_delete_event_location (location);
create_breakpoint (python_gdbarch,
copy, NULL, -1, NULL,
location, NULL, -1, NULL,
0,
temporary_bp, bp_breakpoint,
0,

View File

@ -29,6 +29,7 @@
#include "observer.h"
#include "inferior.h"
#include "block.h"
#include "location.h"
/* Function that is called when a Python finish bp is found out of scope. */
static char * const outofscope_func = "out_of_scope";
@ -169,7 +170,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
PyObject *internal = NULL;
int internal_bp = 0;
CORE_ADDR finish_pc, pc;
char *addr_str, small_buf[100];
char small_buf[100], *p;
struct symbol *function;
if (!PyArg_ParseTupleAndKeywords (args, kwargs, "|OO", keywords,
@ -296,13 +297,17 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
TRY
{
struct event_location *location;
struct cleanup *back_to;
/* Set a breakpoint on the return address. */
finish_pc = get_frame_pc (prev_frame);
xsnprintf (small_buf, sizeof (small_buf), "*%s", hex_string (finish_pc));
addr_str = small_buf;
p = small_buf;
location = new_linespec_location (&p);
back_to = make_cleanup_delete_event_location (location);
create_breakpoint (python_gdbarch,
addr_str, NULL, thread, NULL,
location, NULL, thread, NULL,
0,
1 /*temp_flag*/,
bp_breakpoint,
@ -310,6 +315,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
AUTO_BOOLEAN_TRUE,
&bkpt_breakpoint_ops,
0, 1, internal_bp, 0);
do_cleanups (back_to);
}
CATCH (except, RETURN_MASK_ALL)
{

View File

@ -34,6 +34,7 @@
#include "extension-priv.h"
#include "cli/cli-utils.h"
#include <ctype.h>
#include "location.h"
/* Declared constants and enum for python stack printing. */
static const char python_excp_none[] = "none";
@ -724,12 +725,12 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
struct symtabs_and_lines sals = { NULL, 0 }; /* Initialize to
appease gcc. */
struct symtab_and_line sal;
const char *arg = NULL;
char *copy_to_free = NULL, *copy = NULL;
char *arg = NULL;
struct cleanup *cleanups;
PyObject *result = NULL;
PyObject *return_result = NULL;
PyObject *unparsed = NULL;
struct event_location *location;
if (! PyArg_ParseTuple (args, "|s", &arg))
return NULL;
@ -738,14 +739,16 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
sals.sals = NULL;
if (arg != NULL)
{
location = new_linespec_location (&arg);
make_cleanup_delete_event_location (location);
}
TRY
{
if (arg)
{
copy = xstrdup (arg);
copy_to_free = copy;
sals = decode_line_1 (&copy, 0, 0, 0);
}
sals = decode_line_1 (location, 0, 0, 0);
else
{
set_default_source_symtab_and_line ();
@ -761,10 +764,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
END_CATCH
if (sals.sals != NULL && sals.sals != &sal)
{
make_cleanup (xfree, copy_to_free);
make_cleanup (xfree, sals.sals);
}
make_cleanup (xfree, sals.sals);
if (except.reason < 0)
{
@ -808,9 +808,9 @@ gdbpy_decode_line (PyObject *self, PyObject *args)
goto error;
}
if (copy && strlen (copy) > 0)
if (arg != NULL && strlen (arg) > 0)
{
unparsed = PyString_FromString (copy);
unparsed = PyString_FromString (arg);
if (unparsed == NULL)
{
Py_DECREF (result);

View File

@ -45,6 +45,7 @@
#include "filestuff.h"
#include "rsp-low.h"
#include "disasm.h"
#include "location.h"
#include <sys/time.h>
@ -11242,13 +11243,12 @@ remote_download_tracepoint (struct target_ops *self, struct bp_location *loc)
if (packet_support (PACKET_TracepointSource) == PACKET_ENABLE)
{
if (b->addr_string)
if (b->location != NULL)
{
strcpy (buf, "QTDPsrc:");
encode_source_string (b->number, loc->address,
"at", b->addr_string, buf + strlen (buf),
2048 - strlen (buf));
encode_source_string (b->number, loc->address, "at",
event_location_to_string (b->location),
buf + strlen (buf), 2048 - strlen (buf));
putpkt (buf);
remote_get_noisy_reply (&target_buf, &target_buf_size);
if (strcmp (target_buf, "OK"))

View File

@ -45,7 +45,7 @@
#include "dwarf2-frame.h"
#include "ax.h"
#include "spu-tdep.h"
#include "location.h"
/* The list of available "set spu " and "show spu " commands. */
static struct cmd_list_element *setspucmdlist = NULL;
@ -1953,8 +1953,10 @@ spu_catch_start (struct objfile *objfile)
{
struct bound_minimal_symbol minsym;
struct compunit_symtab *cust;
char buf[32], *p;
CORE_ADDR pc;
char buf[32];
struct event_location *location;
struct cleanup *back_to;
/* Do this only if requested by "set spu stop-on-load on". */
if (!spu_stop_on_load_p)
@ -1999,7 +2001,10 @@ spu_catch_start (struct objfile *objfile)
/* Use a numerical address for the set_breakpoint command to avoid having
the breakpoint re-set incorrectly. */
xsnprintf (buf, sizeof buf, "*%s", core_addr_to_string (pc));
create_breakpoint (get_objfile_arch (objfile), buf /* arg */,
p = buf;
location = new_linespec_location (&p);
back_to = make_cleanup_delete_event_location (location);
create_breakpoint (get_objfile_arch (objfile), location,
NULL /* cond_string */, -1 /* thread */,
NULL /* extra_string */,
0 /* parse_condition_and_thread */, 1 /* tempflag */,
@ -2008,6 +2013,7 @@ spu_catch_start (struct objfile *objfile)
AUTO_BOOLEAN_FALSE /* pending_break_support */,
&bkpt_breakpoint_ops /* ops */, 0 /* from_tty */,
1 /* enabled */, 0 /* internal */, 0);
do_cleanups (back_to);
}

View File

@ -1,3 +1,9 @@
2015-08-11 Keith Seitz <keiths@redhat.com>
* gdb.base/dprintf-pending.exp: Update dprintf "without format"
test.
Add tests for missing ",FMT" and ",".
2015-08-10 Doug Evans <dje@google.com>
Keith Seitz <keiths@redhat.com>

View File

@ -41,14 +41,8 @@ with_test_prefix "without format" {
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_test \
"dprintf pendfunc" \
"Dprintf.*pendfunc.*pending." \
"set pending dprintf" \
".*Make dprintf pending.*y or \\\[n\\\]. $" \
"y"
gdb_test "file ${binfile}" ".*Error in re-setting breakpoint.*" "resolved dprintf fails to be re-set"
gdb_test "dprintf pendfunc" "Format string required" "missing ,FMT"
gdb_test "dprintf pendfunc," "Format string required" "missing FMT"
}
with_test_prefix "without symbols" {

View File

@ -55,6 +55,7 @@
#include "filestuff.h"
#include "rsp-low.h"
#include "tracefile.h"
#include "location.h"
/* readline include files */
#include "readline/readline.h"
@ -2712,14 +2713,22 @@ scope_info (char *args, int from_tty)
int j, count = 0;
struct gdbarch *gdbarch;
int regno;
struct event_location *location;
struct cleanup *back_to;
if (args == 0 || *args == 0)
error (_("requires an argument (function, "
"line or *addr) to define a scope"));
sals = decode_line_1 (&args, DECODE_LINE_FUNFIRSTLINE, NULL, 0);
location = string_to_event_location (&args, current_language);
back_to = make_cleanup_delete_event_location (location);
sals = decode_line_1 (location, DECODE_LINE_FUNFIRSTLINE, NULL, 0);
if (sals.nelts == 0)
return; /* Presumably decode_line_1 has already warned. */
{
/* Presumably decode_line_1 has already warned. */
do_cleanups (back_to);
return;
}
/* Resolve line numbers to PC. */
resolve_sal_pc (&sals.sals[0]);
@ -2856,6 +2865,7 @@ scope_info (char *args, int from_tty)
if (count <= 0)
printf_filtered ("Scope for %s contains no locals or arguments.\n",
save_args);
do_cleanups (back_to);
}
/* Helper for trace_dump_command. Dump the action list starting at
@ -3078,7 +3088,7 @@ trace_dump_command (char *args, int from_tty)
extern int
encode_source_string (int tpnum, ULONGEST addr,
char *srctype, char *src, char *buf, int buf_size)
char *srctype, const char *src, char *buf, int buf_size)
{
if (80 + strlen (srctype) > buf_size)
error (_("Buffer too small for source encoding"));

View File

@ -298,7 +298,7 @@ extern struct trace_state_variable *
extern struct trace_state_variable *create_trace_state_variable (const char *name);
extern int encode_source_string (int num, ULONGEST addr,
char *srctype, char *src,
char *srctype, const char *src,
char *buf, int buf_size);
extern void parse_trace_status (char *line, struct trace_status *ts);