Following my previous commit which add support for stopping at start of
exception handler, this commit adds required gdb-mi support for this
feature.
gdb/ChangeLog:
* mi/mi-cmd-catch.c (mi_cmd_catch_handlers): New function.
* mi/mi-cmds.c (mi_cmds): Add catch-handlers command.
* mi/mi-cmds.h (mi_cmd_catch_handlers): Add external declaration.
* NEWS: Document "-catch-handlers" command.
gdb/doc/ChangeLog:
* gdb.texinfo (Ada Exception gdb/mi Catchpoints): Add
documentation for new "-catch-handlers" command.
gdb/testsuite/ChangeLog:
* gdb.ada/mi_catch_ex_hand.exp: New testcase.
* gdb.ada/mi_catch_ex_hand/foo.adb: New file.
Tested on x86_64-linux.
This commit C++fy the conditional string used when catching Ada exception.
gdb/ChangeLog:
* ada-lang.c (catch_ada_exception_command_split)
(create_ada_exception_catchpoint) <cond_string>: Change parameter
type. Update code accordingly.
(catch_ada_exception_command, catch_ada_handlers_command): Use
C++ string instead of char* for conditional var.
(catch_ada_assert_command_split) <cond_string>: Change parameter
type. Update code accordingly.
(catch_assert_command): Use C++ string instead of char* for
conditional var.
* ada-lang.h (create_ada_exception_catchpoint) <cond_string>:
Update declaration.
* mi/mi-cmd-catch.c (mi_cmd_catch_assert, mi_cmd_catch_exception):
Use std::string instead of char* for condition string.
Tested on x86_64-linux.
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".
register_changed_p actually returns bool, but return type is still int.
This patch changes the return type to bool. The caller of
register_changed_p also checked whether the return value can be negative,
which is not needed now. Such check was added in fb40c2090 in 2000,
at that moment, register_changed_p returns -1 when
read_relative_register_raw_bytes fails. I can tell from its name that
it reads register contents, but we don't have this function called inside
register_changed_p, and the regcache is read-only.
gdb:
2017-11-24 Yao Qi <yao.qi@linaro.org>
* mi/mi-main.c (mi_cmd_data_list_changed_registers): Remove
local 'changed'. Remove error.
(register_changed_p): Change return type to bool.
Commit
C++ify osdata
479f8de1b3
introduced a memory leak. We allocate std::vectors and insert them in a
map, but never free them. Instead, the map value type can be
std::vector objects directly.
gdb/ChangeLog:
* mi/mi-main.c (list_available_thread_groups): Change map value
type to std::vector.
This patch c++ifies the osdata structure: osdata_column, osdata_item and
osdata. char* are replaced with std::string and VEC are replaced with
std::vector. This allows to get rid of a great deal of cleanup and
free'ing code.
I replaced the splay tree in list_available_thread_groups with an
std::map. Unless there's a good advantage to keep using a splay tree,
I think using the standard type should make things simpler to
understand.
gdb/ChangeLog:
* osdata.h: Include vector isntead of vec.h.
(osdata_column_s): Remove typedef.
(struct osdata_column): Add constructor.
<name, value>: Change type to std::string.
(DEF_VEC_O (osdata_column_s)): Remove.
(osdata_item_s): Remove typedef.
(struct osdata_item) <columns>: Change type to std::vector.
(DEF_VEC_O (osdata_item_s)): Remove.
(struct osdata): Add constructor.
<type>: Change type to std::string.
<items>: Change type to std::vector.
(osdata_p): Remove typedef.
(DEF_VEC_P (osdata_p)): Remove.
(osdata_parse): Return a unique_ptr.
(osdata_free): Remove.
(make_cleanup_osdata_free): Remove.
(get_osdata): Return a unique_ptr.
(get_osdata_column): Return pointer to std::string, take a
reference to osdata_item as parameter.
* osdata.c (struct osdata_parsing_data) <osdata>: Change type to
unique_ptr.
<property_name>: Change type to std::string.
(osdata_start_osdata): Allocate osdata with new and adjust.
(osdata_start_item): Adjust.
(osdata_start_column): Adjust.
(osdata_end_column): Adjust.
(clear_parsing_data): Remove.
(osdata_parse): Return a unique_ptr and adjust, remove cleanup.
(osdata_item_clear): Remove.
(get_osdata): return a unique_ptr and adjust.
(get_osdata_column): Return a pointer to std::string and adjust.
(info_osdata): Adjust.
* mi/mi-main.c: Include <map>.
(free_vector_of_osdata_items): Remove.
(list_available_thread_groups): Adjust, use std::map instead of
splay tree.
This patch replaces makes varobj_update return an std::vector, and
updates the fallouts.
To make that easier, the varobj_update_result is c++ified a bit. I
added a constructor and initialized its fields in-class. The newobj
vector is also made an std::vector, so that it's automatically freed
when varobj_update_result is destroyed and handled correctly by the
default move constructor. I disabled copy constructor and assignment
for that structure, because normally it never needs to be copied, only
moved.
As a result, the newobj parameter of update_dynamic_varobj_children must
be changed to an std::vector. The patch converts the other vector
parameters of update_dynamic_varobj_children to std::vector. It's not
strictly necessary to do it in the same patch, but I think it makes
sense to do it.
gdb/ChangeLog:
* varobj.h (struct varobj_update_result): Add constructor, add
move constructor, disable copy and assign, initialize fields.
<newobj>: Change type to std::vector.
(varobj_update): Return std::vector.
* varobj.c (install_dynamic_child): Change VEC parameters to
std::vector and adjust.
(update_dynamic_varobj_children): Likewise.
(varobj_update): Return std::vector and adjust.
* mi/mi-cmd-var.c (varobj_update_one): Adjust to vector changes.
This patch makes the children field of varobj an std::vector, and
updates the fallout.
One note is that varobj::parent must be made non-const. The reason is
that when a child deletes itself, it modifies its writes NULL to its
slot in its parent's children vector. With the VEC, the const didn't
made the parent's children vector content const, only the pointer to it,
but with std::vector, even the content is.
gdb/ChangeLog:
* varobj.h (struct varobj) <parent>: Remove const.
<children>: Change type to std::vector.
(varobj_list_children): Return std::vector const reference.
(varobj_restrict_range): Change parameter type to std::vector
const reference.
* varobj.c (varobj_has_more): Adjust.
(varobj_restrict_range): Change parameter type to std::vector
const reference and adjust.
(install_dynamic_child): Adjust.
(update_dynamic_varobj_children): Adjust.
(varobj_list_children): Return std::vector const reference and
adjust.
(varobj_add_child): Adjust.
(update_type_if_necessary): Adjust.
(varobj_update): Adjust.
(delete_variable_1): Adjust.
* ada-varobj.c (ada_value_has_mutated): Adjust.
* mi/mi-cmd-var.c (mi_cmd_var_list_children): Adjust.
This patch replaces the last usages of VEC(mem_range_s) with
std::vector<mem_range>. This allows getting rid of a few cleanups and
of the DEF_VEC_O(mem_range_s).
I added a test for normalize_mem_ranges to make sure I didn't break
anything there.
Regtested on the buildbot.
gdb/ChangeLog:
* memrange.h (struct mem_range): Define operator< and operator==.
(mem_range_s): Remove.
(DEF_VEC_O (mem_range_s)): Remove.
(normalize_mem_ranges): Change parameter type to std::vector.
* memrange.c (compare_mem_ranges): Remove.
(normalize_mem_ranges): Change parameter type to std::vector,
adjust to vector change.
* exec.c (section_table_available_memory): Return vector, remove
parameter.
(section_table_read_available_memory): Adjust to std::vector
change.
* remote.c (remote_read_bytes): Adjust to std::vector
change.
* tracepoint.h (traceframe_available_memory): Change parameter
type to std::vector.
* tracepoint.c (traceframe_available_memory): Change parameter
type to std::vector, adjust.
* gdb/mi/mi-main.c (mi_cmd_trace_frame_collected): Adjust to
std::vector change.
* gdb/Makefile.in (SUBDIR_UNITTESTS_SRCS): Add
unittests/memrange-selftests.c.
(SUBDIR_UNITTESTS_OBS): Add memrange-selftests.o.
* gdb/unittests/memrange-selftests.c: New file.
Straightforward change to get rid of a VEC. We need to new/delete
traceframe_info instead of malloc/free it. I found three places that
allocate a traceframe_info (ctf_traceframe_info, tfile_traceframe_info
and parse_traceframe_info) and only one that frees it
(free_traceframe_info).
gdb/ChangeLog:
* tracepoint.h (struct traceframe_info) <tvars>: Change type to
std::vector<int>.
* tracepoint.c (free_traceframe_info): Deallocate with delete.
(traceframe_info_start_tvar): Adjust to vector change.
(parse_traceframe_info): Allocate with new.
* ctf.c (ctf_traceframe_info): Allocate with new, adjust to
vector change.
* tracefile-tfile.c (build_traceframe_info): Adjust to vector
change.
tfile_traceframe_info): Allocate with new.
* mi/mi-main.c (mi_cmd_trace_frame_collected): Adjust to vector
change.
This patch gets rid of catch_exceptions / catch_exceptions_with_msg.
The latter is done mostly by getting rid of the three remaining
vestigial libgdb wrapper functions, which are really pointless
nowadays. This results in a good number of simplifications.
(I checked that Insight doesn't use those functions.)
The gdb.mi/mi-pthreads.exp change is necessary because this actually
fixes a bug, IMO -- the patch stops MI's -thread-select causing output
on the CLI stream.
I.e., before:
-thread-select 123456789
&"Thread ID 123456789 not known.\n"
^error,msg="Thread ID 123456789 not known."
(gdb)
After:
-thread-select 123456789
^error,msg="Thread ID 123456789 not known."
(gdb)
gdb/ChangeLog
2017-10-10 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* breakpoint.c (struct captured_breakpoint_query_args)
(do_captured_breakpoint_query, gdb_breakpoint_query): Delete.
(print_breakpoint): New.
* breakpoint.h (print_breakpoint): Declare.
* common/common-exceptions.h (enum return_reason): Remove
references to catch_exceptions.
* exceptions.c (catch_exceptions, catch_exceptions_with_msg):
Delete.
* exceptions.h (catch_exceptions_ftype, catch_exceptions)
(catch_exception_ftype, catch_exceptions_with_msg): Delete.
* gdb.h: Delete.
* gdbthread.h (thread_select): Declare.
* mi/mi-cmd-break.c: Don't include gdb.h.
(breakpoint_notify): Use print_breakpoint.
* mi/mi-cmd-catch.c: Don't include gdb.h.
* mi/mi-interp.c: Don't include gdb.h.
(mi_print_breakpoint_for_event): New.
(mi_breakpoint_created, mi_breakpoint_modified): Use
mi_print_breakpoint_for_event.
* mi/mi-main.c: Don't include gdb.h.
(mi_cmd_thread_select): Parse the global thread ID here. Use
thread_select instead of gdb_thread_select.
(mi_cmd_thread_list_ids): Output "thread-ids" tuple here instead
of using gdb_list_thread_ids.
* remote-fileio.c (do_remote_fileio_request): Change type. Reply
FILEIO_ENOSYS here.
(remote_fileio_request): Use TRY/CATCH instead of
catch_exceptions.
* symfile-mem.c (struct symbol_file_add_from_memory_args)
(symbol_file_add_from_memory_wrapper): Delete.
(add_vsyscall_page): Use TRY/CATCH instead of catch_exceptions.
* thread.c: Don't include gdb.h.
(do_captured_list_thread_ids, gdb_list_thread_ids): Delete.
(thread_alive): Use thread_select.
(do_captured_thread_select): Delete, parts salvaged as ...
(thread_select): ... this new function.
(gdb_thread_select): Delete.
gdb/testsuite/ChangeLog
2017-10-10 Pedro Alves <palves@redhat.com>
* gdb.mi/mi-pthreads.exp (check_mi_thread_command_set): Don't
expect CLI output.
One spot in gdb uses a cleanup to free a splay tree. This patch
introduces a unique_ptr specialization for this case.
ChangeLog
2017-10-09 Tom Tromey <tom@tromey.com>
* mi/mi-main.c (free_splay_tree): Remove.
(list_available_thread_groups): Use splay_tree_up.
* common/gdb_splay_tree.h: New file.
The do_nothing function in mi-main.c is used as a splay tree
key-deleting function; but NULL serves the same purpose and is used
elsewhere in gdb. This patch removes the unneeded function.
ChangeLog
2017-10-09 Tom Tromey <tom@tromey.com>
* mi/mi-main.c (do_nothing): Remove.
(list_available_thread_groups): Update.
New in v3:
- Replace use_gdb_stub with can_spawn_for_attach.
- Call kill_wait_spawned_process on spawn_ids.
Commit
Use std::set in mi-main.c
52f9abe4c7
changed the logic of the "-list-thread-groups --available" by mistake
when a pid is passed. It prints all the processes except the one
specified by the given pid. The correct behavior is to only print the
process corresponding to that pid. this patch fixes that and adds a test.
gdb/ChangeLog:
* mi/mi-main.c (list_available_thread_groups): Reverse filter logic.
gdb/testsuite/ChangeLog:
* gdb.mi/list-thread-groups-available.exp: New file.
* gdb.mi/list-thread-groups-available.c: New file.
This changes read_memory_robust to return a std::vector, allowing the
removal of free_memory_read_result_vector and associated cleanups.
This patch also changes the functions it touches to be a bit more
robust with regards to deallocation; it's perhaps possible that
read_memory_robust could have leaked in some situations.
This patch is based on my earlier series to remove some MI cleanups.
Regression tested by the buildbot.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* target.c (read_whatever_is_readable): Change type of "result".
Update.
(free_memory_read_result_vector): Remove.
(read_memory_robust): Change return type. Update.
* mi/mi-main.c (mi_cmd_data_read_memory_bytes): Update. Use
bin2hex, std::string.
* target.h (memory_read_result_s): Remove typedef.
(free_memory_read_result_vector): Remove.
(read_memory_robust): Return std::vector.
Change captured_mi_execute_command to use a scoped_restore, removing a
cleanup. The old code copied the current token, but I don't believe
that is necessary.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* mi/mi-main.c (captured_mi_execute_command): Use scope_restore.
Change ada_exceptions_list to return a std::vector and fix up the
users. This allows removing a cleanup in MI.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* mi/mi-cmd-info.c (mi_cmd_info_ada_exceptions): Update.
* ada-lang.h (struct ada_exc_info): Remove typedef. Declare
operator< and operator==.
(ada_exceptions_list): Return a std::vector.
* ada-lang.c (ada_exc_info::operator<): Rename from
compare_ada_exception_info.
(ada_exc_info::operator==): New.
(sort_remove_dups_ada_exceptions_list): Change type of
"exceptions".
(ada_add_standard_exceptions, ada_add_exceptions_from_frame)
(ada_add_global_exceptions): Likewise.
(ada_exceptions_list_1): Return a std::vector.
(ada_exceptions_list): Likewise.
Change a couple of spots in mi-main.c to use std::set. This
simplifies the code and removes some cleanups.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* mi/mi-main.c (struct print_one_inferior_data) <inferiors>: Now a
'std::set *'.
(print_one_inferior): Update.
(free_vector_of_ints): Remove.
(list_available_thread_groups): Change "ids" to std::set.
(mi_cmd_list_thread_groups): Update.
(struct collect_cores_data) <core>: Now a std::set.
(collect_cores): Update.
(unique): Remove.
(print_one_inferior): Update.
Change a couple of spots in mi-main.c to use std::string, and change
one place to use field_fmt. This removes some cleanups.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* mi/mi-main.c (mi_execute_cli_command): Use std::string.
(mi_execute_async_cli_command): Likewise.
(mi_cmd_trace_frame_collected): Use field_fmt.
This changes mi_cmd_data_write_memory_bytes to use gdb::byte_vector,
removing some cleanups.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* mi/mi-main.c (mi_cmd_data_write_memory_bytes): Use
gdb::byte_vector.
There was a leftover cleanup declaration in mi_parse. Remove it.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* mi/mi-parse.c (mi_parse): Remove unused declaration.
This string copy in mi_cmd_disassemble seems not to be needed, so
don't do it.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* mi/mi-cmd-disas.c (mi_cmd_disassemble): Don't copy "oarg".
This removes some cleanups from mi-cmd-var.c. varobj_gen_name now
returns a string, simplifying mi_cmd_var_create. In
mi_cmd_var_delete, a string copy is apparently unnecessary, so it's
simply removed.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* varobj.h (varobj_gen_name): Return std::string.
* varobj.c (varobj_gen_name): Return std::string.
* mi/mi-cmd-var.c (mi_cmd_var_create): Use std::string.
(mi_cmd_var_delete): Don't copy "name".
This changes mi_argv_to_format to return a string, allowing the
removal of some cleanups.
gdb/ChangeLog
2017-09-29 Tom Tromey <tom@tromey.com>
* mi/mi-cmd-break.c (mi_argv_to_format): Return std::string.
(mi_cmd_break_insert_1): Update.
Currently we have "current_directory" and "gdb_dirbuf" globals, which
means that we basically have two possible places to consult when we
want to know GDB's current working directory.
This is not ideal and can lead to confusion. Moreover, the way we're
using "gdb_difbuf" along with "getcwd" is problematic because we
declare the buffer with "1024" elements hardcoded, which does not take
into account longer pathnames that are possible in many filesystems.
Using "PATH_MAX" would also not be a solution because of portability
problems. Therefore, the best solution is to rely on the fact that
"getcwd (NULL, 0)" will "do the right thing" and return a
heap-allocated string containing the full path. With the new "getcwd"
module from gnulib, it is now possible to do that without worrying
about breaking some host.
With this patch "current_directory" is now the only place to check for
GDB's cwd.
Reviewed-by: Pedro Alves <palves@redhat.com>
gdb/ChangeLog:
2017-09-22 Sergio Durigan Junior <sergiodj@redhat.com>
* cli/cli-cmds.c (pwd_command): Use "getcwd (NULL, 0)".
(cd_command): Likewise. Free "current_directory" before
assigning to it.
* main.c (captured_main_1): Use "getcwd (NULL, 0)".
* mi/mi-cmd-env.c (mi_cmd_env_pwd): Likewise.
* top.c (gdb_dirbuf): Remove global declaration.
* top.h (gdb_dirbuf): Likewise.
Simply use a scoped_restore instead of manually saving and restoring
current_uiout.
gdb/ChangeLog:
* mi/mi-main.c (mi_load_progress): Restore current_uiout using a
scoped_restore.
This changes setup_breakpoint_reporting to return a scoped_restore,
allowing for some cleanup removal.
ChangeLog
2017-09-11 Tom Tromey <tom@tromey.com>
* mi/mi-cmd-catch.c (mi_cmd_catch_assert)
(mi_cmd_catch_exception, mi_catch_load_unload): Update.
* mi/mi-cmd-break.c (setup_breakpoint_reporting): Return a
scoped_restore.
(mi_cmd_break_insert_1): Update.
* mi/mi-cmd-break.h (setup_breakpoint_reporting): Return a
scoped_restore.
Change extract_arg to return a std::string and fix up all the users.
I think string is mildly better than unique_xmalloc_ptr<char>, when
possible, because it provides a more robust API.
I changed the error messages emitted from find_location_by_number to
avoid either writing to a string or an extra allocation; this can be
changed but I thought that the new message was not any less clear.
You can see an example in the testsuite patch.
ChangeLog
2017-09-11 Tom Tromey <tom@tromey.com>
* demangle.c (demangle_command): Update.
* breakpoint.c (disable_command): Update.
(enable_command): Update.
(find_location_by_number): Make "number" const. Use
get_number_trailer.
* cli/cli-utils.c (extract_arg): Return std::string.
* probe.c (parse_probe_linespec): Update. Change types.
(collect_probes): Take string arguments.
(parse_probe_linespec): Likewise.
(info_probes_for_ops): Update.
(enable_probes_command): Update.
(disable_probes_command): Update.
* break-catch-sig.c (catch_signal_split_args): Update.
* mi/mi-parse.c (mi_parse): Update.
testsuite/ChangeLog
2017-09-11 Tom Tromey <tom@tromey.com>
* gdb.base/ena-dis-br.exp (test_ena_dis_br): Update test.
This renames a few functions -- skip_spaces_const,
skip_to_space_const, get_number_const, extract_arg_const -- to drop
the "_const" suffix and instead rely on overloading.
This makes future const fixes simpler by reducing the number of lines
that must be changed. I think it is also not any less clear, as all
these functions have the same interface as their non-const versions by
design. Furthermore there's an example of using an overload in-tree
already, namely check_for_argument.
This patch was largely created using some perl one-liners; then a few
fixes were applied by hand.
ChangeLog
2017-09-11 Tom Tromey <tom@tromey.com>
* common/common-utils.h (skip_to_space): Remove macro, redeclare
as function.
(skip_to_space): Rename from skip_to_space_const.
* common/common-utils.c (skip_to_space): New function.
(skip_to_space): Rename from skip_to_space_const.
* cli/cli-utils.h (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
* cli/cli-utils.c (get_number): Rename from get_number_const.
(extract_arg): Rename from extract_arg_const.
(number_or_range_parser::get_number): Use ::get_number.
* aarch64-linux-tdep.c, ada-lang.c, arm-linux-tdep.c, ax-gdb.c,
break-catch-throw.c, breakpoint.c, cli/cli-cmds.c, cli/cli-dump.c,
cli/cli-script.c, cli/cli-setshow.c, compile/compile.c,
completer.c, demangle.c, disasm.c, findcmd.c, linespec.c,
linux-tdep.c, linux-thread-db.c, location.c, mi/mi-parse.c,
minsyms.c, nat/linux-procfs.c, printcmd.c, probe.c,
python/py-breakpoint.c, record.c, rust-exp.y, serial.c, stack.c,
stap-probe.c, tid-parse.c, tracepoint.c: Update all callers.
This changes a few spots to use ui_out_emit_list and/or
ui_out_emit_tuple with gdb::optional, to preserve existing behavior.
This allows for the removal of a few more cleanups.
ChangeLog
2017-09-09 Tom Tromey <tom@tromey.com>
* mi/mi-cmd-var.c (mi_cmd_var_list_children): Use gdb::optional,
ui_out_emit_list, ui_out_emit_tuple.
(mi_cmd_var_update): Likewise.
This patch introduces ui_out_redirect_pop. All uses of
make_cleanup_ui_out_redirect_pop are replaced with this new class.
ChangeLog
2017-09-09 Tom Tromey <tom@tromey.com>
* mi/mi-interp.c (mi_user_selected_context_changed): Use
ui_out_redirect_pop.
* guile/scm-ports.c (ioscm_with_output_to_port_worker): Use
ui_out_redirect_pop.
* utils.c (do_ui_out_redirect_pop)
(make_cleanup_ui_out_redirect_pop): Remove.
* top.c (execute_command_to_string): Use ui_out_redirect_pop.
* utils.h (make_cleanup_ui_out_redirect_pop): Remove.
* ui-out.h (ui_out_redirect_pop): New class.
This changes various spots to use ui_out_emit_list, removing some
cleanups.
ChangeLog
2017-09-09 Tom Tromey <tom@tromey.com>
* mi/mi-main.c (output_cores): Use ui_out_emit_list.
(list_available_thread_groups, mi_cmd_list_thread_groups)
(mi_cmd_data_list_changed_registers, mi_cmd_data_read_memory)
(mi_cmd_data_read_memory_bytes, mi_cmd_trace_frame_collected):
Likewise.
This changes more places to use ui_out_emit_tuple, removing cleanups.
ChangeLog
2017-09-09 Tom Tromey <tom@tromey.com>
* target.c (flash_erase_command): Use ui_out_emit_tuple.
* stack.c (print_frame): Use ui_out_emit_tuple.
* spu-tdep.c (info_spu_event_command): Use ui_out_emit_tuple.
(info_spu_mailbox_command, info_spu_dma_command)
(info_spu_proxydma_command): Likewise.
* mi/mi-main.c (mi_cmd_trace_frame_collected): Use
ui_out_emit_tuple, gdb::byte_vector, bin2hex.
* mi/mi-cmd-file.c (mi_cmd_file_list_shared_libraries): Use
ui_out_emit_tuple.
* breakpoint.c (print_it_watchpoint): Use ui_out_emit_tuple.
For some reason I ended up staring at some of the "int flags" in
btrace-related code, and I got confused because I had no clue what the
flags where supposed to indicate.
Fix that by using enum_flags, so that:
#1 - it's clear from the type what the flags are about, and
#2 - the compiler can catch mismatching mistakes
gdb/ChangeLog:
2017-09-04 Pedro Alves <palves@redhat.com>
* cli/cli-cmds.c (print_disassembly, disassemble_current_function)
(disassemble_command): Use gdb_disassembly_flags instead of bare
int.
* disasm.c (gdb_pretty_print_disassembler::pretty_print_insn)
(dump_insns, do_mixed_source_and_assembly_deprecated)
(do_mixed_source_and_assembly, do_assembly_only, gdb_disassembly):
Use gdb_disassembly_flags instead of bare int.
* disasm.h (DISASSEMBLY_SOURCE_DEPRECATED, DISASSEMBLY_RAW_INSN)
(DISASSEMBLY_OMIT_FNAME, DISASSEMBLY_FILENAME)
(DISASSEMBLY_OMIT_PC, DISASSEMBLY_SOURCE)
(DISASSEMBLY_SPECULATIVE): No longer macros. Instead they're...
(enum gdb_disassembly_flag): ... values of this new enumeration.
(gdb_disassembly_flags): Define.
(gdb_disassembly)
(gdb_pretty_print_disassembler::pretty_print_insn): Use it.
* mi/mi-cmd-disas.c (mi_cmd_disassemble): Use
gdb_disassembly_flags instead of bare int.
* record-btrace.c (btrace_insn_history)
(record_btrace_insn_history, record_btrace_insn_history_range)
(record_btrace_insn_history_from): Use gdb_disassembly_flags
instead of bare int.
* record.c (get_insn_history_modifiers, cmd_record_insn_history):
Use gdb_disassembly_flags instead of bare int.
* target-debug.h (target_debug_print_gdb_disassembly_flags):
Define.
* target-delegates.c: Regenerate.
* target.c (target_insn_history, target_insn_history_from)
(target_insn_history_range): Use gdb_disassembly_flags instead of
bare int.
* target.h: Include "disasm.h".
(struct target_ops) <to_insn_history, to_insn_history_from,
to_insn_history_range>: Use gdb_disassembly_flags instead of bare
int.
(target_insn_history, target_insn_history_from)
(target_insn_history_range): Use gdb_disassembly_flags instead of
bare int.