aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2020-01-24gdb: Include end of sequence markers in the line tableAndrew Burgess6-11/+61
In this commit: commit d9b3de22f33e400f7f409cce3acf6c7dab07dd79 Date: Wed May 27 14:44:29 2015 -0700 Add struct to record dwarf line number state machine. I believe an unintended change was made to how we store the DWARF line table, the end of sequence markers between sequences of lines were lost from the line table. This commit fixes this small oversight and restores the end of sequence markers. Given that we've survived this long without noticing is clearly an indication that this isn't that serious, however, a later patch that I am developing would benefit from having the markers in place, so I'd like to restore them. Having the markers also means that the output of 'maintenance info line-table' now more closely reflects the DWARF line table. I've taken this opportunity to improve how 'maintenance info line-table' displays the end of sequence markers - it now uses the END keyword, rather than just printing an entry with line number 0. So we see this: INDEX LINE ADDRESS 0 12 0x00000000004003b0 1 17 0x00000000004003b0 2 18 0x00000000004003b0 3 END 0x00000000004003b7 4 5 0x00000000004004a0 5 6 0x00000000004004a0 6 END 0x00000000004004a7 Instead of what we would have seen, which was this: INDEX LINE ADDRESS 0 12 0x00000000004003b0 1 17 0x00000000004003b0 2 18 0x00000000004003b0 3 0 0x00000000004003b7 4 5 0x00000000004004a0 5 6 0x00000000004004a0 6 0 0x00000000004004a7 I've added a small test that uses 'maintenance info line-table' to ensure that we don't regress this again. gdb/ChangeLog: * dwarf2read.c (lnp_state_machine::record_line): Include end_sequence parameter in debug print out. Record the line if we are at an end_sequence marker even if it's not the start of a statement. * symmisc.c (maintenance_print_one_line_table): Print end of sequence markers with 'END' not '0'. gdb/testsuite/ChangeLog: * gdb.base/maint.exp: Update line table parsing test. * gdb.dwarf2/dw2-ranges-base.exp: Add new line table parsing test. Change-Id: I002f872248db82a1d4fefdc6b51ff5dbf932d8a8
2020-01-24Fix re-runs of a second inferior (PR gdb/25410)Pedro Alves8-18/+265
This fixes a latent bug exposed by the multi-target patch (5b6d1e4fa "Multi-target support), and then fixes two other latent bugs exposed by fixing that first latent bug. The symptom described in the bug report is that starting a first inferior, then trying to run a second (multi-threaded) inferior twice, causes libthread_db to fail to load, along with other erratic behavior: (gdb) run Starting program: /tmp/foo warning: td_ta_new failed: generic error Going a bit deeply, I found that if the two inferiors have different symbols, we can see that just after inferior 2 exits, we are left with inferior 2 selected, which is correct, but the symbols in scope belong to inferior 1, which is obviously incorrect... This problem is that there's a path in scoped_restore_current_thread::restore() that switches to no thread selected, and switches the current inferior, but leaves the current program space as is, resulting in leaving the program space pointing to the wrong program space (the one of the other inferior). This was happening after handling TARGET_WAITKIND_NO_RESUMED, which is an event that triggers after TARGET_WAITKIND_EXITED for the previous inferior exit. Subsequent symbol lookups find the symbols of the wrong inferior. The fix is to use switch_to_inferior_no_thread in that problem spot. This function was recently added along with the multi-target work exactly for these situations. As for testing, this patch adds a new testcase that tests symbol printing just after inferior exit, which exercises the root cause of the problem more directly. And then, to cover the use case described in the bug too, it also exercises the lithread_db.so mis-loading, by using TLS printing as a proxy for being sure that threaded debugging was activated sucessfully. The testcase fails without the fix like this, for the "print symbol just after exit" bits: ... [Inferior 1 (process 8719) exited normally] (gdb) PASS: gdb.multi/multi-re-run.exp: re_run_inf=1: iter=1: continue until exit print re_run_var_1 No symbol "re_run_var_1" in current context. (gdb) FAIL: gdb.multi/multi-re-run.exp: re_run_inf=1: iter=1: print re_run_var_1 ... And like this for the "libthread_db.so loading" bits: (gdb) run Starting program: /home/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.multi/multi-re-run/multi-re-run warning: td_ta_new failed: generic error [New LWP 27001] Thread 1.1 "multi-re-run" hit Breakpoint 3, all_started () at /home/pedro/gdb/binutils-gdb/build/../src/gdb/testsuite/gdb.multi/multi-re-run.c:44 44 } (gdb) PASS: gdb.multi/multi-re-run.exp: re_run_inf=1: iter=2: running to all_started in runto print tls_var Cannot find thread-local storage for LWP 27000, executable file /home/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.multi/multi-re-run/multi-re-run: Cannot find thread-local variables on this target (gdb) FAIL: gdb.multi/multi-re-run.exp: re_run_inf=1: iter=2: print tls_var As mentioned, that fix above goes on to expose a couple other latent bugs. This commit fixes those as well. The first latent bug exposed is in infrun.c:handle_vfork_child_exec_or_exit. The current code is leaving inf->pspace == NULL while calling clone_program_space. The idea was to make it so that the breakpoints module doesn't use this inferior's pspace to set breakpoints. With that, any scoped_restore_current_thread use from within clone_program_space tries to restore a NULL program space, which hits an assertion: Attaching after Thread 0x7ffff74b8700 (LWP 27276) vfork to child process 27277] [New inferior 2 (process 27277)] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". /home/pedro/gdb/binutils-gdb/build/../src/gdb/progspace.c:243: internal-error: void set_current_program_space(program_space*): Assertion `pspace != NULL' faile d. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) FAIL: gdb.threads/vfork-follow-child-exit.exp: detach-on-fork=off: continue (GDB internal error) That NULL pspace idea was legitimate, but it's no longer necessary, since commit b2e586e850db ("Defer breakpoint reset when cloning progspace for fork child"). So the fix is to just set the inferior's program space earlier. The other latent bug exposed is in exec.c. When exec_close is called from the program_space destructor, it is purposedly called with a current program space that is not the current inferior's program space. The problem is that the multi-target work added some code to remove_target_sections that loops over all inferiors, and uses scoped_restore_current_thread to save/restore the previous thread/inferior/frame state. This makes it so that exec_close returns with the current program space set to the current inferior's program space, which is exactly what we did not want. Then the program_space destructor continues into free_all_objfiles, but it is now running that method on the wrong program space, resulting in: Reading symbols from /home/pedro/gdb/binutils-gdb/build/gdb/testsuite/outputs/gdb.threads/fork-plus-threads/fork-plus-threads... Reading symbols from /usr/lib/debug/usr/lib64/libpthread-2.26.so.debug... Reading symbols from /usr/lib/debug/usr/lib64/libm-2.26.so.debug... Reading symbols from /usr/lib/debug/usr/lib64/libc-2.26.so.debug... Reading symbols from /usr/lib/debug/usr/lib64/ld-2.26.so.debug... [Inferior 3 (process 9583) exited normally] /home/pedro/gdb/binutils-gdb/build/../src/gdb/progspace.c:170: internal-error: void program_space::free_all_objfiles(): Assertion `so->objfile == 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/fork-plus-threads.exp: detach-on-fork=off: inferior 1 exited (GDB internal error) The fix is to use scoped_restore_current_pspace_and_thread instead of scoped_restore_current_thread. gdb/ChangeLog: 2020-01-24 Pedro Alves <palves@redhat.com> PR gdb/25410 * thread.c (scoped_restore_current_thread::restore): Use switch_to_inferior_no_thread. * exec.c: Include "progspace-and-thread.h". (add_target_sections, remove_target_sections): scoped_restore_current_pspace_and_thread instead of scoped_restore_current_thread. * infrun.c (handle_vfork_child_exec_or_exit): Assign the pspace and aspace to the inferior before calling clone_program_space. Remove stale comment. gdb/testsuite/ChangeLog: 2020-01-24 Pedro Alves <palves@redhat.com> PR gdb/25410 * gdb.multi/multi-re-run-1.c: New. * gdb.multi/multi-re-run-2.c: New. * gdb.multi/multi-re-run.exp: New.
2020-01-24Add install-strip target to gdbserverHannes Domani5-1/+236
So far this was only possible indirectly when invoked from the gdb directory. This makes the install-strip target independent from gdb. 2020-01-24 Hannes Domani <ssbssa@yahoo.de> * Makefile.in (install-strip): New target. (install_sh, INSTALL_STRIP_PROGRAM, STRIP): New variables. * aclocal.m4: Regenerate. * configure: Regenerate. * configure.ac: Add AM_PROG_INSTALL_STRIP.
2020-01-24Make the class name in the definition match the declarationChristian Biesinger2-2/+9
Fixes a compile error because the class is actually called arm_netbsd_nat_target. gdb/ChangeLog: 2020-01-24 Christian Biesinger <cbiesinger@google.com> * arm-nbsd-nat.c (arm_nbsd_nat_target::fetch_registers): Rename to... (arm_netbsd_nat_target::fetch_registers): ...this. (arm_nbsd_nat_target::store_registers): Rename to... (arm_netbsd_nat_target::store_registers): ...this. Change-Id: Ibebfab9edeff48f54c32d0745afda1d74d31de92
2020-01-24Define _KERNTYPES in arm-nbsd-nat.cChristian Biesinger2-0/+7
Fixes the below compile error on ARM NetBSD 9.0_RC1 (the only version I tested). types.h does not define register_t by default. We already use this define elsewhere, notably in bsd-kvm.c. In file included from ../../gdb/arm-nbsd-nat.c:28: /usr/include/machine/frame.h:54:2: error: unknown type name 'register_t'; did you mean '__register_t'? register_t tf_spsr; ^ /usr/include/machine/types.h:77:14: note: '__register_t' declared here typedef int __register_t; ^ There are other compile errors that this does not fix. gdb/ChangeLog: 2020-01-24 Christian Biesinger <cbiesinger@google.com> * arm-nbsd-nat.c: Define _KERNTYPES to get the declaration of register_t. Change-Id: I82c21d38189ee59ea0af2538ba84b771d268722e
2020-01-24gdbserver: Make `make TAGS' actually workMaciej W. Rozycki5-38/+65
Fix a: make: *** No rule to make target '.../gdb/gdbserver/arch/arm.c', needed by 'TAGS'. Stop. error produced by `make TAGS' by making the list of sources processed match actual file locations and by moving host-specific object files listed in DEPFILES to nat/ or target/ subdirectories as appropriate so that the location of the corresponding source file can be mechanically determined. gdb/gdbserver/ * Makefile.in (SFILES): Adjust paths to point to real files. (OBS): Move waitstatus.o to target/waitstatus.o. (TAGS): Transform paths appropriately. (%.o): Rename to... (nat/%.o): ... this pattern rule. (%.o): Rename to... (target/%.o): ... this pattern rule. * configure.srv: Adjust paths throughout to include nat/ prefix with the revant files. * configure.ac: Add `nat' and `target' to CONFIG_SRC_SUBDIR. * configure: Regenerate.
2020-01-24gdbserver: Remove a stale TAGS recipe for config filesMaciej W. Rozycki2-3/+5
Complement commit 7ea814144a31 ("Fully disentangle gdb and gdbserver"), <https://sourceware.org/ml/gdb-patches/2002-02/msg00692.html> (from 2002!), and remove a recipe to include config files in `make TAGS', which are no longer used by `gdbserver' as from that commit. gdb/gdbserver/ * Makefile.in (TAGS): Remove config files from the recipe.
2020-01-24Update comments about removed functionChristian Biesinger6-6/+17
regset_from_core_section doesn't exist anymore; it has been replaced by the iterate_over_regset_sections gdbarch method. Update comments accordingly to not confuse readers. gdb/ChangeLog: 2020-01-24 Christian Biesinger <cbiesinger@google.com> * aarch64-fbsd-tdep.c (aarch64_fbsd_iterate_over_regset_sections): Update comment. * aarch64-linux-tdep.c (aarch64_linux_iterate_over_regset_sections): Likewise. * arm-fbsd-tdep.c (arm_fbsd_iterate_over_regset_sections): Likewise. * gdbcore.h (deprecated_add_core_fns): Update comment to point to the correct replacement (iterate_over_regset_sections). * riscv-fbsd-tdep.c (riscv_fbsd_iterate_over_regset_sections): Update comment. Change-Id: I5eea4d18e15edae5d6dfd5d0d6241e5b2ae40daa
2020-01-24gdb: Enable stdin on exception in execute_gdb_commandAndrew Burgess4-0/+105
This is an update of this patch: https://sourceware.org/ml/gdb-patches/2018-09/msg00884.html This patch attempts to address PR gdb/23718 by re-enabling stdin whenever an exception is caught during gdb.execute(). When Python gdb.execute() is called, an exception could occur (e.g. the target disappearing), which is then converted into a Python exception. If stdin was disabled before the exception is caught, it is not re-enabled, because the exception doesn't propagate to the top level of the event loop, whose catch block would otherwise enable it. The result is that when execution of a Python script completes, GDB does not prompt or accept input, and is effectively hung. This change rectifies the issue by re-enabling stdin in the catch block of execute_gdb_command, prior to converting the exception to a Python exception. Since this patch was originally posted I've added a test, and also I converted the code to re-enable stdin from this: SWITCH_THRU_ALL_UIS () { async_enable_stdin (); } to simply this: async_enable_stdin (); My reasoning is that we only need the SWITCH_THRU_ALL_UIS if, at the time the exception is caught, the current_ui might be different than at the time we called async_disable_stdin. Within python's execute_gdb_command I think it should be impossible to switch current_ui, so the SWITCH_THRU_ALL_UIS isn't needed. gdb/ChangeLog: PR gdb/23718 * gdb/python/python.c (execute_gdb_command): Call async_enable_stdin in catch block. gdb/testsuite/ChangeLog: PR gdb/23718 * gdb.server/server-kill-python.exp: New file. Change-Id: I1cfc36ee9f8484cc1ed82be9be338353db6bc080
2020-01-24gdb: Re-enable stdin for all UIs from start_event_loopAndrew Burgess5-1/+153
If we catch an exception in start_event_loop's call to gdb_do_one_event, then it is possible that the current_ui has changed since we called async_disable_stdin. If that's the case then calling async_enable_stdin will be called on the wrong UI. To solve this problem we wrap the call to async_enable_stdin with SWITCH_THRU_ALL_UIS, this causes us to try and re-enable stdin for all UIs, which will catch any for which we called async_disable_stdin. gdb/ChangeLog: * event-loop.c (start_event_loop): Wrap async_enable_stdin with SWITCH_THRU_ALL_UIS. gdb/testsuite/ChangeLog: * gdb.server/multi-ui-errors.c: New file. * gdb.server/multi-ui-errors.exp: New file. Change-Id: I1e18deff2e6f4e17f7a13adce3553eb001cad93b
2020-01-24gdb/tui: asm window handles invalid memory and scrolls betterAndrew Burgess6-78/+288
This started as a patch to enable the asm window to handle attempts to disassemble invalid memory, but it ended up expanding into a significant rewrite of how the asm window handles scrolling. These two things ended up being tied together as it was impossible to correctly test scrolling into invalid memory when the asm window would randomly behave weirdly while scrolling. Things that should work nicely now; scrolling to the bottom or top of the listing with PageUp, PageDown, Up Arrow, Down Arrow and we should be able to scroll past small areas of memory that don't have symbols associated with them. It should also be possible to scroll to the start of a section even if there's no symbol at the start of the section. Adding tests for this scrolling was a little bit of a problem. First I would have liked to add tests for PageUp / PageDown, but the tuiterm library we use doesn't support these commands right now due to only emulating a basic ascii terminal. Changing this to emulate a more complex terminal would require adding support for more escape sequence control codes, so I've not tried to tackle that in this patch. Next, I would have liked to test scrolling to the start or end of the assembler listing and then trying to scroll even more, however, this is a problem because in a well behaving GDB a scroll at the start/end has no effect. What we need to do is: - Move to start of assembler listing, - Send scroll up command, - Wait for all curses output, - Ensure the assembler listing is unchanged, we're still at the start of the listing. The problem is that there is no curses output, so how long do we wait at step 3? The same problem exists for scrolling to the bottom of the assembler listing. However, when scrolling down you can at least see the end coming, so I added a test for this case, however, this feels like an area of code that is massively under tested. gdb/ChangeLog: PR tui/9765 * minsyms.c (lookup_minimal_symbol_by_pc_section): Update header comment, add extra parameter, and update to store previous symbol when appropriate. * minsyms.h (lookup_minimal_symbol_by_pc_section): Update comment, add extra parameter. * tui/tui-disasm.c (tui_disassemble): Update header comment, remove unneeded parameter, add try/catch around gdb_print_insn, rewrite to add items to asm_lines vector. (tui_find_backward_disassembly_start_address): New function. (tui_find_disassembly_address): Updated throughout. (tui_disasm_window::set_contents): Update for changes to tui_disassemble. (tui_disasm_window::do_scroll_vertical): No need to adjust the number of lines to scroll. gdb/testsuite/ChangeLog: PR tui/9765 * gdb.tui/tui-layout-asm.exp: Add scrolling test for asm window. Change-Id: I323987c8fd316962c937e73c17d952ccd3cfa66c
2020-01-24gdb/tui: Prevent exceptions from trying to cross readlinePedro Alves1-3/+28
This is triggered by simply scrolling off the end of the dissasembly window. This commit doesn't fix the actual exception that is being thrown, which will still need to be fixed, but makes sure that we don't ever throw an exception out to readline. gdb/ChangeLog: yyyy-mm-dd Pedro Alves <palves@redhat.com> PR tui/9765 * tui/tui-io.c (tui_getc): Rename to ... (tui_getc_1): ... this. (tui_get): New, reimplent as try/catch wrapper around tui_getc_1. Change-Id: I2e32a401ab34404b2132ec82a3e1c17b9b723e41
2020-01-23gdb: introduce objfile text_section_offset and data_section_offset methodsSimon Marchi17-82/+135
The pattern objfile->section_offsets[SECT_OFF_TEXT (objfile)] ... appears very often, to get the offset of the text section of an objfile. I thought it would be more readable to write it as: objfile->text_section_offset () ... so I added this method and used it where possible. I also added data_section_offset, although it is not used as much. gdb/ChangeLog: * objfiles.h (ALL_OBJFILE_OSECTIONS): Move up. (SECT_OFF_DATA): Likewise. (SECT_OFF_RODATA): Likewise. (SECT_OFF_TEXT): Likewise. (SECT_OFF_BSS): Likewise. (struct objfile) <text_section_offset, data_section_offset>: New methods. * amd64-windows-tdep.c (amd64_windows_find_unwind_info): Use objfile::text_section_offset. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. * coffread.c (coff_symtab_read): Likewise. (enter_linenos): Likewise. (process_coff_symbol): Likewise. * ctfread.c (get_objfile_text_range): Likewise. * dtrace-probe.c (dtrace_probe::get_relocated_address): Use objfile::data_section_offset. * dwarf2-frame.c (execute_cfa_program): Use objfile::text_section_offset. (dwarf2_frame_find_fde): Likewise. * dwarf2read.c (create_addrmap_from_index): Likewise. (create_addrmap_from_aranges): Likewise. (dw2_find_pc_sect_compunit_symtab): Likewise. (process_psymtab_comp_unit_reader): Likewise. (add_partial_symbol): Likewise. (add_partial_subprogram): Likewise. (process_full_comp_unit): Likewise. (read_file_scope): Likewise. (read_func_scope): Likewise. (read_lexical_block_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_rnglists_process): Likewise. (dwarf2_ranges_process): Likewise. (dwarf2_ranges_read): Likewise. (dwarf_decode_lines_1): Likewise. (new_symbol): Likewise. (dwarf2_fetch_die_loc_sect_off): Likewise. (dwarf2_per_cu_text_offset): Likewise. * hppa-bsd-tdep.c (hppabsd_find_global_pointer): Likewise. * hppa-tdep.c (read_unwind_info): Likewise. * ia64-tdep.c (ia64_find_unwind_table): Likewise. * psympriv.h (struct partial_symtab): Likewise. * psymtab.c (find_pc_sect_psymtab): Likewise. * solib-svr4.c (enable_break): Likewise. * stap-probe.c (relocate_address): Use objfile::data_section_offset. * xcoffread.c (enter_line_range): Use objfile::text_section_offset. (read_xcoff_symtab): Likewise.
2020-01-23gdb: fix variable shadowing error in darwin-nat.cSimon Marchi2-2/+8
We encounter this error when building on macOS with GCC. CXX darwin-nat.o /src-local/binutils-gdb/gdb/darwin-nat.c: In member function 'ptid_t darwin_nat_target::wait_1(ptid_t, target_waitstatus*)': /src-local/binutils-gdb/gdb/darwin-nat.c:1264:18: error: declaration of 'inf' shadows a previous local [-Werror=shadow=compatible-local] for (inferior *inf : all_inferiors (this)) ^~~ /src-local/binutils-gdb/gdb/darwin-nat.c:1205:20: note: shadowed declaration is here struct inferior *inf; ^~~ Fix it by moving the declaration of `inf` in the specific scopes that need it. I think it's clearer this way anyway, as it shows that it's not the same `inf` that is used in these different scopes. Thanks to Iain Sandoe for reporting this. I did not see this error at first, because I compile with the default system compiler on macOS, which is clang. The compiler flag we try to enable for this is `-Wshadow=local`, which is not one recognized by clang. I checked to see if there would a version of the -Wshadow* warnings [1] we could enable for clang, that would catch this, but the only one that would is `-Wshadow` itself, and this is too invasive for us (which is why we enabled just -Wshadow=local in the first place). [1] https://clang.llvm.org/docs/DiagnosticsReference.html#wshadow gdb/ChangeLog: * darwin-nat.c (darwin_nat_target::wait_1): Move `inf` declaration to narrower scopes.
2020-01-23gdb: fix darwin-nat.c build / adapt to multi-targetSimon Marchi5-109/+160
The darwin-nat.c file doesn't build since the multi-target changes (5b6d1e4f, "Multi-target support"). This patch makes it build. I have access to a macOS vm, so I am able to build it, but I wasn't able to successfully codesign it and try to actually debug something, so I don't know if it works. I don't have much more time to put on this to figure it out, so I thought I'd sent the patch anyway, as it's at least a step in the right direction. The bulk of the patch is to change a bunch of functions to be methods of the darwin_nat_target object, so that this can pass `this` to find_inferior_ptid and other functions that now require a process_stratum_target pointer. The darwin_ptrace_him function (renamed to darwin_nat_target::ptrace_him in this patch) is passed to fork_inferior as the `init_trace_fun` parameter. Since the method can't be passed as a plain function pointer (we need the `this` pointer), I changed the `init_trace_fun` parameter of fork_inferior to be a gdb::function_view, so we can pass a lambda and capture `this`. The changes in darwin-nat.h are only to move definition higher in the file, so that forward declarations are not needed. gdb/ChangeLog: * darwin-nat.h (struct darwin_exception_msg, enum darwin_msg_state, struct darwin_thread_info, darwin_thread_t): Move up. (class darwin_nat_target) <wait_1, check_new_threads, decode_exception_message, decode_message, stop_inferior, init_thread_list, ptrace_him, cancel_breakpoint>: Declare. * darwin-nat.c (darwin_check_new_threads): Rename to... (darwin_nat_target::check_new_threads): ... this. (darwin_suspend_inferior_it): Remove. (darwin_decode_exception_message): Rename to... (darwin_nat_target::decode_exception_message): ... this. (darwin_nat_target::resume): Pass target to find_inferior_ptid. (darwin_decode_message): Rename to... (darwin_nat_target::decode_message): ... this. (cancel_breakpoint): Rename to... (darwin_nat_target::cancel_breakpoint): ... this. (darwin_wait): Rename to... (darwin_nat_target::wait_1): ... this. Use range-based for loop instead of iterate_over_inferiors. (darwin_nat_target::wait): Call wait_1 instead of darwin_wait. (darwin_stop_inferior): Rename to... (darwin_nat_target::stop_inferior): ... this. (darwin_nat_target::kill): Call wait_1 instead of darwin_wait. (darwin_init_thread_list): Rename to... (darwin_nat_target::init_thread_list): ... this. (darwin_ptrace_him): Rename to... (darwin_nat_target::ptrace_him): ... this. (darwin_nat_target::create_inferior): Pass lambda function to fork_inferior. (darwin_nat_target::detach): Call stop_inferior instead of darwin_stop_inferior. * fork-inferior.h (fork_inferior): Change init_trace_fun parameter to gdb::function_view. * fork-inferior.c (fork_inferior): Likewise.
2020-01-23Cache the text section offset of shared librariesHannes Domani5-7/+27
Each time a dll is loaded, update_solib_list is called. This in turn calls deep down xfer_partial -> windows_xfer_shared_libraries, which calls windows_xfer_shared_library for each loaded dll, and pe_text_section_offset reads the dll for the text section offset. Also if the data provided by xfer_partial is bigger than 4K, then all of this is done for each 4K chunk (see target_read_alloc_1). Caching of the text section offset improves the startup time of an application with >300 dynamically loaded plugins from 2m10s to 10s. And the shutdown time improves from 2m to 2s. gdb/ChangeLog: 2020-01-23 Hannes Domani <ssbssa@yahoo.de> * i386-cygwin-tdep.c (core_process_module_section): Update. * windows-nat.c (struct lm_info_windows): Add text_offset. (windows_xfer_shared_libraries): Update. * windows-tdep.c (windows_xfer_shared_library): Add text_offset_cached argument. * windows-tdep.h (windows_xfer_shared_library): Update.
2020-01-21gdb: add declaration for _initialize_gdbarch in gdbarch.shSimon Marchi2-1/+6
In commit gdb: add back declarations for _initialize functions 6c2659886f7018fcca26ee0fc813bc9748fb8513 I wrongfully edited gdbarch.c, instead of editing gdbarch.sh and re-generating gdbarch.c. This patch fixes gdbarch.sh to add a declaration for _initialize_gdbarch. gdbarch.c is not changed, as the output of gdbarch.sh now matches the current state of gdbarch.c. gdb/ChangeLog: * gdbarch.sh: Add declaration for _initialize_gdbarch.
2020-01-21gdb: remove uses of iterate_over_inferiors in remote-sim.cSimon Marchi2-50/+38
This removes the two uses of iterate_over_inferiors, in favor of range-based loops. gdb/ChangeLog: * remote-sim.c (check_for_duplicate_sim_descriptor): Remove. (get_sim_inferior_data): Remove use of iterate_over_inferiors, replace with range-based for. (gdbsim_interrupt_inferior): Remove. (gdbsim_target::interrupt): Replace iterate_over_inferiors use with a range-based for. Inline code from gdbsim_interrupt_inferior.
2020-01-21gdb: fix indentation in infrun.cSimon Marchi2-37/+41
I noticed the indentation there was off, this patch fixes it. gdb/ChangeLog: * infrun.c (proceed): Fix indentation.
2020-01-21Allow use of Pygments to colorize source codeTom Tromey8-4/+150
While GNU Source Highlight is good, it's also difficult to build and distribute. For one thing, it needs Boost. For another, it has an unusual configuration and installation setup. Pygments, a Python library, doesn't suffer from these issues, and so I thought it would be a reasonable fallback. This patch implements this idea. GNU Source Highlight is preferred, but if it is unavailable (or fails), the extension languages are tried. This patch also implements support for Pygments. Something similar could be done for Guile, using: https://dthompson.us/projects/guile-syntax-highlight.html However, I don't know enough about Guile internals to make this happen, so I have not done it here. gdb/ChangeLog 2020-01-21 Tom Tromey <tromey@adacore.com> * source-cache.c (source_cache::ensure): Call ext_lang_colorize. * python/python.c (python_extension_ops): Update. (gdbpy_colorize): New function. * python/lib/gdb/__init__.py (colorize): New function. * extension.h (ext_lang_colorize): Declare. * extension.c (ext_lang_colorize): New function. * extension-priv.h (struct extension_language_ops) <colorize>: New member. * cli/cli-style.c (_initialize_cli_style): Update help text. Change-Id: I5e21623ee05f1f66baaa6deaeca78b578c031bf4
2020-01-21Convert an int flag variable to boolLuis Machado2-4/+12
As suggested, the cond variable is really supposed to be a bool. So, make it so. gdb/ChangeLog: 2020-01-21 Luis Machado <luis.machado@linaro.org> * aarch64-tdep.c (struct aarch64_displaced_step_closure) <cond>: Change type to bool. (aarch64_displaced_step_b_cond): Update cond to use bool type. (aarch64_displaced_step_cb): Likewise. (aarch64_displaced_step_tb): Likewise.
2020-01-21Add more debugging output to aarch64_displaced_step_fixupLuis Machado2-2/+30
While debugging the step-over-syscall problem, i wanted to see a bit more debugging output to try to determine the root cause. This patch does this. gdb/ChangeLog: 2020-01-21 Luis Machado <luis.machado@linaro.org> * aarch64-tdep.c (aarch64_displaced_step_fixup): Add more debugging output.
2020-01-21Fix step-over-syscall.exp failureLuis Machado2-4/+20
In particular, this one: FAIL: gdb.base/step-over-syscall.exp: fork: displaced=on: check_pc_after_cross_syscall: single step over fork final pc When ptrace fork event reporting is enabled, GDB gets a PTRACE_EVENT_FORK event whenever the inferior executes the fork syscall. Then the logic is that GDB needs to step the inferior yet again in order to receive a predetermined SIGTRAP, but no execution takes place because the signal was already queued for delivery. That means the PC should stay the same. I noticed the aarch64 code is currently adjusting the PC in this situation, making the inferior skip an instruction without executing it. The following change checks if we did not execute the instruction (pc - to == 0), making proper adjustments for such case. Regression tested on aarch64-linux-gnu on the tryserver. gdb/ChangeLog: 2020-01-21 Luis Machado <luis.machado@linaro.org> * aarch64-tdep.c (struct aarch64_displaced_step_closure ) <pc_adjust>: Adjust the documentation. (aarch64_displaced_step_fixup): Check if PC really moved before adjusting it.
2020-01-19sim: don't rely on inferior_ptid in gdbsim_target::waitSimon Marchi1-1/+1
When running a program with the simulator target, I get: /home/simark/src/binutils-gdb/gdb/inferior.c:279: internal-error: inferior* find_inferior_pid(process_stratum_target*, int): Assertion `pid != 0' failed. This can be reproduced by building a GDB for --target=arm-none-gnueabi, and running with $ ./gdb -nx --data-directory=data-directory a.out -ex "target sim" -ex load -ex "b main" -ex r Where a.out is any program with a main. The problem is that gdbsim_target::wait assumes that inferior_ptid has the value of the thread it wants to report an event for. Actually, it's the target's responsibility to come up with the ptid of the thread the event is for. In the sim target, that ptid is stored in sim_inferior_data::remote_sim_ptid, so return that instead of inferior_ptid. ChangeLog: * remote-sim.c (gdbsim_target::wait): Return sim_data->remote_sim_ptid instead of inferior_ptid.
2020-01-19Call disassemble_free_target in gdbTom Tromey3-1/+19
Commit 20135676fc4c3912297c313b3e0d3cbd6cc402e3 ("PR24960, Memory leak from disassembler") added "disassemble_free_target" to opcodes. This is used to free target-specific data when finished with a disassembler. This patch changes gdb to call this function where needed. gdb/ChangeLog 2020-01-19 Tom Tromey <tom@tromey.com> * disasm.c (~gdb_disassembler): New destructor. (gdb_buffered_insn_length): Call disassemble_free_target. * disasm.h (class gdb_disassembler): Declare destructor. Use DISABLE_COPY_AND_ASSIGN. Change-Id: I245ba5b7dec5e5d9f29cd21832c6e2b4fecef047
2020-01-19Replace init_cutu_and_read_dies with a classTom Tromey2-323/+267
init_cutu_and_read_dies takes a callback function, which I've always found somewhat difficult to follow. This patch replaces this function with a class, and changes the callers to use it. In some cases this allows for the removal of a helper struct and helper function as well. gdb/ChangeLog 2020-01-19 Tom Tromey <tom@tromey.com> * dwarf2read.c (abbrev_table_up): Move typedef earlier. (die_reader_func_ftype): Remove. (cutu_reader): New class. (dw2_get_file_names_reader): Remove "data" parameter. (dw2_get_file_names): Use cutu_reader. (create_debug_type_hash_table): Update. (read_cutu_die_from_dwo): Update comment. (lookup_dwo_unit): Add dwo_name parameter. (cutu_reader::init_tu_and_read_dwo_dies): Now a method. Remove die_reader_func_ftype and data parameters. (cutu_reader::cutu_reader): Rename from init_cutu_and_read_dies. Remove die_reader_func_ftype and data parameters. (~cutu_reader): New; from init_cutu_and_read_dies. (cutu_reader::cutu_reader): Rename from init_cutu_and_read_dies_no_follow. Remove die_reader_func_ftype and data parameters. (init_cutu_and_read_dies_simple): Remove. (struct process_psymtab_comp_unit_data): Remove. (process_psymtab_comp_unit_reader): Remove data parameter; add want_partial_unit and pretend_language parameters. (process_psymtab_comp_unit): Use cutu_reader. (build_type_psymtabs_reader): Remove data parameter. (build_type_psymtabs_1): Use cutu_reader. (process_skeletonless_type_unit): Likewise. (load_partial_comp_unit_reader): Remove. (load_partial_comp_unit): Use cutu_reader. (load_full_comp_unit_reader): Remove. (load_full_comp_unit): Use cutu_reader. (struct create_dwo_cu_data): Remove. (create_dwo_cu_reader): Remove datap parameter; add dwo_file and dwo_unit parameters. (create_cus_hash_table): Use cutu_reader. (struct dwarf2_read_addr_index_data): Remove. (dwarf2_read_addr_index_reader): Remove. (dwarf2_read_addr_index): Use cutu_reader. (read_signatured_type_reader): Remove. (read_signatured_type): Use cutu_reader. Change-Id: I4ef2f29e73108ce94bfe97799f8f638ed272212d
2020-01-19Remove flickering from the TUITom Tromey9-5/+116
In some cases, the TUI flickers when redrawing. This can be seen mostly easily when switching layouts. This patch fixes the problem by exploiting the double buffering that curses already does. In some spots, the TUI will now disable flushing the curses buffers to the screen; and then flush them all at once when the rendering is complete. gdb/ChangeLog 2020-01-19 Tom Tromey <tom@tromey.com> * tui/tui.c (tui_show_assembly): Use tui_suppress_output. * tui/tui-wingeneral.h (class tui_suppress_output): New. (tui_wrefresh): Declare. * tui/tui-wingeneral.c (suppress_output): New global. (tui_suppress_output, ~tui_suppress_output): New constructor and destructor. (tui_wrefresh): New function. (tui_gen_win_info::refresh_window): Use tui_wrefresh. (tui_gen_win_info::make_window): Call wnoutrefresh when needed. * tui/tui-regs.h (struct tui_data_window) <no_refresh>: Declare method. * tui/tui-regs.c (tui_data_window::erase_data_content): Call tui_wrefresh. (tui_data_window::no_refresh): New method. (tui_data_item_window::refresh_window): Call tui_wrefresh. (tui_reg_command): Use tui_suppress_output * tui/tui-layout.c (tui_set_layout): Use tui_suppress_output. * tui/tui-data.h (struct tui_gen_win_info) <no_refresh>: New method. * tui/tui-command.c (tui_refresh_cmd_win): Call tui_wrefresh. Change-Id: Icb832ae100b861de3af3307488e636fa928d5c9f
2020-01-19Make "file" clear TUI source windowTom Tromey4-5/+22
I noticed that a plain "file" will leave the current source file in the TUI source window. Instead, I think, it should clear the source window. This patch implements this. gdb/ChangeLog 2020-01-19 Tom Tromey <tom@tromey.com> * tui/tui-winsource.c (tui_update_source_windows_with_line): Handle case where symtab is null. gdb/testsuite/ChangeLog 2020-01-19 Tom Tromey <tom@tromey.com> * gdb.tui/main.exp: Add check for plain "file". Change-Id: I8424acf837f1a47f75bc6a833d1e917d4c10b51e
2020-01-19gdb/linux-fork: simplify one_fork_pSimon Marchi2-2/+5
Unless I'm missing something, this function is a complicated way of saying "fork_list.size () == 1". gdb/ChangeLog: * linux-fork.c (one_fork_p): Simplify.
2020-01-17gdb: remove uses of iterate_over_inferiors in top.cSimon Marchi2-32/+28
Replace with range-based for loops. gdb/ChangeLog: * top.c (struct qt_args): Remove. (kill_or_detach): Change return type to void, replace `void *` parameter with a proper one. (print_inferior_quit_action): Likewise. (quit_confirm): Use range-based for loop to iterate over inferiors. (quit_force): Likewise.
2020-01-17gdb: remove uses of iterate_over_inferiors in mi/mi-main.cSimon Marchi2-46/+40
Replace with range-based loops. gdb/ChangeLog: * mi/mi-main.c (run_one_inferior): Change return type to void, replace `void *` parameter with proper parameters. (mi_cmd_exec_run): Use range-based loop to iterate over inferiors. (print_one_inferior): Change return type to void, replace `void *` parameter with proper parameters. (mi_cmd_list_thread_groups): Use range-based loop to iterate over inferiors. (get_other_inferior): Remove. (mi_cmd_remove_inferior): Use range-based loop to iterate over inferiors.
2020-01-17gdb: remove use of iterate_over_inferiors in mi/mi-interp.cSimon Marchi2-28/+26
Replace it with a range-based for. I've updated the comment in mi_interp::init, which was a bit stale. gdb/ChangeLog: * mi/mi-interp.c (report_initial_inferior): Remove. (mi_interp::init): Use range-based for to iterate over inferiors.
2020-01-17gdb: remove use of iterate_over_inferiors in py-inferior.cSimon Marchi2-14/+15
Use range-based for instead of iterate_over_inferiors in one spot in the Python code. gdb/ChangeLog: * python/py-inferior.c (build_inferior_list): Remove. (gdbpy_ref): Use range-based for loop to iterate over inferiors.
2020-01-16Fix some spelling errors.Christian Biesinger8-7/+20
I noticed those from a lintian run: https://salsa.debian.org/cbiesinger-guest/gdb/-/jobs/514119 gdb/ChangeLog: 2020-01-16 Christian Biesinger <cbiesinger@google.com> * btrace.c (btrace_compute_ftrace_1): Fix spelling error (Unkown). (btrace_stitch_trace): Likewise. * charset.c (intermediate_encoding): Likewise (vaild). * nat/linux-btrace.c (linux_read_pt): Likewise (Unkown). * python/py-record-btrace.c (struct PyMethodDef): Likewise (occurences). * record-btrace.c (record_btrace_print_conf): Likewise (unkown). gdb/testsuite/ChangeLog: 2020-01-16 Christian Biesinger <cbiesinger@google.com> * lib/gdb.exp: Fix spelling error (seperatelly). Change-Id: I2a44936bac295020f217fb6c78b99b0a8d09cf9a
2020-01-16Add type for $_tlb->process_environment_block->process_parametersHannes Domani2-1/+65
The type then looks like this: (gdb) pt $_tlb->process_environment_block->process_parameters type = struct rtl_user_process_parameters { DWORD32 maximum_length; DWORD32 length; DWORD32 flags; DWORD32 debug_flags; void *console_handle; DWORD32 console_flags; void *standard_input; void *standard_output; void *standard_error; unicode_string current_directory; void *current_directory_handle; unicode_string dll_path; unicode_string image_path_name; unicode_string command_line; void *environment; DWORD32 starting_x; DWORD32 starting_y; DWORD32 count_x; DWORD32 count_y; DWORD32 count_chars_x; DWORD32 count_chars_y; DWORD32 fill_attribute; DWORD32 window_flags; DWORD32 show_window_flags; unicode_string window_title; unicode_string desktop_info; unicode_string shell_info; unicode_string runtime_data; } * It's mainly useful to get the current directory, or the full command line: (gdb) p $_tlb->process_environment_block->process_parameters->current_directory $1 = { length = 26, maximum_length = 520, buffer = 0xe36c8 L"C:\\src\\tests\\" } (gdb) p $_tlb->process_environment_block->process_parameters->command_line $2 = { length = 94, maximum_length = 96, buffer = 0xe32aa L"\"C:\\gdb\\build64\\gdb-git\\gdb\\gdb.exe\" access.exe" } The type names are all lowercase because the existing types created by windows_get_tlb_type are also lowercase. Type unicode_string is documented at [1]. The official documentation [2] for rtl_user_process_parameters is limited, so I've used this other page [3]. [1] https://docs.microsoft.com/en-us/windows/win32/api/ntdef/ns-ntdef-_unicode_string [2] https://docs.microsoft.com/en-us/windows/win32/api/winternl/ns-winternl-rtl_user_process_parameters [3] https://www.nirsoft.net/kernel_struct/vista/RTL_USER_PROCESS_PARAMETERS.html gdb/ChangeLog: 2020-01-16 Hannes Domani <ssbssa@yahoo.de> * windows-tdep.c (windows_get_tlb_type): Add rtl_user_process_parameters type.
2020-01-16Ensure proc-service symbols have default visibility (PR build/24805)Pedro Alves1-0/+11
Compiling GDB with '-fvisibility=hidden' removes the symbols that should be exported. This patch explicitly marks them as visible. gdb/ChangeLog: 2020-01-16 Pedro Alves <palves@redhat.com> Norbert Lange <nolange79@gmail.com> PR build/24805 * gdbsupport/gdb_proc_service.h (PS_EXPORT): New. (ps_get_thread_area, ps_getpid, ps_lcontinue, ps_lgetfpregs) (ps_lgetregs, ps_lsetfpregs, ps_lsetregs, ps_lstop, ps_pcontinue) (ps_pdread, ps_pdwrite, ps_pglobal_lookup, ps_pstop, ps_ptread) (ps_ptwrite, ps_lgetxregs, ps_lgetxregsize, ps_lsetxregs) (ps_plog): Redeclare exported functions with default visibility.
2020-01-16[gdb] Move ChangeLog entries to their right filesPedro Alves29-314/+453
I spotted a few misplaced entries in the ChangeLog-2019 entries, and went on to fix them. Looking around I saw a good number of other entries in other years. Then OCD got the best of me and I fixed them all. Also fixes cases of wrong paths in entries, like "* gdb/foo.c" instead of "* foo.c".
2020-01-16Support for DWARF5 location lists entriesNitika Achra2-0/+44
This patch handles DW_LLE_base_addressx, DW_LLE_startx_length and DW_LLE_start_length. Tested by running the testsuite before and after the patch and there is no increase in the number of test cases that fails. Tested with both -gdwarf-4 and -gdwarf-5 flags. Also tested -gslit-dwarf along with -gdwarf-4 as well as -gdwarf5 flags. This is an effort to support DWARF5 in gdb. gdb/ChangeLog: * dwarf2loc.c (decode_debug_loclists_addresses): Handle DW_LLE_base_addressx, DW_LLE_startx_length, DW_LLE_start_length.
2020-01-15Use get_thread_regcache instead of get_current_regcache in post_create_inferiorSimon Marchi2-1/+7
In post_create_inferior, we get the current thread using the inferior_thread function and store it in `thr`. We then call get_current_regcache immediately after, which does: return get_thread_regcache (inferior_thread ()); This patch makes post_create_inferior use get_thread_regcache, passing `thr`, saving an unnecessary inferior_thread call. gdb/ChangeLog: * infcmd.c (post_create_inferior): Use get_thread_regcache instead of get_current_regcache.
2020-01-14Fix valgrind error from gdb.decode_lineTom Tromey4-0/+25
PR symtab/12535 points out that gdb.decode_line("") will cause a valgrind report. I think the empty linespec does not really make sense. So, this patch changes gdb.decode_line to treat a whitespace-only linespec the same as a non-existing argument. gdb/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> PR symtab/12535: * python/python.c (gdbpy_decode_line): Treat empty string the same as no argument. gdb/testsuite/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> PR symtab/12535: * gdb.python/python.exp: Test decode_line with empty string argument. Change-Id: I1d95812b4b7a21d69a3e9afd05b9e3141a931897
2020-01-14Don't link gdb twice against libibertyTom Tromey2-1/+5
I noticed that gdb includes libiberty twice in its link line. I don't think there's a need for this, so this patch removes one of the references. gdb/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * Makefile.in (CLIBS): Remove second use of $(LIBIBERTY). Change-Id: I43bb7100660867081f937c67ea70ff751c62bbfb
2020-01-14Remove use of <config.h> from gdb/nat/Tom Tromey4-24/+6
This removes the use of <config.h> from the files in gdb/nat/. gdb/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * nat/linux-btrace.c: Don't include <config.h>. * nat/linux-ptrace.c: Don't include <config.h>. * nat/x86-linux-dregs.c: Don't include <config.h>. Change-Id: Ie8c734c54ada848aa020c77ec727704d367eff81
2020-01-14Move many configure checks to common.m4Tom Tromey8-1974/+3232
This moves many needed configure checks from gdb and gdbserver into common.m4. This helps gdbsupport, nat, and target be self-contained. The result is a bit spaghetti-ish, because gdbsupport uses another m4 file from gdb/. The resulting code is somewhat non-obvious. However, these problems already exist, so it's not really that much worse than what is already done. gdb/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Move many checks to ../gdbsupport/common.m4. gdb/gdbserver/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Remove any checks that were added to common.m4. * acinclude.m4: Include lib-ld.m4, lib-prefix.m4, and lib-link.m4. gdbsupport/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * configure, Makefile.in, aclocal.m4, common.m4, config.in: Rebuild. * common.m4 (GDB_AC_COMMON): Move many checks from gdb/configure.ac. * acinclude.m4: Include bfd.m4, ptrace.m4. Change-Id: I931eaa94065df268b30a2f1354390710df89c7f8
2020-01-14Move gdbsupport to the top levelTom Tromey130-15301/+135
This patch moves the gdbsupport directory to the top level. This is the next step in the ongoing project to move gdbserver to the top level. The bulk of this patch was created by "git mv gdb/gdbsupport gdbsupport". This patch then adds a build system to gdbsupport and wires it into the top level. Then it changes gdb to use the top-level build. gdbserver, on the other hand, is not yet changed. It still does its own build of gdbsupport. ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * src-release.sh (GDB_SUPPORT_DIRS): Add gdbsupport. * MAINTAINERS: Add gdbsupport. * configure: Rebuild. * configure.ac (configdirs): Add gdbsupport. * gdbsupport: New directory, move from gdb/gdbsupport. * Makefile.def (host_modules, dependencies): Add gnulib. * Makefile.in: Rebuild. gdb/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * nat/x86-linux-dregs.c: Include configh.h. * nat/linux-ptrace.c: Include configh.h. * nat/linux-btrace.c: Include configh.h. * defs.h: Include config.h, bfd.h. * configure.ac: Don't source common.host. (CONFIG_OBS, CONFIG_SRCS): Remove gdbsupport files. * configure: Rebuild. * acinclude.m4: Update path. * Makefile.in (SUPPORT, LIBSUPPORT, INCSUPPORT): New variables. (CONFIG_SRC_SUBDIR): Remove gdbsupport. (INTERNAL_CFLAGS_BASE): Add INCSUPPORT. (CLIBS): Add LIBSUPPORT. (CDEPS): Likewise. (COMMON_SFILES): Remove gdbsupport files. (HFILES_NO_SRCDIR): Likewise. (stamp-version): Update path to create-version.sh. (ALLDEPFILES): Remove gdbsupport files. gdb/gdbserver/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * server.h: Include config.h. * gdbreplay.c: Include config.h. * configure: Rebuild. * configure.ac: Don't source common.host. * acinclude.m4: Update path. * Makefile.in (INCSUPPORT): New variable. (INCLUDE_CFLAGS): Add INCSUPPORT. (SFILES): Update paths. (version-generated.c): Update path to create-version.sh. (gdbsupport/%-ipa.o, gdbsupport/%.o): Update paths. gdbsupport/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * common-defs.h: Add GDBSERVER case. Update includes. * acinclude.m4, aclocal.m4, config.in, configure, configure.ac, Makefile.am, Makefile.in, README: New files. * Moved from ../gdb/gdbsupport/ Change-Id: I07632e7798635c1bab389bf885971e584fb4bb78
2020-01-14Consolidate definition of USE_WIN32APITom Tromey7-37/+55
I noticed that USE_WIN32API is defined separately by gdbserver and gdb. However, because it is used by code in gdbsupport, it should be defined by common.m4. This approach ensures that the code will continue to work when it is moved to the top level. gdb/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * gdbsupport/common.m4 (GDB_AC_COMMON): Define WIN32APILIBS and USE_WIN32API when needed. * configure.ac (USE_WIN32API): Don't define. (WIN32LIBS): Use WIN32APILIBS. * configure: Rebuild. gdb/gdbserver/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * configure.ac (LIBS): Use WIN32APILIBS. (USE_WIN32API): Don't define. * configure: Rebuild. Change-Id: I40d524d5445ebfb452b36f4d0e102f0b1e1089df
2020-01-14Fix indentation in common.m4Tom Tromey5-16/+25
Simon pointed out that the indentation in common.m4 is off. This patch fixes the problem. gdb/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * configure: Rebuild. * gdbsupport/common.m4 (GDB_AC_COMMON): Fix indentation. gdb/gdbserver/ChangeLog 2020-01-14 Tom Tromey <tom@tromey.com> * configure: Rebuild. Change-Id: I6a629bd5873cca95ba3e17656f0d0ce583a08361
2020-01-14Make skip without argument skip the current inline functionBernd Edlinger4-10/+30
Previously always the outermost function block was used, but since skip is now able to skip over inline functions it is more natural to skip the inline function that the program is currently executing. gdb: 2020-01-14 Bernd Edlinger <bernd.edlinger@hotmail.de> * skip.c (skip_function_command): Make skip w/o arguments use the name of the inlined function if pc is inside any inlined function. gdb/testsuite: 2020-01-14 Bernd Edlinger <bernd.edlinger@hotmail.de> * gdb.base/skip-inline.exp: Extend test.
2020-01-14Fix/Update misc commentsLuis Machado5-15/+24
While doing some investigation of mine, i noticed a few typos, inaccuracies and missing information. I went ahead and updated/improved those. gdb/ChangeLog: 2020-01-14 Luis Machado <luis.machado@linaro.org> * inf-ptrace.c (inf_ptrace_target::resume): Update comments. * infrun.c (resume_1): Likewise. (handle_inferior_event): Remove stale comment. * linux-nat.c (linux_nat_target::resume): Update comments. (save_stop_reason): Likewise. (linux_nat_filter_event): Likewise. * linux-nat.h (struct lwp_info) <stop_pc>, <stop_reason>: Likewise.
2020-01-13gdb: Handle malformed ELF, symbols in non-allocatable sectionsAndrew Burgess6-4/+253
I ended up debugging a malformed ELF where a section containing executable code was not correctly marked as allocatable. Before realising the ELF was corrupted I tried to place a breakpoint on a symbol in the non-allocatable, executable section, and GDB crashed. Though trying to debug such an ELF clearly isn't going to go well I would prefer, as far as possible, that any input, no matter how corrupted, not crash GDB. The crash occurs when trying to set a breakpoint on the name of a function from the corrupted section. GDB converts the symbol to a symtab_and_line, and looks up a suitable section for this. The problem is that the section is actually an obj_section, which is stored in the table within the objfile, and we only initialise this table for allocatable sections (see add_to_objfile_sections_full in objfiles.c). So, if the symbol is in a non-allocatable section then we end up referencing an uninitialised obj_section. Later we call get_sal_arch on the symtab_and_line, which calls get_objfile_arch, which uses the objfile from the uninitialised obj_section, which will be nullptr, at which point GDB crashes. The fix I propose here is that when we setup the section references on msymbols, we should check if the bfd_section being referenced is allocatable or not. If it is not then we should set the section reference back to the default 0 section (see how MSYMBOL_OBJ_SECTION and SYMBOL_OBJ_SECTION treat the 0 section index). With this fix in place GDB no longer crashes. Instead GDB creates the breakpoint at the non-allocated address, and then fails, with an error, when it tries to insert the breakpoint. gdb/ChangeLog: * elfread.c (record_minimal_symbol): Set section index to 0 for non-allocatable sections. gdb/testsuite/ChangeLog: * gdb.dwarf2/dw2-bad-elf-other.S: New file. * gdb.dwarf2/dw2-bad-elf.c: New file. * gdb.dwarf2/dw2-bad-elf.exp: New file. Change-Id: Ie05436ab4c6a71440304d20ee639dfb021223f8b
2020-01-13gdb/testsuite: Allow DWARF assembler to create multiple line tablesAndrew Burgess2-0/+7
Fixes a bug in the DWARF assembler that prevents multiple line tables from being created in a test. We currently don't initialise a couple of flags, as a result we will only ever generate one end of file list, and one end of header, in the first line table. Any additional line tables will be missing these parts, and will therefore be corrupt. This fix will be required for a later commit. There should be no change in the testsuite after this commit. gdb/testsuite/ChangeLog: * lib/dwarf.exp (Dwarf::lines): Reset _line_saw_program and _line_saw_file. Change-Id: Id7123f217a036f26ee32d608db3064dd43164596