summaryrefslogtreecommitdiff
path: root/gdb/location.h
AgeCommit message (Collapse)Author
2018-01-02Update copyright year range in all GDB filesJoel Brobecker
gdb/ChangeLog: Update copyright year range in all GDB files
2017-12-13python: Add qualified parameter to gdb.BreakpointSimon Marchi
This patch adds the possibility to pass a qualified=True|False parameter when creating a breakpoint in Python. It is equivalent to using -qualified in a linespec. The parameter actually accepts any Python value, and converts it to boolean using Python's standard rules for that (https://docs.python.org/3/library/stdtypes.html#truth). Unlike the -source/-line/-function/-label parameters, it is possible to use -qualified with a "normal" (non-explicit) linespec. Therefore, it is possible (unlike these other parameters) to use this new parameter along with the spec parameter. I updated the py-breakpoint.exp test. To be able to test multiple locations using a namespace, I had to switch the test case to compile as C++. If we really wanted to, we could run it as both C and C++, but omit the C++-specific parts when running it as C. gdb/ChangeLog: * location.h (string_to_event_location): Add match_type parameter. * location.c (string_to_event_location): Likewise. * python/py-breakpoint.c (bppy_init): Handle qualified parameter. gdb/doc/ChangeLog: * python.texi (Manipulating breakpoints using Python): Document qualified parameter to gdb.Breakpoint. gdb/testsuite/ChangeLog: * gdb.python/py-breakpoint.c (foo_ns::multiply): New function. * gdb.python/py-breakpoint.exp: Compile the test case as c++, call test_bkpt_qualified. (test_bkpt_qualified): New proc.
2017-11-29Make "break foo" find "A::foo", A::B::foo", etc. [C++ and wild matching]Pedro Alves
This patch teaches GDB about setting breakpoints in all scopes (namespaces and classes) by default. Here's a contrived example: (gdb) b func<tab> (anonymous namespace)::A::function() Bn::(anonymous namespace)::B::function() function(int, int) (anonymous namespace)::B::function() Bn::(anonymous namespace)::function() gdb::(anonymous namespace)::A::function() (anonymous namespace)::B::function() const Bn::(anonymous namespace)::function(int, int) gdb::(anonymous namespace)::function() (anonymous namespace)::function() Bn::B::func() gdb::(anonymous namespace)::function(int, int) (anonymous namespace)::function(int, int) Bn::B::function() gdb::A::func() A::func() Bn::func() gdb::A::function() A::function() Bn::function() gdb::func() B::func() Bn::function(int, int) gdb::function() B::function() Bn::function(long) gdb::function(int, int) B::function() const func() gdb::function(long) B::function_const() const function() (gdb) b function Breakpoint 1 at 0x4005ce: function. (26 locations) (gdb) b B::function<tab> (anonymous namespace)::B::function() B::function() const Bn::B::function() (anonymous namespace)::B::function() const B::function_const() const B::function() Bn::(anonymous namespace)::B::function() (gdb) b B::function Breakpoint 1 at 0x40072c: B::function. (6 locations) To get back the original behavior of interpreting the function name as a fully-qualified name, you can use the new "-qualified" (or "-q") option/flag (added by this commit). For example: (gdb) b B::function (anonymous namespace)::B::function() B::function() const Bn::B::function() (anonymous namespace)::B::function() const B::function_const() const B::function() Bn::(anonymous namespace)::B::function() vs: (gdb) b -qualified B::function B::function() B::function() const B::function_const() const I've chosen "-qualified" / "-q" because "-f" (for "full" or "fully-qualified") is already taken for "-function". Note: the "-qualified" option works with both linespecs and explicit locations. I.e., these are equivalent: (gdb) b -q func (gdb) b -q -f func and so are these: (gdb) b -q filename.cc:func (gdb) b -q -s filename.cc -f func (gdb) b -s filename.cc -q -f func (gdb) b -s filename.cc -f func -q To better understand why I consider wild matching the better default, consider what happens when we get to the point when _all_ of GDB is wrapped under "namespace gdb {}". I have a patch series that does that, and when I started debugging that GDB, I immediately became frustrated. You'd have to write "b gdb::internal_error", "b gdb::foo", "b gdb::bar", etc. etc., which gets annoying pretty quickly. OTOH, consider how this makes it very easy to set breakpoints in classes wrapped in anonymous namespaces. You just don't think of them, GDB finds the symbols for you automatically. (At the Cauldron a couple months ago, several people told me that they run into a similar issue when debugging other C++ projects. One example was when debugging LLVM, which puts all its code under the "llvm" namespace.) Implementation-wise, what the patch does is: - makes C++ symbol name hashing only consider the last component of a symbol name. (so that we can look up symbol names by last-component name only). - adds a C++ symbol name matcher for symbol_name_match_type::WILD, which ignores missing leading specifiers / components. - adjusts a few preexisting testsuite tests to use "-qualified" when they mean it. - adds new testsuite tests. - adds unit tests. Grows the gdb.linespec/ tests like this: -# of expected passes 7823 +# of expected passes 8977 gdb/ChangeLog: 2017-11-29 Pedro Alves <palves@redhat.com> * NEWS: Mention that breakpoints on C++ functions are now set on on all namespaces/classes by default, and mention "break -qualified". * ax-gdb.c (agent_command_1): Adjust to pass a symbol_name_match_type to new_linespec_location. * breakpoint.c (parse_breakpoint_sals): Adjust to get_linespec_location's return type change. (strace_marker_create_sals_from_location): Adjust to pass a symbol_name_match_type to new_linespec_location. (strace_marker_decode_location): Adjust to get_linespec_location's return type change. (strace_command): Adjust to pass a symbol_name_match_type to new_linespec_location. (LOCATION_HELP_STRING): Add paragraph about wildmatching, and mention "-qualified". * c-lang.c (cplus_language_defn): Install cp_search_name_hash. * completer.c (explicit_location_match_type::MATCH_QUALIFIED): New enumerator. (complete_address_and_linespec_locations): New parameter 'match_type'. Pass it down. (explicit_options): Add "-qualified". (collect_explicit_location_matches): Pass the requested match type to the linespec completers. Handle MATCH_QUALIFIED. (location_completer): Handle "-qualified" combined with linespecs. * cp-support.c (cp_search_name_hash): New. (cp_symbol_name_matches_1): Implement wild matching for C++. (cp_fq_symbol_name_matches): Reimplement. (cp_get_symbol_name_matcher): Return different matchers depending on the lookup name's match type. (selftests::test_cp_symbol_name_matches): Add wild matching tests. * cp-support.h (cp_search_name_hash): New declaration. * dwarf2read.c (selftests::dw2_expand_symtabs_matching::test_symbols): Add symbols. (test_dw2_expand_symtabs_matching_symbol): Add wild matching tests. * guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Adjust to pass a symbol_name_match_type to new_linespec_location. * linespec.c (linespec_parse_basic): Lookup function symbols using the parser's symbol name match type. (convert_explicit_location_to_linespec): New symbol_name_match_type parameter. Pass it down to find_linespec_symbols. (convert_explicit_location_to_sals): Pass the location's name match type to convert_explicit_location_to_linespec. (parse_linespec): New match_type parameter. Save it in the parser. (linespec_parser_new): Default to symbol_name_match_type::WILD. (linespec_complete_function): New symbol_name_match_type parameter. Use it. (complete_linespec_component): Pass down the parser's recorded name match type. (linespec_complete_label): New symbol_name_match_type parameter. Use it. (linespec_complete): New symbol_name_match_type parameter. Save it in the parser and pass it down. Adjust to get_linespec_location's prototype change. (find_function_symbols, find_linespec_symbols): New symbol_name_match_type parameter. Pass it down instead of assuming symbol_name_match_type::WILD. * linespec.h (linespec_complete, linespec_complete_function) (linespec_complete_label): New symbol_name_match_type parameter. * location.c (event_location::linespec_location): Now a struct linespec_location. (EL_LINESPEC): Adjust. (initialize_explicit_location): Default to symbol_name_match_type::WILD. (new_linespec_location): New symbol_name_match_type parameter. Record it in the location. (get_linespec_location): Now returns a struct linespec_location. (new_explicit_location): Also copy func_name_match_type. (explicit_to_string_internal) (string_to_explicit_location): Handle "-qualified". (copy_event_location): Adjust to LINESPEC_LOCATION type change. Copy symbol_name_match_type fields. (event_location_deleter::operator()): Adjust to LINESPEC_LOCATION type change. (event_location_to_string): Adjust to LINESPEC_LOCATION type change. Handle "-qualfied". (string_to_explicit_location): Handle "-qualified". (string_to_event_location_basic): New symbol_name_match_type parameter. Pass it down. (string_to_event_location): Handle "-qualified". * location.h (struct linespec_location): New. (explicit_location::func_name_match_type): New field. (new_linespec_location): Now returns a const linespec_location *. (string_to_event_location_basic): New symbol_name_match_type parameter. (explicit_completion_info::saw_explicit_location_option): New field. * mi/mi-cmd-break.c (mi_cmd_break_insert_1): Adjust to pass a symbol_name_match_type to new_linespec_location. * python/py-breakpoint.c (bppy_init): Likewise. * python/python.c (gdbpy_decode_line): Likewise. gdb/testsuite/ChangeLog: 2017-11-29 Pedro Alves <palves@redhat.com> * gdb.base/langs.exp: Use -qualified. * gdb.cp/meth-typedefs.exp: Use -qualified, and add tests without it. * gdb.cp/namespace.exp: Use -qualified. * gdb.linespec/cpcompletion.exp (overload-2, fqn, fqn-2) (overload-3, template-overload, template-ret-type, const-overload) (const-overload-quoted, anon-ns, ambiguous-prefix): New procedures. (test_driver): Call them. * gdb.cp/save-bp-qualified.cc: New. * gdb.cp/save-bp-qualified.exp: New. * gdb.linespec/explicit.exp: Test -qualified. * lib/completion-support.exp (completion::explicit_opts_list): Add "-qualified". * lib/gdb.exp (gdb_breakpoint): Handle "qualified". gdb/doc/ChangeLog: 2017-11-29 Pedro Alves <palves@redhat.com> * gdb.texinfo (Linespec Locations): Document how "function" is interpreted in C++ and Ada. Document "-qualified". (Explicit Locations): Document how "-function" is interpreted in C++ and Ada. Document "-qualified".
2017-09-27Constify some linespec functionsTom Tromey
This changes a few linespec functions to work on "const char *" and then fixes up all the callers. This allows further constification elsewhere. gdb/ChangeLog 2017-09-27 Tom Tromey <tom@tromey.com> * tracepoint.c (info_scope_command): Constify. * python/python.c (gdbpy_decode_line): Constify. * python/py-breakpoint.c (bppy_init): Constify. * mi/mi-cmd-break.c (mi_cmd_break_insert_1): Constify. * location.h: (new_linespec_location) (string_to_event_location_basic, string_to_event_location): Constify. * location.c (new_linespec_location) (string_to_event_location_basic, string_to_event_location): Constify. * linespec.h (decode_line_with_current_source) (decode_line_with_last_displayed, linespec_lex_to_end): Constify. * linespec.c (linespec_lex_to_end) (decode_line_with_current_source) (decode_line_with_last_displayed): Constify. * guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Constify. * cli/cli-cmds.c (edit_command, list_command): Constify. * breakpoint.h (until_break_command, watch_command_wrapper) (awatch_command_wrapper, rwatch_command_wrapper) (init_ada_exception_breakpoint): Constify. * breakpoint.c (break_command_1, dprintf_command) (break_range_command, watch_command_wrapper) (rwatch_command_wrapper, awatch_command_wrapper) (until_break_command, init_ada_exception_breakpoint) (strace_marker_create_sals_from_location, trace_command) (ftrace_command, strace_command, struct tracepoint): Constify. * ax-gdb.c (agent_command_1): Constify. * ada-lang.c (ada_exception_sal): Constify.
2017-07-17Rewrite/enhance explicit locations completer, parse left->rightPedro Alves
One of the most annoying (to me) things about GDB's completion is when you have overloads in your program, and you want to set a breakpoint in one of them: void function(int); // set breakpoint here. void function(long); (gdb) b -f func[TAB] (gdb) b -f function( # ok, gdb completed as much as possible. (gdb) b -f function([TAB] # show me the overloads, please. <_all_ symbols in the program are shown...> E.g., when debugging GDB, that'd be: (gdb) b -f function([TAB] (anonymous namespace)::get_global()::global pt_insn_get_offset@plt scm_new_port_table_entry asprintf pt_pkt_alloc_decoder scm_new_port_table_entry@plt asprintf@plt pt_pkt_alloc_decoder@plt scm_out_of_range bt_ctf_get_char_array pt_pkt_sync_forward scm_out_of_range@plt bt_ctf_get_char_array@plt pt_pkt_sync_forward@plt scm_putc bt_ctf_get_uint64 pwrite scm_putc@plt bt_ctf_get_uint64@plt pwrite@plt scm_reverse_x bt_ctf_iter_read_event PyErr_Restore scm_reverse_x@plt bt_ctf_iter_read_event@plt PyErr_Restore@plt scm_set_port_filename_x <snip...> Now that's a load of completely useless completions. The reason GDB offers those is that the completer relies on readline figuring out the completion word point in the input line based on the language's word break characters, which include "(". So readline tells the completer to complete on "", the string that is after '('. Likewise, if you type "function(i[TAB]" to try to complete to "int", you're out of luck. GDB shows you all the symbols in the program that start with "i"... This makes sense for the expression completer, as what you'd want to type is e.g., a global variable, say: (gdb) print function(i[TAB] but, it makes no sense when specifying a function name for a breakpoint location. To get around that limitation, users need to quote the function name, like: (gdb) b -f 'function([TAB] function(int) function(long) (gdb) b 'function(i[TAB] (gdb) b 'function(int)' # now completes correctly! Note that the quoting is only necessary for completion. Creating the breakpoint does not require the quoting: (gdb) b -f function(int) [RET] Breakpoint 1 at .... This patch removes this limitation. ( Actually, it's a necessary patch, though not sufficient. That'll start working correctly by the end of the series. With this patch, if try it, you'll see: (gdb) b -f function(i[TAB] (gdb) b -f function i.e., gdb strips everything after the "(". That's caused by some code in symtab.c that'll be eliminated further down the series. These patches are all unfortunately interrelated, which is also the reason new tests only appear much later in the series. But let's ignore that reality for the remainder of the description. ) So... this patch gets rid of the need for quoting. It does that by adding a way for a completer to control the exact completion word point that readline should start the completion request for, instead of letting readline try to figure it out using the current language's word break chars array, and often failing. In the case above, we want the completer to figure out that it's completing a function name that starts with "function(i". It now does. It took me a while to figure out a way to ask readline to "use this exact word point", and for a while I feared that it'd be impossible with current readline (and having to rely on master readline for core functionality is something I'd like to avoid very much). Eventually, after several different attempts, I came up with what is described in the comment above gdb_custom_word_point_brkchars in the patch. With this patch, the handle_brkchars phase of the explicit location completer advances the expected word point as it parses the input line left to right, until it figures out exactly what we're completing, instead of expecting readline to break the string using the word break characters, and then having the completer heuristically fix up a bad decision by parsing the input string backwards. This allows correctly knowning that we're completing a symbol name after -function, complete functions without quoting, etc. Later, we'll make use of this same mechanims to implement a proper linespec completer that avoids need for quoting too. gdb/ChangeLog: 2017-07-17 Pedro Alves <palves@redhat.com> * ada-lang.c (ada_collect_symbol_completion_matches): Add complete_symbol_mode parameter. * cli/cli-cmds.c (complete_command): Get the completion result out of the handle_brkchars tracker if used a custom word point. * completer.c: Include "linespec.h". (enum explicit_location_match_type) <MATCH_LINE>: New enumerator. (advance_to_expression_complete_word_point): New. (completion_tracker::completes_to_completion_word): New. (complete_files_symbols): Pass down complete_symbol_mode::EXPRESSION. (explicit_options, probe_options): New. (collect_explicit_location_matches): Complete on the explictit_loc->foo instead of word. Use linespec_complete_function. Handle MATCH_LINE. Handle offering keyword and options completions. (backup_text_ptr): Delete. (skip_keyword): New. (complete_explicit_location): Remove 'word' parameter. Add language, quoted_arg_start and quoted_arg_end parameters. Rewrite, parsing left to right. (location_completer): Rewrite. (location_completer_handle_brkchars): New function. (symbol_completer): Pass down complete_symbol_mode::EXPRESSION. (enum complete_line_internal_reason): Adjust comments. (completion_tracker::discard_completions): New. (completer_handle_brkchars_func_for_completer): Handle location_completer. (gdb_custom_word_point_brkchars) (gdb_org_rl_basic_quote_characters): New. (gdb_completion_word_break_characters_throw) (completion_find_completion_word): Handle trackers that use a custom word point. (completion_tracker::advance_custom_word_point_by): New. (completion_tracker::build_completion_result): Don't rely on readline appending the quote char. (gdb_rl_attempted_completion_function_throw): Handle trackers that use a custom word point. (gdb_rl_attempted_completion_function): Restore rl_basic_quote_characters. * completer.h (class completion_tracker): Extend intro comment. (completion_tracker::set_quote_char) (completion_tracker::quote_char) (completion_tracker::set_use_custom_word_point) (completion_tracker::use_custom_word_point) (completion_tracker::custom_word_point) (completion_tracker::set_custom_word_point) (completion_tracker::advance_custom_word_point_by) (completion_tracker::completes_to_completion_word) (completion_tracker::discard_completions): New methods. (completion_tracker::m_quote_char) (completion_tracker::m_use_custom_word_point) (completion_tracker::m_custom_word_point): New fields. (advance_to_expression_complete_word_point): Declare. * f-lang.c (f_collect_symbol_completion_matches): Add complete_symbol_mode parameter. * language.h (struct language_defn) <la_collect_symbol_completion_matches>: Add complete_symbol_mode parameter. * linespec.c (linespec_keywords): Add NULL terminator. Make extern. (linespec_complete_function): New function. (linespec_lexer_lex_keyword): Adjust. * linespec.h (linespec_keywords, linespec_complete_function): New declarations. * location.c (find_end_quote): New function. (explicit_location_lex_one): Add explicit_completion_info parameter. Save quoting info. Don't throw if being called for completion. Don't handle Ada operators here. (is_cp_operator, skip_op_false_positives, first_of) (explicit_location_lex_one_function): New function. (string_to_explicit_location): Replace 'dont_throw' parameter with an explicit_completion_info pointer parameter. Handle it. Don't use explicit_location_lex_one to lex function names. Use explicit_location_lex_one_function instead. * location.h (struct explicit_completion_info): New. (string_to_explicit_location): Replace 'dont_throw' parameter with an explicit_completion_info pointer parameter. * symtab.c (default_collect_symbol_completion_matches_break_on): Add complete_symbol_mode parameter. Handle LINESPEC mode. (default_collect_symbol_completion_matches) (collect_symbol_completion_matches): Add complete_symbol_mode parameter. (collect_symbol_completion_matches_type): Pass down complete_symbol_mode::EXPRESSION. (collect_file_symbol_completion_matches): Add complete_symbol_mode parameter. Handle LINESPEC mode. * symtab.h (complete_symbol_mode): New. (default_collect_symbol_completion_matches_break_on) (default_collect_symbol_completion_matches) (collect_symbol_completion_matches) (collect_file_symbol_completion_matches): Add complete_symbol_mode parameter. gdb/testsuite/ChangeLog: 2017-07-17 Pedro Alves <palves@redhat.com> * gdb.linespec/ls-errs.exp (do_test): Adjust expected output.
2017-04-12Change linespec_result::location to be an event_location_upTom Tromey
This is a follow-up to another patch. It changes linespec_result::location to be an event_location_up. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * probe.c (parse_probes): Update. * location.h (delete_event_location): Don't declare. (event_location_deleter::operator()): Update. * location.c (event_location_deleter::operator()): Rename from delete_event_location. * linespec.h (linespec_result) <location>: Change type to event_location_up. * linespec.c (canonicalize_linespec, event_location_to_sals) (decode_objc): Update. (linespec_result): Don't call delete_event_location. * breakpoint.c (create_breakpoints_sal) (bkpt_probe_create_sals_from_location) (strace_marker_create_sals_from_location): Update.
2017-04-12Introduce event_location_upTom Tromey
This removes make_cleanup_delete_event_location and instead changes the various location functions to return an event_location_up, a new unique_ptr typedef. This is largely straightforward, but be sure to examine the init_breakpoint_sal change. I believe the code I deleted there is dead, because "location != NULL" can never be true in that branch; but you should double-check. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * tracepoint.c (scope_info): Update. * spu-tdep.c (spu_catch_start): Update. * python/python.c (gdbpy_decode_line): Update. * python/py-finishbreakpoint.c (bpfinishpy_init): Update. * python/py-breakpoint.c (bppy_init): Update. * probe.c (parse_probes): Update. * mi/mi-cmd-break.c (mi_cmd_break_insert_1): Update. * location.h (event_location_deleter): New struct. (event_location_up): New typedef. (new_linespec_location, new_address_location, new_probe_location) (new_explicit_location, copy_event_location) (string_to_event_location, string_to_event_location_basic) (string_to_explicit_location): Update return type. (make_cleanup_delete_event_location): Remove. * location.c (new_linespec_location, new_address_location) (new_probe_location, new_explicit_location, copy_event_location): Return event_location_up. (delete_event_location_cleanup) (make_cleanup_delete_event_location): Remove. (string_to_explicit_location, string_to_event_location_basic) (string_to_event_location): Return event_location_up. * linespec.c (canonicalize_linespec, event_location_to_sals) (decode_line_with_current_source) (decode_line_with_last_displayed, decode_objc): Update. * guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Update. * completer.c (location_completer): Update. * cli/cli-cmds.c (edit_command, list_command): Update. * breakpoint.c (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint) (create_thread_event_breakpoint): Update. (init_breakpoint_sal): Update. Remove some dead code. (create_breakpoint_sal): Change type of "location". Update. (create_breakpoints_sal, create_breakpoint, break_command_1) (dprintf_command, break_range_command, until_break_command) (init_ada_exception_breakpoint) (strace_marker_create_sals_from_location) (update_static_tracepoint, trace_command, ftrace_command) (strace_command, create_tracepoint_from_upload): Update. * break-catch-throw.c (re_set_exception_catchpoint): Update. * ax-gdb.c (agent_command_1): Update.
2017-01-01update copyright year range in GDB filesJoel Brobecker
This applies the second part of GDB's End of Year Procedure, which updates the copyright year range in all of GDB's files. gdb/ChangeLog: Update copyright year range in all GDB files.
2016-02-09Refactor string_to_event_location for legacy linespec support.Keith Seitz
This patch refactors string_to_event_location, breaking it into two separate functions: 1) string_to_event_location_basic A "basic" string parser that implements support for "legacy" linespecs (linespec, address, and probe locations). This function is intended to be used by any UI wishing/needing to support this legacy behavior. 2) string_to_event_location This is now intended as a CLI-only function which adds explicit location parsing in a CLI-appropriate manner (in the form of traditional option/value pairs). Together these patches serve to simplify string-to-event location parsing for all existing non-CLI interfaces (MI, guile, and python). gdb/ChangeLog * location.c (string_to_explicit_location): Note that "-p" is reserved for probe locations and return NULL for any input that starts with that. (string_to_event_location): Move "legacy" linespec code to ... (string_to_event_location_basic): ... here. * location.h (string_to_event_location): Update comment. (string_to_event_location_basic): New function.
2016-01-21Fix regression introduced in "break *<EXPR>" by explicit location patches.Joel Brobecker
A relatively recent patch support for explicit locations, and part of that patch cleaned up the way we parse breakpoint locations. Unfortunatly, a small regression crept in for "*<EXPR>" breakpoint locations. In particular, on PIE programs, one can see the issue by doing the following, with any program: (gdb) b *main Breakpoint 1 at 0x51a: file hello.c, line 3. (gdb) run Starting program: /[...]/hello Error in re-setting breakpoint 1: Warning: Cannot insert breakpoint 1. Cannot access memory at address 0x51a Warning: Cannot insert breakpoint 1. Cannot access memory at address 0x51a Just for the record, this regression was introduced by: commit a06efdd6effd149a1d392df8d62824e44872003a Date: Tue Aug 11 17:09:35 2015 -0700 Subject: Explicit locations: introduce address locations What happens is that the patch makes the implicit assumption that the address computed the first time is static, as if it was designed to only support litteral expressions (Eg. "*0x1234"). This allows the shortcut of not re-computing the breakpoint location's address when re-setting breakpoints. However, this does not work in general, as demonstrated in the example above. This patch plugs that hole simply by saving the original expression used to compute the address as part of the address location, so as to then re-evaluate that expression during breakpoint re-set. gdb/ChangeLog: * location.h (new_address_location): Add new parameters "addr_string" and "addr_string_len". (get_address_string_location): Add declaration. * location.c (new_address_location): Add new parameters "addr_string" and "addr_string_len". If not NULL, store a copy of the addr_string in the new location as well. (get_address_string_location): New function. (string_to_event_location): Update call to new_address_location. * linespec.c (event_location_to_sals) <ADDRESS_LOCATION>: Save the event location in the parser's state before passing it to convert_address_location_to_sals. * breakpoint.c (create_thread_event_breakpoint): Update call to new_address_location. (init_breakpoint_sal): Get the event location's string, if any, and use it to update call to new_address_location. * python/py-finishbreakpoint.c (bpfinishpy_init): Update call to new_address_location. * spu-tdep.c (spu_catch_start): Likewise. * config/djgpp/fnchange.lst: Add entries for gdb/testsuite/gdb.base/break-fun-addr1.c and gdb/testsuite/gdb.base/break-fun-addr2.c. gdb/testsuite/ChangeLog: * gdb.base/break-fun-addr.exp: New file. * gdb.base/break-fun-addr1.c: New file. * gdb.base/break-fun-addr2.c: New file.
2016-01-01GDB copyright headers update after running GDB's copyright.py script.Joel Brobecker
gdb/ChangeLog: Update year range in copyright notice of all files.
2015-08-13Mass rename `explicit' -> `explicit_loc'.Keith Seitz
BuildBot reminded me that "explicit" is a reserved keyword in C++. This patch simply renames all the (illegal) uses of "explicit". This should fix the build errors with --enable-build-with-cxx bots. gdb/ChangeLog * break-catch-throw.c (re_set_exception_catchpoint) Rename reserved C++ keyword "explicit" to "explicit_loc". * breakpoint.c (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint, update_static_tracepoint): Rename reserved C++ keyword "explicit" to "explicit_loc". * completer.c (collect_explicit_location_matches) (explicit_location_completer): Rename reserved C++ keyword "explicit" to "explicit_loc". * linespec.c (struct linespec) <explicit>: Rename to "explicit_loc". (canonicalize_linespec, create_sals_line_offset) (convert_linespec_to_sals, convert_explicit_location_to_sals) (event_location_to_sals, decode_objc): Rename reserved C++ keyword "explicit" to "explicit_loc". * location.c (struct event_location) <explicit>: Rename to "explicit_loc". (initialize_explicit_location, new_explicit_location) (explicit_location_to_string_internal, explicit_location_to_linespec): Rename reserved C++ keyword "explicit" to "explicit_loc". * location.h (explicit_location_to_string) (explicit_location_to_linespec, initialize_explicit_location) (new_explicit_location): Rename reserved C++ keyword "explicit" to "explicit_loc". * mi/mi-cmd-break.c (mi_cmd_break_insert_1): Rename reserved C++ keyword "explicit" to "explicit_loc".
2015-08-11Explicit locations: add UI features for CLIKeith Seitz
This patch exposes explicit locations to the CLI user. This enables users to "explicitly" specify attributes of the breakpoint location to avoid any ambiguity that might otherwise exist with linespecs. The general syntax of explicit locations is: -source SOURCE_FILENAME -line {+-}LINE -function FUNCTION_NAME -label LABEL_NAME Option names may be abbreviated, e.g., "-s SOURCE_FILENAME -li 3" and users may use the completer with either options or values. gdb/ChangeLog: * completer.c: Include location.h. (enum match_type): New enum. (location_completer): Rename to ... (linespec_completer): ... this. (collect_explicit_location_matches, backup_text_ptr) (explicit_location_completer): New functions. (location_completer): "New" function; handle linespec and explicit location completions. (complete_line_internal): Remove all location completer-specific handling. * linespec.c (linespec_lexer_lex_keyword, is_ada_operator) (find_toplevel_char): Export. (linespec_parse_line_offset): Export. Issue error if STRING is not numerical. (gdb_get_linespec_parser_quote_characters): New function. * linespec.h (linespec_parse_line_offset): Declare. (get_gdb_linespec_parser_quote_characters): Declare. (is_ada_operator): Declare. (find_toplevel_char): Declare. (linespec_lexer_lex_keyword): Declare. * location.c (explicit_to_event_location): New function. (explicit_location_lex_one): New function. (string_to_explicit_location): New function. (string_to_event_location): Handle explicit locations. * location.h (explicit_to_event_location): Declare. (string_to_explicit_location): Declare. gdb/testsuite/ChangeLog: * gdb.linespec/3explicit.c: New file. * gdb.linespec/cpexplicit.cc: New file. * gdb.linespec/cpexplicit.exp: New file. * gdb.linespec/explicit.c: New file. * gdb.linespec/explicit.exp: New file. * gdb.linespec/explicit2.c: New file. * gdb.linespec/ls-errs.exp: Add explicit location tests. * lib/gdb.exp (capture_command_output): Regexp-escape `command' before using in the matching pattern. Clarify that `prefix' is a regular expression.
2015-08-11Explicit locations: introduce explicit locationsKeith Seitz
This patch add support for explicit locations and switches many linespec locations to this new location type. This patch also converts all linespec locations entered by the user to an explicit representation internally (thus bypassing the linespec parser when resetting the breakpoint). This patch does not introduce any user-visible changes. gdb/ChangeLog: * break-catch-throw.c (re_set_exception_catchpoint): Convert linespec into explicit location. * breakpoint.c (create_overlay_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Convert linespec into explicit location. (update_static_tracepoint): Convert linespec into explicit location. * linespec.c (enum offset_relative_sign, struct line_offset): Move location.h. (struct linespec) <expression, expr_pc, source_filename> <function_name, label_name, line_offset>: Replace with ... <explicit>: ... this. <is_linespec>: New member. (PARSER_EXPLICIT): New accessor macro. (undefined_label_error): New function. (source_file_not_found_error): New function. (linespec_parse_basic): The parser result is now an explicit location. Use PARSER_EXPLICIT to access it. Use undefined_label_error. (canonicalize_linespec): Convert canonical linespec into explicit location. Move string representation of location to explicit_location_to_linespec and use it and explicit_location_to_string to save string representations of the canonical location. (create_sals_line_offset, convert_linespec_to_sals): `ls' contains an explicit location. Update all references. (convert_explicit_location_to_sals): New function. (parse_linespec): Use PARSER_EXPLICIT to access the parser result's explicit location. (linespec_state_constructor): Initialize is_linespec. Use PARSER_EXPLICIT. (linespec_parser_delete): Use PARSER_EXPLICIT to access the parser's result. (event_location_to_sals): For linespec locations, set is_linespec. Handle explicit locations. (decode_objc): 'ls' contains an explicit location now. Update all references. (symtabs_from_filename): Use source_file_not_found_error. * location.c (struct event_location.u) <explicit>: New member. (initialize_explicit_location): New function. (initialize_event_location): Initialize explicit locations. (new_explicit_location, get_explicit_location) (get_explicit_location_const): New functions. (explicit_to_string_internal): New function; most of contents moved from canonicalize_linespec. (explicit_location_to_string): New function. (explicit_location_to_linespec): New function. (copy_event_location, delete_event_location) (event_location_to_string_const, event_location_empty_p): Handle explicit locations. * location.h (enum offset_relative_sign, struct line_offset): Move here from linespec.h. (enum event_location_type): Add EXPLICIT_LOCATION. (struct explicit_location): New structure. (explicit_location_to_string): Declare. (explicit_location_to_linespec): Declare. (new_explicit_location, get_explicit_locationp (get_explicit_location_const, initialize_explicit_location): Declare.
2015-08-11Explicit locations: introduce probe locationsKeith Seitz
This patch adds support for probe locations and converts existing probe linespec locations to the new location type. gdb/ChangeLog: * break-catch-throw.c (re_set_exception_catchpoint): Convert linespec for stap probe to probe location. * breakpoint.c (create_longjmp_master_breakpoint) (create_exception_master_breakpoint): Likewise. (break_command_1): Remove local variable `arg_cp'. Check location type to set appropriate breakpoint ops methods. (trace_command): Likewise. * linespec.c (event_location_to_sals): Assert on probe locations. * location.c (EL_PROBE): Add macro definition. (new_probe_location, get_probe_location): New functions. (copy_event_location, delete_event_location, event_location_to_string) (string_to_event_location, event_location_empty_p): Handle probe locations. * location.h (enum event_location_type): Add PROBE_LOCATION. (new_probe_location, get_probe_location): Declare. * probe.c (parse_probes): Assert that LOCATION is a probe location. Convert linespec into probe location.
2015-08-11Explicit locations: introduce address locationsKeith Seitz
This patch adds support for address locations, of the form "*ADDR". [Support for address linespecs has been removed/replaced by this "new" location type.] This patch also converts any existing address locations from its previous linespec type. gdb/ChangeLog: * breakpoint.c (create_thread_event_breakpoint, init_breakpoint_sal): Convert linespec to address location. * linespec.c (canonicalize_linespec): Do not handle address locations here. (convert_address_location_to_sals): New function; contents moved from ... (convert_linespc_to_sals): ... here. (parse_linespec): Remove address locations from linespec grammar. Remove handling of address locations. (linespec_lex_to_end): Remove handling of address linespecs. (event_location_to_sals): Handle ADDRESS_LOCATION. (linespec_expression_to_pc): Export. * linespec.h (linespec_expression_to_pc): Add declaration. * location.c (struct event_location.u) <address>: New member. (new_address_location, get_address_location): New functions. (copy_event_location, delete_event_location, event_location_to_string) (string_to_event_location, event_location_empty_p): Handle address locations. * location.h (enum event_location_type): Add ADDRESS_LOCATION. (new_address_location, get_address_location): Declare. * python/py-finishbreakpoint.c (bpfinishpy_init): Convert linespec to address location. * spu-tdep.c (spu_catch_start): Likewise.
2015-08-11Explicit locations: introduce new struct event_location-based APIKeith Seitz
This patch introduces the new breakpoint/"linespec" API based on a new struct event_location. This API currently only supports traditional linespecs, maintaining the status quo of the code base. Future patches will add additional functionality for other location types such as address locations. gdb/ChangeLog: * Makefile.in (SFILES): Add location.c. (HFILES_NO_SRCDIR): Add location.h. (COMMON_OBS): Add location.o. * linespec.c (linespec_lex_to_end): New function. * linespec.h (linespec_lex_to_end): Declare. * location.c: New file. * location.h: New file.