aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2016-01-01GDB copyright headers update after running GDB's copyright.py script.Joel Brobecker4144-4154/+4158
gdb/ChangeLog: Update year range in copyright notice of all files.
2016-01-01update copyright year printed by GDB, GDBserver and gdbreplay.Joel Brobecker5-3/+14
gdb/ChangeLog: * top.c (print_gdb_version): Change copyright year in version message. gdb/gdbserver/ChangeLog: * gdbreplay.c (gdbreplay_version): Change copyright year in version message. * server.c (gdbserver_version): Likewise.
2016-01-01Rotate the GDB ChangeLogJoel Brobecker3-14475/+14489
Per GDB the "Start of New Year Procedure", this patch - renames the current ChangeLog into ChangeLog-2015; - starts a new ChangeLog file. gdb/ChangeLog: * config/djgpp/fnchange.lst: Add entry for gdb/ChangeLog-2015.
2015-12-28Use libiberty's crc32 implementation in gdbserverPatrick Palka2-20/+6
Tested on x86_64-pc-linux-gnu native-gdbserver, no new regressions. gdb/gdbserver/ChangeLog: * server.c (crc32_table): Delete. (crc32): Use libiberty's xcrc32 function.
2015-12-25Document that the PATTERN argument to gdb_test is optional.Sandra Loosemore2-1/+8
2015-12-25 Sandra Loosemore <sandra@codesourcery.com> gdb/testsuite/ * lib/gdb.exp (gdb_test): Update comments to clarify that the PATTERN argument is optional.
2015-12-24[testsuite/Ada] stop using project files when building test programsJoel Brobecker5-31/+34
The current approach when building Ada programs for testing is based on the use of a project file (testsuite/gdb.ada/gnat_ada.gpr). To do that, we pass a number of additional arguments to target_compile, one of them being the project file (via "-P/path/to/gnat_ada.gpr"). This used to work well-enough, but AdaCore is currently working towards removing project-file support from gnatmake (the prefered tool for using project files is gprbuild). So, we need to either switch the compilation to gprbuild, or stop using project files. First, using gprbuild is not always what users will be using to build their applications. So having the option of using gnatmake provides more flexibility towards exactly reproducing past bugs. If we ever need a testcase that requires the use of gprbuild, then I believe support for a new target needs to be added to dejagnu's target_compile. Also, the only real reason behind using a project file in the first place is that we wanted to make it easy to specify the directory where all compilation artifacts get stored. This is a consequence of the organization choice we made for gdb.ada to keep each testcase well organized. It is very easy to achieve that goal without using project files. This is therefore what this patch does: It change gdb_compile_ada to build any program using gnatmake without using a project file (by temporarily changing the current working directory). There is a small (beneficial) side-effect; in the situation where GDB is built in-tree, gnatmake is called as... % gnatmake [...] unit.adb ... which means that the debugging info in unit.o will say contain a filename whose name is 'unit.adb', rather than '/path/to/unit.adb'. This also better matches what users might typically do. But the side- effect is that the unit name in the GDB output is not always a full path. This patch tweaks a couple of testcases to make the path part optional. gdb/testsuite: * lib/ada.exp (target_compile_ada_from_dir): New function. (gdb_compile_ada): Reimplement avoiding the use of project files. * gdb.ada/gnat_ada.gpr: Delete. * gdb.ada/cond_lang.exp: Adjust test to make path before filename optional. * gdb.ada/small_reg_param.exp: Likewise. Tested on x86_64-linux, with both in-tree and out-of-tree builds.
2015-12-22Remove HP-UX reference in foll-vfork.expSimon Marchi2-36/+10
One more I just found. Tested with native, native-gdbserver and native-extended-gdbserver on Linux. gdb/testsuite/ChangeLog: * gdb.base/foll-vork.exp: Remove HP-UX special case.
2015-12-22[lynxos] gdbserver hangs when killing inferior from GDBJoel Brobecker2-1/+27
With any program under GDBserver control on LynxOS, killing the program from the debugger (using the "kill" command) causes GDBserver to properly kill the inferior but GDBserver then hangs. This change of behavior occured after the following change was applied: commit f0ea042932e6922c90df3fd0001497d287b97677 Date: Mon Nov 30 16:05:27 2015 +0000 Subject: gdbserver: don't exit until GDB disconnects One of the changes introduced by the commit above is that process_serial_event no longer calls exit after handling the vKill packet. Instead, what happens is that we wait until captured_main finds that we no longer have any inferior to debug, at which point it throws_quit. This (normal) exception is then expected to propagate all the way to the exception handle in function "main", which calls exit. However, before the exception gets propagated, the cleanups are first executed, and one of the cleanups in question is detach_or_kill_for_exit_cleanup, which was put in place by captured_main. detach_or_kill_for_exit_cleanup is basically a wrapper around detach_or_kill_for_exit, which iterates over all inferiors, and kills them all. In our case, we have only one inferior, which we have already killed during the handling for the "vKill" packet. Unfortunately, we did not properly clean our internal data for that inferior up, and so detach_or_kill_for_exit thinks that we still have one inferior, and therefore tries to kill it. This results in lynx_kill being called, doing the following: lynx_ptrace (PTRACE_KILL, ptid, 0, 0, 0); lynx_wait (ptid, &status, 0); the_target->mourn (process); The hang is caused by the call to lynx_wait, which waits for an event from a process which does not exist... This patch fixes the issue by enhancing lynx_mourn to clean the threads and process list up. gdb/gdbserver/ChangeLog: * lynx-low.c (lynx_delete_thread_callback): New function. (lynx_mourn): Properly delete our process and all of its threads. Remove call to clear_inferiors.
2015-12-22gdbserver crash in gdb/gdbserver/thread.c::thread_search_callbackJoel Brobecker2-1/+9
Connecting GDB to a LynxOS-178 GDBserver causes GDBserver to crash: % gdbserver :4444 simple_main Process simple_main created; pid = 19 Listening on port 4444 Remote debugging from host 205.232.38.10 Segmentation fault (core dumped) The crash happens in thread_search_callback where the function calls the_target->thread_stopped (via the thread_stopped macro) without verifying whether the callback is NULL or not. For the record, the regression was introduced by: commit a67a9faef0e32886c83611cc7a0ba61e91123063 Date: Mon Nov 30 16:05:26 2015 +0000 Subject: gdbserver:prepare_access_memory: pick another thread This patch avoids the crash by checking the value of the callback first, before calling it. gdb/gdbserver/ChangeLog: * target.c (thread_search_callback): Add check that the thread_stopped target callback is not NULL before calling it.
2015-12-22[win32] cannot automatically find executable file [...] warning at GDB startupJoel Brobecker2-1/+7
The following change... commit 43499ea30db2a866412c86952c7e1d7b158d806f Date: Tue Nov 17 15:17:44 2015 +0000 Subject: [C++/mingw] windows-nat.c casts ... causes a small regression in GDB, where we get the following warning at startup: % gdb C:\[...]\gdb.exe: warning: cannot automatically find executable file or library to read symbols. Use "file" or "dll" command to load executable/libraries directly. GNU gdb (GDB) 7.10.50.20151218-cvs (with AdaCore local changes) [...] (gdb) The warning comes from _initialize_loadable which tries to dynamically load some symbols from kernel32.dll and psapi.dll, and in particular: hm = LoadLibrary ("psapi.dll"); if (hm) { GPA (hm, EnumProcessModules); GPA (hm, GetModuleInformation); GPA (hm, GetModuleFileNameEx); } The problem is that the new GPA macro assumes that the name of the variable we use to point to the function, and the name of its associated symbol are the same. This is mostly the case, except for GetModuleFileNameEx, where the name is provided by the GetModuleFileNameEx_name macro (defined differently depending on whether we are on cygwin or not). As a result, the dynamic resolution for GetModuleFileNameEx returns NULL, and we trip the following check which leads to the warning: if (!EnumProcessModules || !GetModuleInformation || !GetModuleFileNameEx) { [...] warning(_("[...]")); } This patch fixes the problem by calling GetProcAddress directly, rather than through the GPA macro, but in a way which hopefully avoids the C++ compilation warning that the previous patch was trying to get rid of. gdb/ChangeLog: * windows-nat.c (_initialize_loadable): Fix computing of GetModuleFileNameEx.
2015-12-22Add an expect for running commands with CLI jumpThomas Preud'homme2-0/+8
2015-12-22 Thomas Preud'homme <thomas.preudhomme@arm.com> gdb/testsuite/ * lib/mi-support.exp (mi_run_cmd_full): Add an expect for the CLI jump case.
2015-12-21Remove dead code in testsuiteSimon Marchi3-60/+17
This patch removes cases from the testsuite that are not posssibly used. The messages "Catch of * not yet implemented" were removed here: https://www.sourceware.org/ml/gdb-patches/2004-01/msg00679.html I changed the regexp at the same time to match the string more closely. gdb/testsuite/ChangeLog: * gdb.base/break.exp: Remove dead code. * gdb.base/sepdebug.exp: Likewise.
2015-12-21Remove HP-UX references fom testsuiteSimon Marchi36-1048/+146
This patch removes all special cases for HP-UX, for which support has been removed earlier, that I found in the testsuite. Note that the hppa architecture != HP-UX, since other OSes can run on hppa, so I tried to leave everything that is not HP-UX specific. Two complete tests were completely HP-UX specific, so I removed them. I ran the testsuite on Linux x86-64, native and native-gdbserver, and noticed no regressions. gdb/testsuite/ChangeLog: * gdb.asm/asm-source.exp: Remove HP-UX references. * gdb.base/annota1.exp: Likewise. * gdb.base/annota3.exp: Likewise. * gdb.base/attach.exp: Likewise. * gdb.base/bigcore.exp: Likewise. * gdb.base/break.exp: Likewise. * gdb.base/call-ar-st.exp: Likewise. * gdb.base/callfuncs.exp: Likewise. * gdb.base/catch-fork-static.exp: Likewise. * gdb.base/display.exp: Likewise. * gdb.base/foll-exec-mode.exp: Likewise. * gdb.base/foll-exec.exp: Likewise. * gdb.base/foll-fork.exp: Likewise. * gdb.base/foll-vfork.exp: Likewise. * gdb.base/funcargs.exp: Likewise. * gdb.base/hbreak2.exp: Likewise. * gdb.base/inferior-died.exp: Likewise. * gdb.base/interrupt.exp: Likewise. * gdb.base/multi-forks.exp: Likewise. * gdb.base/nodebug.exp: Likewise. * gdb.base/sepdebug.exp: Likewise. * gdb.base/solib1.c: Likewise. * gdb.base/step-test.exp: Likewise. * gdb.mi/non-stop.c: Likewise. * gdb.mi/pthreads.c: Likewise. * gdb.multi/bkpt-multi-exec.ex: Likewise. * gdb.threads/pthreads.c: Likewise. * gdb.threads/staticthreads.exp: Likewise. * lib/future.exp: Likewise. * lib/gdb.exp: Likewise. * gdb.base/so-indr-cl.c: Remove. * gdb.base/so-indr-cl.exp: Likewise. * gdb.base/solib.c: Likewise. * gdb.base/solib.exp: Likewise. * gdb.base/solib2.c: Likewise.
2015-12-21Remove references to HP CC/aCC compiler from testsuiteSimon Marchi29-324/+72
The HP CC/aCC compiler is exclusive to HP-UX, for which support has been explicitly removed. Therefore, It does not make sense to keep tests for these compilers' quirks. gdb/testsuite/ChangeLog: * gdb.base/break.exp: Remove references to HP CC/aCC compilers. * gdb.base/call-ar-st.exp: Likewise. * gdb.base/callfuncs.exp: Likewise. * gdb.base/condbreak.exp: Likewise. * gdb.base/constvars.exp: Likewise. * gdb.base/hbreak2.exp: Likewise. * gdb.base/langs.exp: Likewise. * gdb.base/list.exp: Likewise. * gdb.base/long_long.exp: Likewise. * gdb.base/ptype.exp: Likewise. * gdb.base/scope.exp: Likewise. * gdb.base/signals.exp: Likewise. * gdb.base/so-impl-ld.exp: Likewise. * gdb.base/varargs.exp: Likewise. * gdb.base/volatile.exp: Likewise. * gdb.base/whatis.exp: Likewise. * gdb.cp/cplusfuncs.exp: Likewise. * gdb.cp/inherit.exp: Likewise. * gdb.cp/local.exp: Likewise. * gdb.cp/member-ptr.exp: Likewise. * gdb.cp/method.exp: Likewise. * gdb.cp/overload.exp: Likewise. * gdb.cp/templates.exp: Likewise. * gdb.stabs/weird.exp: Likewise. * lib/compiler.c: Likewise. * lib/compiler.cc: Likewise. * lib/cp-support.exp: Likewise. * lib/gdb.exp: Likewise.
2015-12-21Use arm_eabi_breakpoint on aarch32Yao Qi2-3/+8
This patch is to get b37a6290 back again, which was removed by d9311bfa by mistake. gdb/gdbserver: 2015-12-21 Yao Qi <yao.qi@linaro.org> * linux-aarch32-low.h [__aarch64__]: Use arm_abi_breakpoint arm breakpoint.
2015-12-21Minor reformatting fix in gdbtypes.c::create_array_type_with_strideJoel Brobecker2-2/+6
gdb/ChangeLog: * gdbtypes.c (create_array_type_with_stride): Fix indentation.
2015-12-20Remove HP-UX reference in testsuite/configure.acSimon Marchi3-4/+5
gdb/testsuite/ChangeLog: * configure.ac: Remove HP-UX case. * configure: Regenerate.
2015-12-19Fix ARI warning in gdb/arch/arm-get-next-pcs.cJoel Brobecker2-1/+6
gdb/ChangeLog: * arch/arm-get-next-pcs.c (arm_get_next_pcs_raw): Remove trailing newline at end of error message.
2015-12-18Reset pagination counts even when stdin is not a tty.Sandra Loosemore3-4/+8
2015-12-18 Sandra Loosemore <sandra@codesourcery.com> gdb/ * event-top.c (command_handler): Don't require stdin to be a tty for call to reinitialize_more_filter. * top.c (command_loop): Likewise.
2015-12-18Make prompt_for_continue call throw_quit directly.Sandra Loosemore2-1/+6
2015-12-18 Sandra Loosemore <sandra@codesourcery.com> gdb/ * utils.c (prompt_for_continue): Call throw_quit directly on 'q'.
2015-12-18Cast to enum bfd_endian in arm_get_next_pcs_read_memory_unsigned_integerAntoine Tremblay2-1/+7
This patch fixes the cxx build broken by commit : d9311bfaf572cf14af577a66e79c51c491553552. Pushed as obvious. gdb/ChangeLog: * arm-tdep.c (arm_get_next_pcs_read_memory_unsigned_integer): Cast to enum bfd_endian)
2015-12-18Add documentation to gdb_compileSimon Marchi2-0/+38
This patch adds some documentation to gdb_compile. It describes the various options that can influence compilation. Most of them are handled by DejaGnu, but are not really documented anywhere, so I think it's good to have a quick reference. Not all possible options are described, that would add way to much noise. I chose those that I think are relevant in the context of writing a test case. gdb/testsuite/ChangeLog: * lib/gdb.exp (gdb_compile): Add function doc.
2015-12-18Enable conditional breakpoints for targets that support software single step ↵Antoine Tremblay2-6/+6
in GDBServer This patch enables support for conditional breakpoints if the target supports software single step. This was disabled before as the implementations of software single step were too simple as discussed in https://sourceware.org/ml/gdb-patches/2015-04/msg01110.html. Since these issues are now fixed support can be added back. New tests passing : PASS: gdb.base/cond-eval-mode.exp: set breakpoint condition-evaluation target and related... No regressions, tested on ubuntu 14.04 ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } gdb/gdbserver/ChangeLog: * server.c (handle_query): Call target_supports_software_single_step.
2015-12-18Enable software single stepping for while-stepping actions in GDBServerAntoine Tremblay2-17/+37
This patch enables software single stepping if the targets support it, to do while-stepping actions. No regressions, tested on ubuntu 14.04 ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } gdb/gdbserver/ChangeLog: * linux-low.c (single_step): New function. (linux_resume_one_lwp_throw): Call single_step. (start_step_over): Likewise.
2015-12-18Support software single step on ARM in GDBServerAntoine Tremblay22-1361/+1924
This patch teaches GDBServer how to software single step on ARM linux by sharing code with GDB. The arm_get_next_pcs function in GDB is now shared with GDBServer. So that GDBServer can use the function to return the possible addresses of the next PC. A proper shared context was also needed so that we could share the code, this context is described in the arm_get_next_pcs structure. Testing : No regressions, tested on ubuntu 14.04 ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } gdb/ChangeLog: * Makefile.in (ALL_TARGET_OBS): Append arm-get-next-pcs.o, arm-linux.o. (ALLDEPFILES): Append arm-get-next-pcs.c, arm-linux.c (arm-linux.o): New rule. (arm-get-next-pcs.o): New rule. * arch/arm-get-next-pcs.c: New file. * arch/arm-get-next-pcs.h: New file. * arch/arm-linux.h: New file. * arch/arm-linux.c: New file. * arm.c: Include common-regcache.c. (thumb_advance_itstate): Moved from arm-tdep.c. (arm_instruction_changes_pc): Likewise. (thumb_instruction_changes_pc): Likewise. (thumb2_instruction_changes_pc): Likewise. (shifted_reg_val): Likewise. * arm.h (submask): Move macro from arm-tdep.h (bit): Likewise. (bits): Likewise. (sbits): Likewise. (BranchDest): Likewise. (thumb_advance_itstate): Moved declaration from arm-tdep.h (arm_instruction_changes_pc): Likewise. (thumb_instruction_changes_pc): Likewise. (thumb2_instruction_changes_pc): Likewise. (shifted_reg_val): Likewise. * arm-linux-tdep.c: Include arch/arm.h, arch/arm-get-next-pcs.h arch/arm-linux.h. (arm_linux_get_next_pcs_ops): New struct. (ARM_SIGCONTEXT_R0, ARM_UCONTEXT_SIGCONTEXT, ARM_OLD_RT_SIGFRAME_SIGINFO, ARM_OLD_RT_SIGFRAME_UCONTEXT, ARM_NEW_RT_SIGFRAME_UCONTEXT, ARM_NEW_SIGFRAME_MAGIC): Move stack layout defines to arch/arm-linux.h. (arm_linux_sigreturn_next_pc_offset): Move to arch/arm-linux.c. (arm_linux_software_single_step): Adjust for arm_get_next_pcs implementation. * arm-tdep.c: Include arch/arm-get-next-pcs.h. (arm_get_next_pcs_ops): New struct. (submask): Move macro to arm.h. (bit): Likewise. (bits): Likewise. (sbits): Likewise. (BranchDest): Likewise. (thumb_instruction_changes_pc): Move to arm.c (thumb2_instruction_changes_pc): Likewise. (arm_instruction_changes_pc): Likewise. (shifted_reg_val): Likewise. (thumb_advance_itstate): Likewise. (thumb_get_next_pc_raw): Move to arm-get-next-pcs.c. (arm_get_next_pc_raw): Likewise. (arm_get_next_pc): Likewise. (thumb_deal_with_atomic_sequence_raw): Likewise. (arm_deal_with_atomic_sequence_raw): Likewise. (arm_deal_with_atomic_sequence): Likewise. (arm_get_next_pcs_read_memory_unsigned_integer): New function. (arm_get_next_pcs_addr_bits_remove): Likewise. (arm_get_next_pcs_syscall_next_pc): Likewise. (arm_get_next_pcs_is_thumb): Likewise. (arm_software_single_step): Adjust for arm_get_next_pcs implementation. * arm-tdep.h: (arm_get_next_pc): Remove declaration. (arm_get_next_pcs_read_memory_unsigned_integer): New declaration. (arm_get_next_pcs_addr_bits_remove): Likewise. (arm_get_next_pcs_syscall_next_pc): Likewise. (arm_get_next_pcs_is_thumb): Likewise. (arm_deal_with_atomic_sequence: Remove declaration. * common/gdb_vecs.h: Add CORE_ADDR vector definition. * configure.tgt (aarch64*-*-linux): Add arm-get-next-pcs.o, arm-linux.o. (arm*-wince-pe): Add arm-get-next-pcs.o. (arm*-*-linux*): Add arm-get-next-pcs.o, arm-linux.o, arm-get-next-pcs.o (arm*-*-netbsd*,arm*-*-knetbsd*-gnu): Add arm-get-next-pcs.o. (arm*-*-openbsd*): Likewise. (arm*-*-symbianelf*): Likewise. (arm*-*-*): Likewise. * symtab.h: Move CORE_ADDR vector definition to gdb_vecs.h. gdb/gdbserver/ChangeLog: * Makefile.in (SFILES): Append arch/arm-linux.c, arch/arm-get-next-pcs.c. (arm-linux.o): New rule. (arm-get-next-pcs.o): New rule. * configure.srv (arm*-*-linux*): Add arm-get-next-pcs.o, arm-linux.o. * linux-aarch32-low.c (arm_abi_breakpoint): Remove macro. Moved to linux-aarch32-low.c. (arm_eabi_breakpoint, arm_breakpoint): Likewise. (arm_breakpoint_len, thumb_breakpoint): Likewise. (thumb_breakpoint_len, thumb2_breakpoint): Likewise. (thumb2_breakpoint_len): Likewise. (arm_is_thumb_mode): Make non-static. * linux-aarch32-low.h (arm_abi_breakpoint): New macro. Moved from linux-aarch32-low.c. (arm_eabi_breakpoint, arm_breakpoint): Likewise. (arm_breakpoint_len, thumb_breakpoint): Likewise. (thumb_breakpoint_len, thumb2_breakpoint): Likewise. (thumb2_breakpoint_len): Likewise. (arm_is_thumb_mode): New declaration. * linux-arm-low.c: Include arch/arm-linux.h aarch/arm-get-next-pcs.h, sys/syscall.h. (get_next_pcs_ops): New struct. (get_next_pcs_addr_bits_remove): New function. (get_next_pcs_is_thumb): New function. (get_next_pcs_read_memory_unsigned_integer): Likewise. (arm_sigreturn_next_pc): Likewise. (get_next_pcs_syscall_next_pc): Likewise. (arm_gdbserver_get_next_pcs): Likewise. (struct linux_target_ops) <arm_gdbserver_get_next_pcs>: Initialize. * linux-low.h: Move CORE_ADDR vector definition to gdb_vecs.h. * server.h: Include gdb_vecs.h.
2015-12-18Share regcache function regcache_raw_read_unsignedAntoine Tremblay10-51/+119
This patch is in preparation for software single step support on ARM in GDBServer. It adds a new shared function regcache_raw_read_unsigned and regcache_raw_get_unsigned so that GDB and GDBServer can use the same call to fetch a raw register into an integer. No regressions, tested on ubuntu 14.04 ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } gdb/ChangeLog: * Makefile.in (SFILES): Append common/common-regcache.c. (COMMON_OBS): Append common/common-regcache.o. (common-regcache.o): New rule. * common/common-regcache.h (register_status) New enum. (regcache_raw_read_unsigned): New declaration. * common/common-regcache.c: New file. * regcache.h (enum register_status): Move to common-regcache.h. (regcache_raw_read_unsigned): Likewise. (regcache_raw_get_unsigned): Likewise. gdb/gdbserver/ChangeLog: * Makefile.in (SFILES): Append common/common-regcache.c. (OBS): Append common-regcache.o. (common-regcache.o): New rule. * regcache.c (init_register_cache): Initialize cache to REG_UNAVAILABLE. (regcache_raw_read_unsigned): New function. * regcache.h (REG_UNAVAILABLE, REG_VALID): Replaced by shared register_status enum.
2015-12-18Refactor arm_software_single_step to use regcacheAntoine Tremblay6-79/+212
This patch is in preparation for software single step support on ARM in GDBServer. It refactors arm_*_software_single_step and sub-functions to use regcache instead of frame to access registers so that the code can be shared more easily between GDB and GDBServer. Note also that since the intention is at some point to get rid of frame completely in that function, memory reads have also been replaced by read_memory_unsigned_integer rather than get_frame_memory_unsigned. No regressions, tested on ubuntu 14.04 ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } gdb/ChangeLog: * arm-linux-tdep.c (arm_linux_sigreturn_next_pc_offset): New function. (arm_linux_sigreturn_next_pc): Likewise. (arm_linux_syscall_next_pc): Use regcache instead of frame. (arm_linux_software_single_step): Likewise. * arm-tdep.c (arm_is_thumb): New function. (shifted_reg_va): Use regcache instead of frame. (thumb_get_next_pc_raw): Likewise. (arm_get_next_pc_raw): Likewise. (arm_get_next_pc): Likewise. (thumb_deal_with_atomic_sequence_raw): Likewise. (arm_deal_with_atomic_sequence_raw): Likewise. (arm_deal_with_atomic_sequence): Likewise. (arm_software_single_step): Likewise. * arm-tdep.h (struct gdbarch_tdep): Use regcache for syscall_next_pc. (arm_get_next_pc): Use regcache. (arm_deal_with_atomic_sequence): Likewise. (arm_is_thumb): New declaration. * regcache.c (regcache_raw_get_unsigned): New function. * regcache.h (regcache_raw_get_unsigned): New function declaration.
2015-12-18Share some ARM target dependent code from GDB with GDBServerAntoine Tremblay7-86/+109
This patch is in preparation for software single stepping support on ARM it shares some functions and definitions that will be needed. No regressions, tested on ubuntu 14.04 ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } Not tested: wince/bsd build. gdb/ChangeLog: * arch/arm.c (bitcount): Move from arm-tdep.c. (condition_true): Likewise. * arch/arm.h (Instruction Definitions): Move form arm-tdep.h. (condition_true): Move defenition from arm-tdep.h. (bitcount): Likewise. * arm-tdep.c (condition_true): Move to arch/arm.c. (bitcount): Likewise. * arm-tdep.h (Instruction Definitions): Move to arch/arm.h. * arm-wince-tdep.c: Include arch/arm.h. * armnbsd-tdep.c: Likewise.
2015-12-18Replace breakpoint_reinsert_addr by get_next_pcs operation in GDBServerAntoine Tremblay11-13/+53
This patch in preparation for software single step support on ARM. It refactors breakpoint_reinsert_addr into get_next_pcs so that multiple location can be returned. When software single stepping there can be multiple possible next addresses because we're stepping over a conditional branch instruction, for example. The operation get_next_pcs handles that by returning a vector of all the possible next addresses. Software breakpoints are installed at each location returned. No regressions, tested on ubuntu 14.04 ARMv7 and x86. With gdbserver-{native,extended} / { -marm -mthumb } gdb/gdbserver/ChangeLog: * linux-aarch64-low.c (the_low_targets): Rename breakpoint_reinsert_addr to get_next_pcs. * linux-arm-low.c (the_low_targets): Likewise. * linux-bfin-low.c (the_low_targets): Likewise. * linux-cris-low.c (the_low_targets): Likewise. * linux-crisv32-low.c (the_low_targets): Likewise. * linux-low.c (can_software_single_step): Likewise. (install_software_single_step_breakpoints): New function. (start_step_over): Use install_software_single_step_breakpoints. * linux-low.h: New CORE_ADDR vector. (struct linux_target_ops) Rename breakpoint_reinsert_addr to get_next_pcs. * linux-mips-low.c (the_low_targets): Likewise. * linux-nios2-low.c (the_low_targets): Likewise. * linux-sparc-low.c (the_low_targets): Likewise.
2015-12-17Fix PR threads/19354: "info threads" error with multiple inferiorsPedro Alves5-34/+81
Note: this applies on top of: [PATCH] Remove support for LinuxThreads and vendor 2.4 kernels w/ backported NPTL https://sourceware.org/ml/gdb-patches/2015-12/msg00214.html We try to avoid using libthread_db.so to list threads in the inferior when debugging live processes, but the code that decides whether to use it decides incorrectly if you have more than one inferior, and the current inferior doesn't have execution yet. The result is visible as: (gdb) add-inferior Added inferior 2 (gdb) inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] (gdb) info inferiors Num Description Executable 1 process 15397 /home/pedro/gdb/tests/threads * 2 <null> (gdb) info threads Cannot find new threads: generic error (gdb) Fix this by checking whether each inferior has execution rather than just the current inferior. By moving the core updating to linux-nat.c's update_thread_list implementation, this also ends up fixing the lwp-last-seen-running-on-core updating in the case we're debugging a program that uses raw clone rather than pthreads, as linux-thread-db.c isn't pushed in the target stack in that scenario. Tested on x86_64 Fedora 20. gdb/ChangeLog: 2015-12-17 Pedro Alves <palves@redhat.com> PR threads/19354 * linux-nat.c (linux_nat_update_thread_list): Update process cores each lwp was last seen running on here. * linux-thread-db.c (update_thread_core): Delete. (thread_db_update_thread_list_td_ta_thr_iter): Rename to ... (thread_db_update_thread_list): ... this. Skip inferiors with execution. Also call the target beneath. (thread_db_update_thread_list): Delete. gdb/testsuite/ChangeLog: 2015-12-17 Pedro Alves <palves@redhat.com> PR threads/19354 * gdb.multi/info-threads.exp: New file.
2015-12-17Remove support for LinuxThreads and vendor 2.4 kernels w/ backported NPTLPedro Alves12-541/+171
Since we now rely on PTRACE_EVENT_CLONE being available (added in Linux 2.5.46), we're relying on NPTL. This commit removes the support for older LinuxThreads, as well as the workarounds for vendor 2.4 kernels with NPTL backported. - Rely on tkill being available. - Assume gdb doesn't get cancel signals. - Remove code that checks the LinuxThreads restart and cancel signals in the inferior. - Assume that __WALL is available. - Assume that non-leader threads report WIFEXITED. - Thus, no longer need to send signal 0 to check whether threads are still alive. - Update comments throughout. Tested on x86_64 Fedora 20, native and gdbserver. gdb/ChangeLog: * configure.ac: Remove tkill checks. * configure, config.in: Regenerate. * linux-nat.c: Remove HAVE_TKILL_SYSCALL check. Update top level comments. (linux_nat_post_attach_wait): Remove 'cloned' parameter. Use __WALL. (attach_proc_task_lwp_callback): Don't set the cloned flag. (linux_nat_attach): Adjust. (kill_lwp): Remove HAVE_TKILL_SYSCALL check. No longer fall back to 'kill'. (linux_handle_extended_wait): Use __WALL. Don't set the cloned flag. (wait_lwp): Use __WALL. Update comments. (running_callback, stop_and_resume_callback): Delete. (linux_nat_filter_event): Don't stop and resume all lwps. Don't check if the event LWP has previously exited. (check_zombie_leaders): Update comments. (linux_nat_wait_1): Use __WALL. (kill_wait_callback): Don't handle clone processes separately. Use __WALL instead. (linux_thread_alive): Delete. (linux_nat_thread_alive): Return true as long as the LWP is in the LWP list. (linux_nat_update_thread_list): Assume the kernel supports PTRACE_EVENT_CLONE. (get_signo): Delete. (lin_thread_get_thread_signals): Remove LinuxThreads references. No longer check __pthread_sig_restart / __pthread_sig_cancel in the inferior. * linux-nat.h (struct lwp_info) <cloned>: Delete field. * linux-thread-db.c: Update comments. (_initialize_thread_db): Remove LinuxThreads references. * nat/linux-waitpid.c (my_waitpid): No longer emulate __WALL. Pass down flags unmodified. * linux-waitpid.h (my_waitpid): Update documentation. gdb/gdbserver/ChangeLog: * linux-low.c (linux_kill_one_lwp): Remove references to LinuxThreads. (kill_lwp): Remove HAVE_TKILL_SYSCALL check. No longer fall back to 'kill'. (linux_init_signals): Delete. (initialize_low): Adjust. * thread-db.c (thread_db_init): Remove LinuxThreads reference.
2015-12-17Fix one heap buffer overflow in aarch64_push_dummy_callYao Qi2-3/+12
Hi, AddressSanitizer reports an error like this, (gdb) PASS: gdb.base/call-ar-st.exp: continue to tbreak9 print print_long_arg_list(a, b, c, d, e, f, *struct1, *struct2, *struct3, *struct4, *flags, *flags_combo, *three_char, *five_char, *int_char_combo, *d1, *d2, *d3, *f1, *f2, *f3) ================================================================= ==6236==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60200008eb50 at pc 0x89e432 bp 0x7fffa3df9080 sp 0x7fffa3df9078 READ of size 5 at 0x60200008eb50 thread T0 #0 0x89e431 in memory_xfer_partial gdb/target.c:1264 #1 0x89e6c7 in target_xfer_partial gdb/target.c:1320 #2 0x89f267 in target_write_partial gdb/target.c:1595^M #3 0x8a014b in target_write_with_progress gdb/target.c:1889^M #4 0x8a0262 in target_write gdb/target.c:1914^M #5 0x89ee59 in target_write_memory gdb/target.c:1492^M #6 0x9a1c74 in write_memory gdb/corefile.c:393^M #7 0x467ea5 in aarch64_push_dummy_call gdb/aarch64-tdep.c:1388 The problem is that an instance of stack_item_t is created to adjust stack for alignment, the item.len is correct, but item.data is buf, which is wrong, because item.len can be greater than the length of buf. This patch sets item.data to NULL, and only update sp (no inferior memory writes on stack for this item). gdb: 2015-12-17 Yao Qi <yao.qi@linaro.org> * aarch64-tdep.c (struct stack_item_t): Update comments. (pass_on_stack): Set item.data to NULL. (aarch64_push_dummy_call): Call write_memory if si->data isn't NULL.
2015-12-16Fix -Wno-unknown-warning support detectionPedro Alves6-8/+56
Ref: https://sourceware.org/ml/gdb/2015-12/msg00024.html We have code in configure.ac that tries to detect whether the compiler supports each warning and suppress it if not, but that doesn't work with "-Wno-" options, because gcc doesn't error out for -Wno-unknown-warning unless other diagnostics are being produced. See https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html. Handle this by checking whether -Wfoo works when we actually want -Wno-foo. gdb/ChangeLog: 2015-12-16 Pedro Alves <palves@redhat.com> * configure.ac (compiler warning flags): When testing a -Wno-foo option, check whether -Wfoo works instead. * configure: Regenerate. gdb/gdbserver/ChangeLog: 2015-12-16 Pedro Alves <palves@redhat.com> * configure.ac (compiler warning flags): When testing a -Wno-foo option, check whether -Wfoo works instead. * configure: Regenerate.
2015-12-16[C++] Fix -Winvalid-offsetof warnings with g++ 4.4Pedro Alves2-10/+40
Ref: https://sourceware.org/ml/gdb/2015-12/msg00014.html Fixes the build in C++ mode with g++ 4.4: gdb/btrace.h: In function ‘size_t VEC_btrace_insn_s_embedded_size(int)’: gdb/btrace.h:84: error: invalid access to non-static data member ‘VEC_btrace_insn_s::vec’ of NULL object gdb/btrace.h:84: error: (perhaps the ‘offsetof’ macro was used incorrectly) gdb/btrace.h: In function ‘VEC_btrace_insn_s* VEC_btrace_insn_s_alloc(int)’: gdb/btrace.h:84: error: invalid access to non-static data member ‘VEC_btrace_insn_s::vec’ of NULL object gdb/btrace.h:84: error: (perhaps the ‘offsetof’ macro was used incorrectly) gdb/btrace.h: In function ‘VEC_btrace_insn_s* VEC_btrace_insn_s_copy(VEC_btrace_insn_s*)’: gdb/btrace.h:84: error: invalid access to non-static data member ‘VEC_btrace_insn_s::vec’ of NULL object gdb/btrace.h:84: error: (perhaps the ‘offsetof’ macro was used incorrectly) gdb/btrace.h: In function ‘VEC_btrace_insn_s* VEC_btrace_insn_s_merge(VEC_btrace_insn_s*, VEC_btrace_insn_s*)’: gdb/btrace.h:84: error: invalid access to non-static data member ‘VEC_btrace_insn_s::vec’ of NULL object gdb/btrace.h:84: error: (perhaps the ‘offsetof’ macro was used incorrectly) gdb/btrace.h: In function ‘int VEC_btrace_insn_s_reserve(VEC_btrace_insn_s**, int, const char*, unsigned int)’: gdb/btrace.h:84: error: invalid access to non-static data member ‘VEC_btrace_insn_s::vec’ of NULL object gdb/btrace.h:84: error: (perhaps the ‘offsetof’ macro was used incorrectly) gdb/ChangeLog: 2015-12-16 Pedro Alves <palves@redhat.com> * common/vec.h (vec_offset): New macro. (DEF_VEC_ALLOC_FUNC_I, DEF_VEC_ALLOC_FUNC_O): Use it instead of offsetof.
2015-12-15Tweak gdb.trace/ftrace.exp for aarch64Yao Qi2-0/+7
Some tests are skipped on aarch64 unexpectedly because arg0exp isn't set. This patch is to set arg0exp to "$x0" for aarch64. gdb/testsuite: 2015-12-15 Yao Qi <yao.qi@linaro.org> * gdb.trace/ftrace.exp: Set arg0exp to "$x0" if target is aarch64*-*-*.
2015-12-14Check for readline support in gdb.base/history-duplicates.exp.Sandra Loosemore2-1/+12
2015-12-14 Sandra Loosemore <sandra@codesourcery.com> gdb/testsuite/ * gdb.base/history-duplicates.exp: Skip if no readline support.
2015-12-14Skip gdb.base/gdbinit-history.exp on remote hosts.Sandra Loosemore2-0/+12
2015-12-14 Sandra Loosemore <sandra@codesourcery.com> gdb/testsuite/ * gdb.base/gdbinit-history.exp: Skip for remote-host testing.
2015-12-14Skip gdb.base/gdbhistsize-history.exp on remote hosts.Sandra Loosemore2-0/+12
2015-12-14 Sandra Loosemore <sandra@codesourcery.com> gdb/testsuite/ * gdb.base/gdbhistsize-history.exp: Skip for remote-host testing.
2015-12-14Skip tests that send ctrl-c to GDB if nointerrupts target property is set.Sandra Loosemore17-57/+137
2015-12-14 Sandra Loosemore <sandra@codesourcery.com> gdb/testsuite/ * gdb.base/completion.exp: Skip tests that interrupt GDB with ctrl-C if nointerrupts target property is set. * gdb.base/double-prompt-target-event-error.exp: Likewise. * gdb.base/paginate-after-ctrl-c-running.exp: Likewise. * gdb.base/paginate-bg-execution.exp: Likewise. * gdb.base/paginate-execution-startup.exp: Likewise. * gdb.base/random-signal.exp: Likewise. * gdb.base/range-stepping.exp: Likewise. * gdb.cp/annota2.exp: Likewise. * gdb.cp/annota3.exp: Likewise. * gdb.gdb/selftest.exp: Likewise. * gdb.threads/continue-pending-status.exp: Likewise. * gdb.threads/leader-exit.exp: Likewise. * gdb.threads/manythreads.exp: Likewise. * gdb.threads/pthreads.exp: Likewise. * gdb.threads/schedlock.exp: Likewise. * gdb.threads/sigthread.exp: Likewise.
2015-12-14Target remote mode fork and exec event documentationDon Breazeal4-77/+213
This patch implements documentation updates for target remote mode fork and exec events. A summary of the rationale for the changes made here: * Connecting to a remote target -- explain that the two protocols exist. * Connecting in target remote mode -- explain invoking gdbserver for target remote mode, and move remote-specific text from original "Connecting to a remote target" section. * Connecting in target extended-remote mode -- promote this section from "Using the gdbserver Program | Running gdbserver | Multi-Process Mode for gdbserver". Put it next to the target remote mode section. * Host and target files -- collect paragraphs dealing with how to locate symbol files from original sections "Connecting to a remote target" and "Using the gdbserver program | Connecting to gdbserver". * Steps for connecting to a remote target -- used to be "Using the gdbserver program | Connecting to gdbserver" * Remote connection commands -- used to be the bulk of "Connecting to a remote target". Added "target extended-remote" commands and information. gdb/ChangeLog: * NEWS: Announce fork and exec event support for target remote. gdb/doc/ChangeLog: * gdb.texinfo (Forks): Correct Linux kernel version where fork and exec events are supported, add notes about support of these events in target remote mode. (Connecting): Reorganize and clarify distinctions between target remote, extended-remote, and multiprocess. Reorganize related text from separate sections into new sections. (Server): Note effects of target extended-remote mode. Delete section on Multi-Process Mode for gdbserver. Move some text to "Connecting" node.
2015-12-14Target remote mode fork and exec event supportDon Breazeal6-114/+161
This patch implements support for fork and exec events with target remote mode Linux targets. For such targets with Linux kernels 2.5.46 and later, this enables follow-fork-mode, detach-on-fork and fork and exec catchpoints. The changes required to implement this included: * Don't exit from gdbserver if there are still active inferiors. * Allow changing the active process in remote mode. * Enable fork and exec events in remote mode. * Print "Ending remote debugging" only when disconnecting. * Combine remote_kill and extended_remote_kill into a single function that can handle the multiple inferior case for target remote. Also, the same thing for remote_mourn and extended_remote_mourn. * Enable process-style ptids in target remote. * Remove restriction on multiprocess mode in target remote. gdb/gdbserver/ChangeLog: * server.c (process_serial_event): Don't exit from gdbserver in remote mode if there are still active inferiors. gdb/ChangeLog: * inferior.c (number_of_live_inferiors): New function. (have_live_inferiors): Use number_of_live_inferiors in place of duplicate code. * inferior.h (number_of_live_inferiors): Declare new function. * remote.c (set_general_process): Remove restriction on target remote mode. (remote_query_supported): Likewise. (remote_detach_1): Exit in target remote mode only when there is just one live inferior left. (remote_disconnect): Unpush the target directly instead of calling remote_mourn. (remote_kill): Rewrite function to handle both target remote and extended-remote. Call remote_kill_k. (remote_kill_k): New function. (extended_remote_kill): Delete function. (remote_mourn, extended_remote_mourn): Combine functions into one, remote_mourn, and enable extended functionality for target remote. (remote_pid_to_str): Enable "process" style ptid string for target remote. (remote_supports_multi_process): Remove restriction on target remote mode.
2015-12-14Target remote mode fork and exec test updatesDon Breazeal18-65/+49
This patch updates tests for fork and exec events in target remote mode. In the majority of cases this was a simple matter of removing some code that disabled the test for target remote. In a few cases the test needed to be disabled; in those cases the gdb_protocol was checked instead of using the [is_remote target] etc. In a couple of cases we needed to use clean_restart, since target remote doesn't support the run command, and in one case we had to modify an expect expression to allow for a "multiprocess-style" ptid. Tested with the patch that implemented target remote mode fork and exec event support. gdb/testsuite/ChangeLog: * gdb.base/execl-update-breakpoints.exp (main): Enable for target remote. * gdb.base/foll-exec-mode.exp (main): Disable for target remote. * gdb.base/foll-exec.exp (main): Enable for target remote. * gdb.base/foll-fork.exp (main): Likewise. * gdb.base/foll-vfork.exp (main): Likewise. * gdb.base/multi-forks.exp (main): Likewise, and use clean_restart. (proc continue_to_exit_bp_loc): Use clean_restart. * gdb.base/pie-execl.exp (main): Disable for target remote. * gdb.base/watch-vfork.exp (main): Enable for target remote. * gdb.mi/mi-nsthrexec.exp (main): Likewise. * gdb.threads/execl.exp (main): Likewise. * gdb.threads/fork-child-threads.exp (main): Likewise. * gdb.threads/fork-plus-threads.exp (main): Disable for target remote. * gdb.threads/fork-thread-pending.exp (main): Enable for target remote. * gdb.threads/linux-dp.exp (check_philosopher_stack): Allow pid.tid style ptids, instead of just tid. * gdb.threads/thread-execl.exp (main): Enable for target remote. * gdb.threads/watchpoint-fork.exp (main): Likewise. * gdb.trace/report.exp (use_collected_data): Allow pid.tid style ptids, instead of just tid.
2015-12-14gdb: Use TYPE_LENGTH macroAndrew Burgess3-8/+16
Fixes a couple of places where we access the length field of the type structure directly, rather than using the TYPE_LENGTH macro. gdb/ChangeLog: * i386-tdep.c (i386_mpx_info_bounds): Use TYPE_LENGTH. (i386_mpx_set_bounds): Likewise. * solib-darwin.c (darwin_load_image_infos): Likewise. (darwin_solib_read_all_image_info_addr): Likewise.
2015-12-11gdb: Extend help text for 'list' command.Andrew Burgess2-2/+11
Reference the 'listsize' setting in the help text for the 'list' command to help users find this setting. gdb/ChangeLog: * cli/cli-cmds.c (_initialize_cli_cmds): Extend help text for 'list' command.
2015-12-11gdb: Add an error when 'list -' reaches the start of a file.Andrew Burgess4-4/+33
When a a user uses 'list +' to list forward through a source file they eventually reach the end of the source file. Subsequent uses of 'list +' result in an error message like this, that let the user know they are at the end of the source file: Line number XXX out of range; FILENAME has YYY lines. Compare this to the current behaviour of 'list -' which lists backwards through a source file. When the user reaches the beginning of the source file, subsequent uses of 'list -' result in the command silently returning. This can be confusing if the previous uses of 'list -' have scrolled off the users display, the user receives no reminder that the have already seen the start of the file. After this commit a use of 'list -' when the user has already seen the start of a file will receive the following error: Already at the start of FILENAME. gdb/ChangeLog: * cli/cli-cmds.c (list_command): Add an error when trying to use '-' to scan read off the start of the source file. gdb/testsuite/ChangeLog: * gdb.base/list.exp (test_list_forward): Add end of file error test. (test_repeat_list_command): Add end of file error test. (test_list_backwards): Add beginning of file error test.
2015-12-11gdb: 'list' command, tweak handling of +/- arguments.Andrew Burgess4-3/+32
There is an inconsistency with the handling of the special +/- arguments to the list command. For the very first time that list is used (after the inferior has changed locations) then only the first character of the argument string is checked, so 'list +BLAH' will operate as 'list +' and 'list -----FOO' will operate as 'list -'. This compares to each subsequent use of list, where the whole argument string is checked, so 'list +BLAH' will try to list lines of code around the function '+BLAH'. This commit unifies the behaviour so that the whole argument string is checked, in order to list the next 10, or previous 10 lines from a file only 'list +' and 'list -' are now valid. gdb/ChangeLog: * cli/cli-cmds.c (list_command): Check that the argument string is a single character, either '+' or '-'. gdb/testsuite/ChangeLog: * gdb.base/list.exp (test_list_invalid_args): New function, defined, and called.
2015-12-11gdb: Make test names unique in list.exp.Andrew Burgess2-2/+10
gdb/testsuite/ChangeLog: * gdb.base/list.exp (test_list): Make test names unique.
2015-12-11gdb: Small code restructure for list_command.Andrew Burgess2-17/+16
Move handling of special +/- arguments to the list_command function inside a single if block, this helps group all related functionality together. There should be no user visible changes after this commit. gdb/ChangeLog: * cli/cli-cmds.c (list_command): Move all handling of +/- arguments into a single if block.
2015-12-11gdb: Use NULL instead of 0 for pointer comparison.Andrew Burgess2-2/+7
Small code cleanup, use NULL instead of 0 when checking pointers. There should be no user visible changes after this commit. gdb/ChangeLog: * cli/cli-cmds.c (list_command): Use NULL instead of 0 when checking pointers.
2015-12-11gdb: Make lines_to_list variable static.Andrew Burgess2-1/+5
Small clean up, make variable static. gdb/ChangeLog: * source.c (lines_to_list): Make static.