summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* Fix removing inferiors from within "thread apply" commandsusers/palves/thread_apply-v2Pedro Alves2017-04-137-80/+308
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch fixes an internal error exposed by a test that does something like: define kill-and-remove kill inferiors 2 remove-inferiors 2 end # Start one inferior. start # Start another inferior. add-inferior 2 inferior 2 start # Kill and remove inferior 1 while inferior 2 is selected. thread apply 1.1 kill-and-remove The internal error looks like this: Thread 1.1 (Thread 0x7ffff7fc2700 (LWP 20677)): [Switching to inferior 1 [process 20677] (gdb/testsuite/outputs/gdb.threads/threadapply/threadapply)] [Switching to thread 1.1 (Thread 0x7ffff7fc2700 (LWP 20677))] #0 main () at src/gdb/testsuite/gdb.threads/threadapply.c:38 38 for (i = 0; i < NUM; i++) src/gdb/inferior.c:66: internal-error: void set_current_inferior(inferior*): Assertion `inf != NULL' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) FAIL: gdb.threads/threadapply.exp: kill_and_remove_inferior: try kill-and-remove: thread apply 1.1 kill-and-remove (GDB internal error) There are several problems around this area of the code. One is that in do_restore_current_thread_cleanup, we do a look up of inferior by ptid, which can find the wrong inferior if the previously selected inferior exited and some other inferior was started with a reused pid (rare, but still...). The other problem is that the "remove-inferiors" command rejects attempts to remove the current inferior, but when we get to "remove-inferiors" in a "thread apply THR remove-inferiors 2" command, the current inferior is the inferior of thread THR, not the previously selected inferior, so if the previously selected inferior was inferior 2, that command still manages to wipe it, and then gdb restores the old selected inferior, which is now a dangling pointer... So the fix here is: - Make make_cleanup_restore_current_thread store a pointer to the previously selected inferior directly, and use it directly instead of doing ptid look ups. - Add a refcount to inferiors, very similar to thread_info's refcount, that is incremented/decremented by make_cleanup_restore_current_thread, and checked before deleting an inferior. To avoid duplication, a new refcounted_object type is added, that both thread_info and inferior inherit from. gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * common/refcounted-object.h: New file. * gdbthread.h: Include "common/refcounted-object.h". (thread_info): Inherit from refcounted_object and add comments. (thread_info::incref, thread_info::decref) (thread_info::m_refcount): Delete. (thread_info::deletable): Use the refcounted_object::refcount() method. * inferior.c (current_inferior_): Add comment. (set_current_inferior): Increment/decrement refcounts. (prune_inferiors, remove_inferior_command): Skip inferiors marked not-deletable instead of comparing with the current inferior. (initialize_inferiors): Increment the initial inferior's refcount. * inferior.h (struct inferior): Forward declare. Include "common/refcounted-object.h". (current_inferior, set_current_inferior): Move declaration to before struct inferior's definition, and fix comment. (inferior): Inherit from refcounted_object. Add comments. * thread.c (switch_to_thread_no_regs): Reference the thread's inferior pointer directly instead of doing a ptid lookup. (switch_to_no_thread): New function. (switch_to_thread(thread_info *)): New function, factored out from ... (switch_to_thread(ptid_t)): ... this. (restore_current_thread): Delete. (current_thread_cleanup): Remove 'inf_id' and 'was_removable' fields, and add 'inf' field. (do_restore_current_thread_cleanup): Check whether old->inf is alive instead of looking up an inferior by ptid. Use switch_to_thread and switch_to_no_thread. Assert that the current inferior matches inferior_ptid. (restore_current_thread_cleanup_dtor): Use old->inf directly instead of lookup up an inferior by id. Decref the inferior. Don't restore 'removable'. (make_cleanup_restore_current_thread): Same the inferior pointer in old, instead of the inferior number. Incref the inferior. Don't save/clear 'removable'. gdb/testsuite/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * gdb.threads/threadapply.exp (kill_and_remove_inferior): New procedure. (top level): Call it. * lib/gdb.exp (gdb_define_cmd): New procedure.
* Make inferior::detaching a bool, and introduce scoped_restore::release()Pedro Alves2017-04-135-18/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I left making inferior::detaching a bool to a separate patch, because doing that makes a make_cleanup_restore_integer call in infrun.c:prepare_for_detach no longer compile (passing a 'bool *' when an 'int *' is expected). Since we want to get rid of cleanups anyway, I looked at converting that to a scoped_restore. However, prepare_for_detach wants to discard the cleanup on success, and scoped_restore doesn't have an equivalent for that. So I added one -- I called it "release()" because it seems like a natural fit in the way standard components call similarly-spirited methods, and, it's also what the proposal for a generic scope guard calls it too, AFAICS: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4189.pdf I've added some scoped_guard unit tests, while at it. gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add unittests/scoped_restore-selftests.c. (SUBDIR_UNITTESTS_OBS): Add scoped_restore-selftests.o. * common/scoped_restore.h (scoped_restore_base): Make "class". (scoped_restore_base::release): New public method. (scoped_restore_base::scoped_restore_base): New protected ctor. (scoped_restore_base::m_saved_var): New protected field. (scoped_restore_tmpl::scoped_restore_tmpl(T*)): Initialize the scoped_restore_base base class instead of m_saved_var directly. (scoped_restore_tmpl::scoped_restore_tmpl(T*, T2)): Likewise. (scoped_restore_tmpl::scoped_restore_tmpl(const scoped_restore_tmpl<T>&)): Likewise. (scoped_restore_tmpl::~scoped_restore_tmpl): Use the saved_var method. (scoped_restore_tmpl::saved_var): New method. (scoped_restore_tmpl::m_saved_var): Delete. * inferior.h (inferior::detaching): Now a bool. * infrun.c (prepare_for_detach): Use a scoped_restore instead of a cleanup. * unittests/scoped_restore-selftests.c: New file.
* Make inferior a class with cdtors, and use new/deletePedro Alves2017-04-132-50/+52
| | | | | | | | | | | | | | | | | | | | | | | | | A following patch in this series will add a private field to struct inferior, making it a non-POD, which requires allocating/destroying inferiors with new/delete, etc. Note: this commit makes all boolean fields of inferior be "bool", except the "detaching" field. That'll require more work, so I split it to a separate patch. gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * inferior.c (free_inferior): Convert to ... (inferior::~inferior): ... this dtor. (inferior::inferior): New ctor, factored out from ... (add_inferior_silent): ... here. Allocate the inferior with a new expression. (delete_inferior): Call delete instead of free_inferior. * inferior.h (gdb_environ, continuation): Forward declare. (inferior): Now a class. Add in-class initialization to all members. Make boolean fields bool, except 'detaching'. (inferior::inferior): New explicit ctor. (inferior::~inferior): New.
* GC inferior.c:init_inferior_listPedro Alves2017-04-132-21/+0
| | | | | | | | | | | | Not used anywhere. This was actually never used. It came in because I originally created inferior.c by copying thread.c, and doing s/thread/inferior/g, and missed that nothing needs this. :-) gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * inferior.c (init_inferior_list): Delete. * inferior.h (init_inferior_list): Delete.
* Improve coverage of the PR threads/13217 regression testPedro Alves2017-04-131-1/+30
| | | | | | | | | | | | | | - Make sure we end up with no thread selected after the detach. - Test both "thread apply all" and "thread apply $some_threads", for completeness. gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> PR threads/13217 * gdb.threads/threadapply.exp (thr_apply_detach): New procedure. (top level): Call it twice, with different thread sets.
* C++fy thread_apply_all_commandPedro Alves2017-04-131-64/+73
| | | | | | | | | | | | | | | | | This eliminates a couple cleanups. gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * thread.c: Include <algorithm>. (thread_array_cleanup): Delete. (scoped_inc_dec_ref): New class. (live_threads_count): New function. (set_thread_refcount): Delete. (tp_array_compar_ascending): Now a bool. (tp_array_compar): Convert to a std::sort comparison function. (thread_apply_all_command): Use std::vector and scoped_inc_dec_ref and live_threads_count.
* Fix follow-fork latent bugPedro Alves2017-04-131-2/+3
| | | | | | | | | | | | | | A later patch in the series adds an assertion to switch_to_thread that the resulting inferior_ptid always matches the "current_inferior()" inferior. This exposed a latent bug in the follow-fork code, where we're building the fork child inferior. We're switching inferior_ptid, but not the current inferior object... gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * infrun.c (follow_fork_inferior): Also switch the current inferior.
* watch_command_1: Fix dangling frame accessPedro Alves2017-04-131-13/+21
| | | | | | | | | | | | | | | | | | | | While working on some changes to switch_to_thread, I inadvertently make switch_to_thread call reinit_frame_cache more frequently, even when the thread didn't change. This exposed a latent bug in watch_command_1, where we're referencing a frame after creating/inserting breakpoints, which potentially calls reinit_frame_cache if it needs to install breakpoints with a different thread selected. Handle this similarly to how it's already handled in other similar cases. I.e., save any frame-related information we might need before creating a breakpoint. gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> * breakpoint.c (watch_command_1): Save watchpoint-frame info before calling create_internal_breakpoint.
* struct breakpoint: Fix indentationPedro Alves2017-04-132-103/+106
| | | | | | | | | | I'm going to need to touch all these fields to add in-class initialization anyway, might as well take the opportunity to finally fix this... gdb/ChangeLog: 2017-04-13 Pedro Alves <palves@redhat.com> * breakpoint.h (struct breakpoint): Reindent.
* breakpoint.c: bp_location (the array) shadows bp_location (the type)Pedro Alves2017-04-132-66/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bp_location array has the same name as the "struct bp_location", type preventing refering to the structure without the "struct" inside breakpoint.c. I.e., we must write: "new struct bp_location;" instead of: "new bp_location" Rename the array and the associated variables/functions to avoid the shadowing. gdb/ChangeLog: 2017-04-13 Pedro Alves <palves@redhat.com> * breakpoint.c (bp_location): Rename to ... (bp_locations): ... this. All references updated. (bp_location_count): Rename to ... (bp_locations_count): ... this. All references updated. (bp_location_placed_address_before_address_max): Rename to ... (bp_locations_placed_address_before_address_max): ... this. All references updated. (bp_location_shadow_len_after_address_max): Rename to ... (bp_locations_shadow_len_after_address_max): ... this. All references updated. (bp_location_compare_addrs): Rename to ... (bp_locations_compare_addrs): ... this. All references updated. (bp_location_compare):Rename to ... (bp_locations_compare): ... this. All references updated. (bp_location_target_extensions_update): Rename to ... (bp_locations_target_extensions_update): ... this. All references updated.
* Automatic date update in version.inGDB Administrator2017-04-131-1/+1
|
* Create gdb_termios.h (and cleanup gdb/{,gdbserver/}terminal.h)Sergio Durigan Junior2017-04-1211-111/+102
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As requested, I'm sending this as a separate patch because it is ready to be included as-is. The idea here is that both gdb/terminal.h and gdb/gdbserver/terminal.h share the same code, which is responsible for setting a bunch of defines on based on the presence of termios.h and a few other headers. This simple patch just moves this common code to common/gdb_termios.h and makes the necessary adjustments on both GDB and gdbserver so that they can use this new header. It also implements the some header checks on common/common.m4. As a bonus, gdb/gdbserver/terminal.h can be removed because it's now empty. Built on x86_64, no regressions found. gdb/ChangeLog: 2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com> * Makefile.in (HFILES_NO_SRCDIR): Add "common/gdb_termios.h". * common/common.m4: Check headers 'termios.h', 'termio.h' and 'sgtty.h'. * common/gdb_termios.h: New file, with parts of "terminal.h". * inflow.c: Include "gdb_termios.h". * ser-unix.c: Include "gdb_termios.h". * terminal.h: Move terminal-related defines to "common/gdb_termios.h". gdb/gdbserver/ChangeLog: 2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com> * remote-utils.c: Include "gdb_termios.h" instead of "terminal.h". * terminal.h: Delete file.
* Change linespec_result::location to be an event_location_upTom Tromey2017-04-127-25/+34
| | | | | | | | | | | | | | | | | | | | | | 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.
* Add a constructor and destructor to linespec_resultTom Tromey2017-04-125-75/+40
| | | | | | | | | | | | | | | | | | | | | | linespec_result is only ever allocated on the stack, so it's relatively easy to convert to having a constructor and a destructor. This patch makes this change. This removes some cleanups. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * linespec.h (struct linespec_result): Add constructor and destructor. (init_linespec_result, destroy_linespec_result) (make_cleanup_destroy_linespec_result): Don't declare. * linespec.c (init_linespec_result): Remove. (linespec_result::~linespec_result): Rename from destroy_linespec_result. Update. (cleanup_linespec_result, make_cleanup_destroy_linespec_result): Remove. * breakpoint.c (create_breakpoint, break_range_command) (decode_location_default): Update. * ax-gdb.c (agent_command_1): Update.
* Change breakpoint event locations to event_location_upTom Tromey2017-04-127-49/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a follow-up to an earlier patch. It changes breakpoint's location and location_range_end members to be of type event_location_up, then fixes up the users. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * remote.c (remote_download_tracepoint): Update. * python/py-breakpoint.c (bppy_get_location): Update. * guile/scm-breakpoint.c (bpscm_print_breakpoint_smob) (gdbscm_breakpoint_location): Update. * elfread.c (elf_gnu_ifunc_resolver_return_stop): Update. * breakpoint.h (struct breakpoint) <location, location_range_end>: Change type to event_location_up. * breakpoint.c (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint) (breakpoint_event_location_empty_p, print_breakpoint_location) (print_one_breakpoint_location, create_thread_event_breakpoint) (init_breakpoint_sal, create_breakpoint) (print_recreate_ranged_breakpoint, break_range_command) (init_ada_exception_breakpoint, say_where): Update. (base_breakpoint_dtor): Don't call delete_event_location. (bkpt_print_recreate, tracepoint_print_recreate) (dprintf_print_recreate, update_static_tracepoint) (breakpoint_re_set_default): Update.
* Use std::vector in compile-loc2c.cTom Tromey2017-04-122-11/+15
| | | | | | | | | | | | This changes compile-loc2c.c to use std::vector in place of a VEC, allowing the removal of a cleanup. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * compile/compile-loc2c.c (compute_stack_depth_worker): Change type of "to_do". Update. (compute_stack_depth): Use std::vector.
* Use std::vector in find_instruction_backwardTom Tromey2017-04-122-10/+10
| | | | | | | | | | This changes find_instruction_backward to use std::vector, removing a cleanup. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * printcmd.c (find_instruction_backward): Use std::vector.
* Use std::vector in reread_symbolsTom Tromey2017-04-122-16/+10
| | | | | | | | | | This changes reread_symbols to use std::vector, removing a cleanup. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * symfile.c (objfilep): Remove typedef. (reread_symbols): Use a std::vector.
* Use scoped_restore in more placesTom Tromey2017-04-128-51/+36
| | | | | | | | | | | | | | | | | | | This changes a few more places to use scoped_restore, allowing some cleanup removals. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * mi/mi-main.c (exec_direction_forward): Remove. (exec_reverse_continue, mi_execute_command): Use scoped_restore. * guile/scm-ports.c (ioscm_with_output_to_port_worker): Use scoped_restore. * guile/guile.c (guile_repl_command, guile_command) (gdbscm_execute_gdb_command): Use scoped_restore. * go-exp.y (go_parse): Use scoped_restore. * d-exp.y (d_parse): Use scoped_restore. * cli/cli-decode.c (cmd_func): Use scoped_restore. * c-exp.y (c_parse): Use scoped_restore.
* C++ify mi_parseTom Tromey2017-04-124-43/+44
| | | | | | | | | | | | | | | | | This changes mi_parse to return a unique_ptr, and to use "new"; then fixes up the users. This allows removing one cleanup. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * mi/mi-parse.h (struct mi_parse): Add constructor, destructor. (mi_parse): Update return type. (mi_parse_free): Remove. * mi/mi-parse.c (mi_parse::mi_parse): New constructor. (mi_parse::~mi_parse): Rename from mi_parse_free. (mi_parse_cleanup): Remove. (mi_parse): Return a unique_ptr. Use new. * mi/mi-main.c (mi_execute_command): Update.
* Remove some cleanups from location.cTom Tromey2017-04-122-38/+32
| | | | | | | | | | | | This removes some more cleanups from location.c by using unique_xmalloc_ptr. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * location.c (explicit_location_lex_one): Return a unique_xmalloc_ptr. (string_to_explicit_location): Update. Remove cleanups.
* Remove some cleanups from gnu-v3-abi.cTom Tromey2017-04-122-36/+26
| | | | | | | | | | | | | | This removes some cleanups from gnu-v3-abi.c, by using std::vector rather than VEC. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * gnu-v3-abi.c (value_and_voffset_p): Remove typedef. (compare_value_and_voffset): Change type. Update. (compute_vtable_size): Change type of "offset_vec". (gnuv3_print_vtable): Use std::vector. Remove cleanups. (gnuv3_get_typeid): Remove extraneous declaration.
* Fix up wchar_iterator commentTom Tromey2017-04-122-4/+6
| | | | | | | | | | This fixes up a comment in charset.h that has been obsolete for a while. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * charset.h (wchar_iterator): Fix comment.
* Remove cleanup_iconvTom Tromey2017-04-122-16/+33
| | | | | | | | | | | | This introduces a new "iconv_wrapper" class, to be used in convert_between_encodings. This allows the removal of cleanup_iconv. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * charset.c (iconv_wrapper): New class. (cleanup_iconv): Remove. (convert_between_encodings): Use it.
* Change increment_reading_symtab to return a scoped_restoreTom Tromey2017-04-125-17/+15
| | | | | | | | | | | | | | This changes increment_reading_symtab to return a scoped_restore, then fixes up the users. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * symfile.h (increment_reading_symtab): Update type. * symfile.c (decrement_reading_symtab): Remove. (increment_reading_symtab): Return a scoped_restore_tmpl<int>. * psymtab.c (psymtab_to_symtab): Update. * dwarf2read.c (dw2_instantiate_symtab): Update.
* Introduce gdb_dlhandle_upTom Tromey2017-04-125-64/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | This introduces gdb_dlhandle_up, a unique_ptr that can close a dlopen'd library. All the functions working with dlopen handles are updated to use this new type. I did not try to build this on Windows. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * jit.c (struct jit_reader): Declare separately. Add constructor and destructor. Change type of "handle". (loaded_jit_reader): Define separately. (jit_reader_load): Update. New "new". (jit_reader_unload_command): Use "delete". * gdb-dlfcn.h (struct dlclose_deleter): New. (gdb_dlhandle_up): New typedef. (gdb_dlopen, gdb_dlsym): Update types. (gdb_dlclose): Remove. * gdb-dlfcn.c (gdb_dlopen): Return a gdb_dlhandle_up. (gdb_dlsym): Change type of "handle". (make_cleanup_dlclose): Remove. (dlclose_deleter::operator()): Rename from gdb_dlclose. * compile/compile-c-support.c (load_libcc): Update.
* Change find_pcs_for_symtab_line to return a std::vectorTom Tromey2017-04-125-30/+28
| | | | | | | | | | | | | | | This changes find_pcs_for_symtab_line to return a std::vector. This allows the removal of some cleanups. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * symtab.h (find_pcs_for_symtab_line): Change return type. * symtab.c (find_pcs_for_symtab_line): Change return type. * python/py-linetable.c (build_line_table_tuple_from_pcs): Change type of "vec". Update. (ltpy_get_pcs_for_line): Update. * linespec.c (decode_digits_ordinary): Update.
* Introduce command_line_upTom Tromey2017-04-1211-116/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces command_line_up, a unique_ptr for command_line objects, and changes many places to use it. This removes a number of cleanups. Command lines are funny in that sometimes they are reference counted. Once there is more C++-ification of some of the users, perhaps all of these can be changed to use shared_ptr instead. gdb/ChangeLog 2017-04-12 Tom Tromey <tom@tromey.com> * tracepoint.c (actions_command): Update. * python/python.c (python_command, python_interactive_command): Update. * mi/mi-cmd-break.c (mi_cmd_break_commands): Update. * guile/guile.c (guile_command): Update. * defs.h (read_command_lines, read_command_lines_1): Return command_line_up. (command_lines_deleter): New struct. (command_line_up): New typedef. * compile/compile.c (compile_code_command) (compile_print_command): Update. * cli/cli-script.h (get_command_line, copy_command_lines): Return command_line_up. (make_cleanup_free_command_lines): Remove. * cli/cli-script.c (get_command_line, read_command_lines_1) (copy_command_lines): Return command_line_up. (while_command, if_command, read_command_lines, define_command) (document_command): Update. (do_free_command_lines_cleanup, make_cleanup_free_command_lines): Remove. * breakpoint.h (breakpoint_set_commands): Change type of "commands". * breakpoint.c (breakpoint_set_commands): Change type of "commands". Update. (do_map_commands_command, update_dprintf_command_list) (create_tracepoint_from_upload): Update.
* Introduce event_location_upTom Tromey2017-04-1217-286/+202
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* gdb: Move DJGPP/go32 bits to their own tdep filePedro Alves2017-04-126-43/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | I posit that this makes them easier to find. The other day while working on the wchar_t patch, I had a bit of trouble finding the DJGPP/go32 tdep bits. My initial reaction was looking for a go32-specific tdep file, but there's none. Confirmed that a --host=i586-pc-msdosdjgpp GDB still builds successfully and includes the i386-go32-tdep.o object. Confirmed that an --enable-targets=all build of GDB on x86-64 GNU/Linux includes the DJGPP/go32 bits too. gdb/ChangeLog: 2017-04-12 Pedro Alves <palves@redhat.com> * Makefile.in (ALL_TARGET_OBS): Add i386-go32-tdep.o. * configure.tgt: Handle i[34567]86-*-go32* and i[34567]86-*-msdosdjgpp*. * i386-tdep.c (i386_svr4_reg_to_regnum): Make extern. (i386_go32_init_abi, i386_coff_osabi_sniffer): Moved to i386-go32-tdep.c. (_initialize_i386_tdep): DJGPP bits moved to i386-go32-tdep.c. * i386-go32-tdep.c: New file. * i386-tdep.h (tdesc_i386_mmx, i386_svr4_reg_to_regnum): New declarations.
* Fix build error in aix-thread.cSimon Marchi2017-04-122-1/+5
| | | | | | | | | | | | Obvious fix for: aix-thread.c: In function 'char* pd_status2str(int)': aix-thread.c:163:33: error: deprecated conversion from string constant to 'char*' [-Werror=write-strings] case PTHDB_SUCCESS: return "SUCCESS"; ^ gdb/ChangeLog: * aix-thread.c (pd_status2str): Change return type to const char *.
* Remove unnecessary set_gdbarch_gnu_triplet_regexp callsPedro Alves2017-04-122-4/+5
| | | | | | | | | | | i386_gdbarch_init already does this unconditionally for all x86 ports. Tested on x86-64 Fedora 23. gdb/ChangeLog: 2017-04-12 Pedro Alves <palves@redhat.com> * i386-tdep.c (i386_elf_init_abi, i386_go32_init_abi): Remove calls to set_gdbarch_gnu_triplet_regexp.
* Teach GDB that wchar_t is a built-in type in C++ modePedro Alves2017-04-1227-14/+220
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GDB is currently not aware that wchar_t is a built-in type in C++ mode. This is usually not a problem because the debug info describes the type, so when you have a program loaded, you don't notice this. However, if you try expressions involving wchar_t before a program is loaded, gdb errors out: (gdb) p (wchar_t)-1 No symbol table is loaded. Use the "file" command. (gdb) p L"hello" No type named wchar_t. (gdb) ptype L"hello" No type named wchar_t. This commit teaches gdb about the type. After: (gdb) p (wchar_t)-1 $1 = -1 L'\xffffffff' (gdb) p L"hello" $2 = L"hello" (gdb) ptype L"hello" type = wchar_t [6] Unlike char16_t/char32_t, unfortunately, the underlying type of wchar_t is implementation dependent, both size and signness. So this requires adding a couple new gdbarch hooks. I grepped the GCC code base for WCHAR_TYPE and WCHAR_TYPE_SIZE, and it seems to me that the majority of the ABIs have a 4-byte signed wchar_t, so that's what I made the default for GDB too. And then I looked for which ports have a 16-bit and/or unsigned wchar_t, and made GDB follow suit. gdb/ChangeLog: 2017-04-12 Pedro Alves <palves@redhat.com> PR gdb/21323 * c-lang.c (cplus_primitive_types) <cplus_primitive_type_wchar_t>: New enum value. (cplus_language_arch_info): Register cplus_primitive_type_wchar_t. * gdbtypes.h (struct builtin_type) <builtin_wchar>: New field. * gdbtypes.c (gdbtypes_post_init): Create the "wchar_t" type. * gdbarch.sh (wchar_bit, wchar_signed): New per-arch values. * gdbarch.h, gdbarch.c: Regenerate. * aarch64-tdep.c (aarch64_gdbarch_init): Override gdbarch_wchar_bit and gdbarch_wchar_signed. * alpha-tdep.c (alpha_gdbarch_init): Likewise. * arm-tdep.c (arm_gdbarch_init): Likewise. * avr-tdep.c (avr_gdbarch_init): Likewise. * h8300-tdep.c (h8300_gdbarch_init): Likewise. * i386-nto-tdep.c (i386nto_init_abi): Likewise. * i386-tdep.c (i386_go32_init_abi): Likewise. * m32r-tdep.c (m32r_gdbarch_init): Likewise. * moxie-tdep.c (moxie_gdbarch_init): Likewise. * nds32-tdep.c (nds32_gdbarch_init): Likewise. * rs6000-aix-tdep.c (rs6000_aix_init_osabi): Likewise. * sh-tdep.c (sh_gdbarch_init): Likewise. * sparc-tdep.c (sparc32_gdbarch_init): Likewise. * sparc64-tdep.c (sparc64_init_abi): Likewise. * windows-tdep.c (windows_init_abi): Likewise. * xstormy16-tdep.c (xstormy16_gdbarch_init): Likewise. gdb/testsuite/ChangeLog: 2017-04-12 Pedro Alves <palves@redhat.com> PR gdb/21323 * gdb.cp/wide_char_types.c: Include <wchar.h>. (wchar): New global. * gdb.cp/wide_char_types.exp (wide_char_types_program) (do_test_wide_char, wide_char_types_no_program, top level): Add wchar_t testing.
* Fix PR c++/21323: GDB thinks char16_t and char32_t are signed in C++Pedro Alves2017-04-127-6/+214
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While the C++ standard says that char16_t and char32_t are unsigned types: Types char16_t and char32_t denote distinct types with the same size, signedness, and alignment as uint_least16_t and uint_least32_t, respectively, in <cstdint>, called the underlying types. ... gdb treats them as signed currently: (gdb) p (char16_t)-1 $1 = -1 u'\xffff' There are actually two places in gdb that hardcode these types: - gdbtypes.c:gdbtypes_post_init, when creating the built-in types, seemingly used by the "x /s" command (judging from commit 9a22f0d0). - dwarf2read.c, when reading base types with DW_ATE_UTF encoding (which is what is used for these types, when compiling for C++11 and up). Despite the comment, the type created does end up used. Both places need fixing. But since I couldn't tell why dwarf2read.c needs to create a new type, I've made it use the per-arch built-in types instead, so that the types are only created once per arch instead of once per objfile. That seems to work fine. While writting the test, I noticed that the C++ language parser isn't actually aware of these built-in types, so if you try to use them without a program that uses them, you get: (gdb) set language c++ (gdb) ptype char16_t No symbol table is loaded. Use the "file" command. (gdb) ptype u"hello" No type named char16_t. (gdb) p u"hello" No type named char16_t. That's fixed by simply adding a couple entries to C++'s built-in types array in c-lang.c. With that, we get the expected: (gdb) ptype char16_t type = char16_t (gdb) ptype u"hello" type = char16_t [6] (gdb) p u"hello" $1 = u"hello" gdb/ChangeLog: 2017-04-12 Pedro Alves <palves@redhat.com> PR c++/21323 * c-lang.c (cplus_primitive_types) <cplus_primitive_type_char16_t, cplus_primitive_type_char32_t>: New enum values. (cplus_language_arch_info): Register cplus_primitive_type_char16_t and cplus_primitive_type_char32_t. * dwarf2read.c (read_base_type) <DW_ATE_UTF>: If bit size is 16 or 32, use the archtecture's built-in type for char16_t and char32_t, respectively. Otherwise, fallback to init_integer_type as before, but make the type unsigned, and issue a complaint. * gdbtypes.c (gdbtypes_post_init): Make char16_t and char32_t unsigned. gdb/testsuite/ChangeLog: 2017-04-12 Pedro Alves <palves@redhat.com> PR c++/21323 * gdb.cp/wide_char_types.c: New file. * gdb.cp/wide_char_types.exp: New file.
* Fix Changelog for ab0538b875c054468aa205d8d36550d1223a3bfdAlan Hayward2017-04-121-1/+1
|
* Add M32R_ARG_REGISTER_SIZEAlan Hayward2017-04-122-1/+9
| | | | | | gdb/ * m32r-tdep.c M32R_ARG_REGISTER_SIZE: Added. (m32r_push_dummy_call): Use M32R_ARG_REGISTER_SIZE.
* Fix build breakage from last commit (window-nat.c:windows_create_inferior)Sergio Durigan Junior2017-04-122-1/+6
| | | | | | | | | | | | Forgot to declare the variable 'toexec' (from window-nat.c:windows_create_inferior) as 'const char *', which caused a build breakage. gdb/ChangeLog: 2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com> * windows-nat.c (windows_create_inferior): Declare 'toexec' as 'const char *'.
* C++-fy and prepare for sharing fork_inferiorSergio Durigan Junior2017-04-1220-176/+220
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As a preparation for the next patch, which will move fork_inferior from GDB to common/ (and therefore share it with gdbserver), it is interesting to convert a few functions to C++. This patch touches functions related to parsing command-line arguments to the inferior (see gdb/fork-child.c:breakup_args), the way the arguments are stored on fork_inferior (using std::vector instead of char **), and the code responsible for dealing with argv also on gdbserver. I've taken this opportunity and decided to constify a few arguments to fork_inferior/create_inferior as well, in order to make the code cleaner. And now, on gdbserver, we're using xstrdup everywhere and aren't checking for memory allocation failures anymore, as requested by Pedro: <https://sourceware.org/ml/gdb-patches/2017-03/msg00191.html> Message-Id: <025ebdb9-90d9-d54a-c055-57ed2406b812@redhat.com> Pedro Alves wrote: > On the "== NULL" check: IIUC, the old NULL check was there to > handle strdup returning NULL due to out-of-memory. > See NULL checks and comments further above in this function. > Now that you're using a std::vector, that doesn't work or make > sense any longer, since if push_back fails to allocate space for > its internal buffer (with operator new), our operator new replacement > (common/new-op.c) calls malloc_failure, which aborts gdbserver. > > Not sure it makes sense to handle out-of-memory specially in > the gdb/rsp-facing functions nowadays (maybe git blame/log/patch > submission for that code shows some guidelines). Maybe (or, probably) > it's OK to stop caring about it, but then we should consistently remove > left over code, by using xstrdup instead and remove the NULL checks. IMO this refactoring was very good to increase the readability of the code as well, because some parts of the argument handling were unnecessarily confusing before. gdb/ChangeLog: 2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com> * common/common-utils.c (free_vector_argv): New function. * common/common-utils.h: Include <vector>. (free_vector_argv): New prototype. * darwin-nat.c (darwin_create_inferior): Rewrite function prototype in order to constify "exec_file" and accept a "std::string" for "allargs". * fork-child.c: Include <vector>. (breakup_args): Rewrite function, using C++. (fork_inferior): Rewrite function header, constify "exec_file_arg" and accept "std::string" for "allargs". Update the code to calculate "argv" based on "allargs". Update calls to "exec_fun" and "execvp". * gnu-nat.c (gnu_create_inferior): Rewrite function prototype in order to constify "exec_file" and accept a "std::string" for "allargs". * go32-nat.c (go32_create_inferior): Likewise. * inf-ptrace.c (inf_ptrace_create_inferior): Likewise. * infcmd.c (run_command_1): Constify "exec_file". Use "std::string" for inferior arguments. * inferior.h (fork_inferior): Update prototype. * linux-nat.c (linux_nat_create_inferior): Rewrite function prototype in order to constify "exec_file" and accept a "std::string" for "allargs". * nto-procfs.c (procfs_create_inferior): Likewise. * procfs.c (procfs_create_inferior): Likewise. * remote-sim.c (gdbsim_create_inferior): Likewise. * remote.c (extended_remote_run): Update code to accept "std::string" as argument. (extended_remote_create_inferior): Rewrite function prototype in order to constify "exec_file" and accept a "std::string" for "allargs". * rs6000-nat.c (super_create_inferior): Likewise. (rs6000_create_inferior): Likewise. * target.h (struct target_ops) <to_create_inferior>: Likewise. * windows-nat.c (windows_create_inferior): Likewise. gdb/gdbserver/ChangeLog: 2017-04-12 Sergio Durigan Junior <sergiodj@redhat.com> * server.c: Include <vector>. <program_argv, wrapper_argv>: Convert to std::vector. (start_inferior): Rewrite function to use C++. (handle_v_run): Likewise. Update code that calculates the argv based on the vRun packet; use C++. (captured_main): Likewise.
* Automatic date update in version.inGDB Administrator2017-04-121-1/+1
|
* Remove the extra `\n' in warning/error messagesH.J. Lu2017-04-114-9/+16
| | | | | | | * elf-properties.c (_bfd_elf_parse_gnu_properties): Remove the extra `\n' in warning/error messages. * elf32-i386.c (elf_i386_parse_gnu_properties): Likewise. * elf64-x86-64.c (elf_x86_64_parse_gnu_properties): Likewise.
* Ignore processor-specific GNU program propertiesH.J. Lu2017-04-112-1/+14
| | | | | | | | Skip processor-specific GNU program properties with generic ELF target vector. They should be handled by the matching ELF target vector. * elf-properties.c (_bfd_elf_parse_gnu_properties): Ignore processor-specific properties with generic ELF target vector.
* gdb/thread.c: Fix whitespace throughoutPedro Alves2017-04-112-31/+37
| | | | | | gdb/ChangeLog: 2017-04-11 Pedro Alves <palves@redhat.com> * thread.c: Fix whitespace throughout.
* Fix read after xfree in linux-nat.c:linux_nat_detachPhilipp Rudo2017-04-112-1/+4
| | | | | | | | | | | | | At the end of linux_nat_detach the main_lwp is deleted (delete_lwp). This is problematic as during detach (detach_one_lwp and linux_fork_detach) main_lwp already gets freed. Thus calling delete_lwp causes a read after free. Fix it by removing the unnecessary delete_lwp. gdb/ChangeLog: 2017-04-11 Philipp Rudo <prudo@linux.vnet.ibm.com> * linux-nat.c (linux_nat_detach): Remove delete_lwp call.
* Remove MAX_REGISTER_SIZE from arm-tdep.cAlan Hayward2017-04-112-1/+5
| | | | | gdb/ * arm-tdep.c (arm_store_return_value): Use FP_REGISTER_SIZE
* PR 21274, ld segfaults linking PE DLLAlan Modra2017-04-116-114/+155
| | | | | | | | | | | | | | | | | | | | | | | | Don't use fixed size buffers for symbol names. PR 21274 PR 18466 * emultempl/pe.em (pe_find_data_imports): Don't use fixed size symbol buffer. Instead, xmalloc max size needed with space for prefix. Wrap overlong lines. Formatting. Pass symbol buffer copy of name to pe_walk_relocs_of_symbol. (make_inport_fixup): Add "name" param, pass to pe_create_import_fixup. * emultempl/pe.em (pep_find_data_imports): As for pe_find_data_imports. (make_import_fixup): Add "name" param, pass to pep_create_import_fixup. Use bfd_get_signed_* and remove unnecessary casts. Formatting. * pe-dll.c (pe_walk_relocs_of_symbol): Add "name" param. Pass to callback. (make_import_fixup_mark): Add "name" param. Make use of prefix space rather than xmalloc here. (pe_create_import_fixup): Likewise. * pe-dll.h (pe_walk_relocs_of_symbol): Update prototype. (pe_create_import_fixup): Likewise. * pep-dll.h (pep_walk_relocs_of_symbol): Likewise. (pep_create_import_fixup): Likewise.
* Automatic date update in version.inGDB Administrator2017-04-111-1/+1
|
* Reorder PPC_OPCODE_* and set PPC_OPCODE_TMR for e6500Alan Modra2017-04-115-49/+55
| | | | | | | | | | | | | | PPC_OPCODE_* renumbered to fill the gaps left by previous patches, and reordered chronologically just because. I kept PPC_OPCODE_TMR because presumably it might be used in future APUinfo for e6500. include/ * opcode/ppc.h (PPC_OPCODE_*): Renumber and order chronologically. (PPC_OPCODE_SPE): Comment on this and other bits used for APUinfo. opcodes/ * ppc-dis.c (ppc_opts): Formatting. Set PPC_OPCODE_TMR for e6500. * ppc-opc.c (powerpc_opcodes <mftmr, mttmr>): Remove now unnecessary E6500.
* Bye bye PPC_OPCODE_HTM and -mhtmAlan Modra2017-04-118-17/+16
| | | | | | | | | | | | | The -mhtm option is fairly useless too. include/ * opcode/ppc.h (PPC_OPCODE_HTM): Delete. gas/ * config/tc-ppc.c (md_show_usage): Delete mention of -mhtm. * testsuite/gas/ppc/htm.d: Pass -mpower8 and -Mpower8. opcodes/ * ppc-dis.c (ppc_opts): Remove PPC_OPCODE_HTM and "htm". * ppc-opc.c (PPCHTM): Define as PPC_OPCODE_POWER8.
* Bye Bye PPC_OPCODE_VSX3Alan Modra2017-04-115-10/+9
| | | | | | | | | | | | | | | This bit is also useless as it can be replaced with PPC_OPCODE_POWER9. Defining the VSX2 and VSX3 selection based on cpu bits also lets the assembler/disassembler distinguish between the power7 VSX opcodes and the power8 ones. Note that this change means -mvsx now reverts back to just adding the power7 VSX insns. include/ * opcode/ppc.h (PPC_OPCODE_VSX3): Delete. opcodes/ * ppc-dis.c (ppc_opts): Remove PPC_OPCODE_VSX3. * ppc-opc.c (PPCVSX2): Define as PPC_OPCODE_POWER8. (PPCVSX3): Define as PPC_OPCODE_POWER9.
* Bye bye PPC_OPCODE_ALTIVEC2Alan Modra2017-04-115-10/+17
| | | | | | | | | | | | | This bit is worse than useless. Using it prevents the assembler and disassembler distinguishing between opcodes added for power8 and those added for power9. include/ * opcode/ppc.h (PPC_OPCODE_ALTIVEC2): Delete. opcodes/ * ppc-dis.c (ppc_opts): Remove PPC_OPCODE_ALTIVEC2. * ppc-opc.c (PPCVEC2): Define as PPC_OPCODE_POWER8|PPC_OPCODE_E6500. (PPCVEC3): Define as PPC_OPCODE_POWER9.