aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2014-09-19Refactor ptrace extended event status.Don Breazeal6-9/+51
This commit implements functions for identifying and extracting extended ptrace event information from a Linux wait status. These are just convenience functions intended to hide the ">> 16" used to extract the event from the wait status word, replacing the hard-coded shift with a more descriptive function call. This is preparatory work for implementation of follow-fork and detach-on-fork for extended-remote linux targets. gdb/ChangeLog: * linux-nat.c (linux_handle_extended_wait): Call linux_ptrace_get_extended_event. (wait_lwp): Call linux_is_extended_waitstatus. (linux_nat_filter_event): Call linux_ptrace_get_extended_event and linux_is_extended_waitstatus. * nat/linux-ptrace.c (linux_test_for_tracefork): Call linux_ptrace_get_extended_event. (linux_ptrace_get_extended_event): New function. (linux_is_extended_waitstatus): New function. * nat/linux-ptrace.h (linux_ptrace_get_extended_event) (linux_is_extended_waitstatus): New declarations. gdb/gdbserver/ChangeLog: * linux-low.c (handle_extended_wait): Call linux_ptrace_get_extended_event. (get_stop_pc, get_detach_signal, linux_low_filter_event): Call linux_is_extended_waitstatus. ---
2014-09-19Run dw2-var-zero-addr.exp with --readnowYao Qi2-3/+21
This patch is to extend dw2-var-zero-add.exp to cover the case that partial symtabl is not used while full symtab is used, in order to cover the changes in patch 2/3. This patch restarts GDB with --readnow and does the same test again. gdb/testsuite: 2014-09-19 Yao Qi <yao@codesourcery.com> * gdb.dwarf2/dw2-var-zero-addr.exp: Move test into new proc test. Invoke test. Restart GDB with --readnow and invoke test again.
2014-09-19Check function is GC'edYao Qi4-16/+59
I see the following fail on arm-none-eabi target, (gdb) b 24^M Breakpoint 1 at 0x4: file ../../../../git/gdb/testsuite/gdb.base/break-on-linker-gcd-function.cc, line 24.^M (gdb) FAIL: gdb.base/break-on-linker-gcd-function.exp: b 24 Currently, we are using flag has_section_at_zero to determine whether address zero in debug info means the corresponding code has been GC'ed, like this: case DW_LNE_set_address: address = read_address (abfd, line_ptr, cu, &bytes_read); if (address == 0 && !dwarf2_per_objfile->has_section_at_zero) { /* This line table is for a function which has been GCd by the linker. Ignore it. PR gdb/12528 */ However, this is incorrect on some bare metal targets, as .text section is located at 0x0, so dwarf2_per_objfile->has_section_at_zero is true. If a function is GC'ed by linker, the address is zero. GDB thinks address zero is a function's address rather than this function is GC'ed. In this patch, we choose 'lowpc' got in read_file_scope to check whether 'lowpc' is greater than zero. If it isn't, address zero really means the function is GC'ed. In this patch, we pass 'lowpc' in read_file_scope through handle_DW_AT_stmt_list and dwarf_decode_lines, and to dwarf_decode_lines_1 finally. This patch fixes the fail above. This patch also covers the path that partial symbol isn't used, which is tested by starting gdb with --readnow option. It is regression tested on x86-linux with target_board=dwarf4-gdb-index, and arm-none-eabi. OK to apply? gdb: 2014-09-19 Yao Qi <yao@codesourcery.com> * dwarf2read.c (dwarf_decode_lines): Update declaration. (handle_DW_AT_stmt_list): Add argument 'lowpc'. Update comments. Callers update. (dwarf_decode_lines): Likewise. (dwarf_decode_lines_1): Add argument 'lowpc'. Update comments. Skip the line table if 'lowpc' is greater than 'address'. Don't check dwarf2_per_objfile->has_section_at_zero. gdb/testsuite: 2014-09-19 Yao Qi <yao@codesourcery.com> * gdb.base/break-on-linker-gcd-function.exp: Move test into new proc set_breakpoint_on_gcd_function. Invoke set_breakpoint_on_gcd_function. Restart GDB with --readnow and invoke set_breakpoint_on_gcd_function again.
2014-09-18New "producer" attribute of python gdb.Symtab.Doug Evans7-1/+150
gdb/ChangeLog: * NEWS: Mention new "producer" attribute of gdb.Symtab. * python/py-symtab.c (stpy_get_producer): New function. (symtab_object_getset): Add "producer" attribute. gdb/doc/ChangeLog: * python.texi (Symbol Tables In Python): Document "producer" attribute of gdb.Symtab objects. gdb/testsuite/ChangeLog: * gdb.dwarf2/symtab-producer.exp: New file.
2014-09-17PR gdb/17384: Do not print memory errors in safe_read_memory_integerUlrich Weigand2-45/+13
If accessing memory via safe_read_memory_integer fails, that function used to print an error message even though callers were perfectly able to handle (and even expected!) failures. This patch removes the confusing message by changing the routine to directly use target_read_memory. gdb/ChangeLog: PR gdb/17384 * corefile.c (struct captured_read_memory_integer_arguments): Remove. (do_captured_read_memory_integer): Remove. (safe_read_memory_integer): Use target_read_memory directly instead of catching errors in do_captured_read_memory_integer.
2014-09-16Add test for global variable that is nested by another DSOSergio Durigan Junior5-0/+134
This is just a testcase addition that I am proposing for upstream GDB. We have this in our internal tree, and the related RH bug is: <https://bugzilla.redhat.com/show_bug.cgi?id=809179> (You might not be able to see all the comments without privileges.) This bug is about a global variable that got incorrectly displayed by GDB. This bug has already been fixed a long time ago by Joel's commit: commit 19630284f570790ebf6d50bfb43caa1f125ee88a Author: Joel Brobecker <brobecker@gnat.com> Date: Tue Jun 5 13:50:50 2012 +0000 But I think a testcase for it wouldn't hurt. So, consider the following scenario: $ cat solib1.c int test; void c_main (void) { test = 42; } $ cat solib2.c int test; void b_main (void) { test = 42; } $ cat main.c int main (int argc, char *argv[]) { c_main (); b_main (); return 0; } $ gcc -g -fPIC -shared -o libSO1.so -c solib1.c $ gcc -g -fPIC -shared -o libSO2.so -c solib2.c $ gcc -g -o main -L$PWD -lSO1 -lSO2 main.c $ LD_LIBRARY_PATH=. gdb -q -batch -ex 'b c_main' -ex r -ex n -ex 'p test' ./main ... $1 = 0 This happened with GDB before Joel's commit above. Now, things work and GDB is able to correctly display the nested global variable: $ LD_LIBRARY_PATH=. gdb -q -batch -ex 'b c_main' -ex r -ex n -ex 'p test' ./main ... $1 = 42 The testcase attached tests this behavior. gdb/testsuite/ChangeLog: 2014-09-16 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/global-var-nested-by-dso-solib1.c: New file. * gdb.base/global-var-nested-by-dso-solib2.c: Likewise. * gdb.base/global-var-nested-by-dso.c: Likewise. * gdb.base/global-var-nested-by-dso.exp: Likewise.
2014-09-16CONTRIBUTE: For internals refer to wiki, not gdb/docMaciej W. Rozycki2-3/+9
2014-09-16Fix CPPFLAGS handling in gdbserver's build.Joel Brobecker2-2/+9
In gdb/gdbserver/Makefile.in, IPAGENT_CFLAGS is defined using an expression which references $(CPPFLAGS). But CPPFLAGS isn't actually defined. This patch first adds a CPPFLAGS definition, so as to inherit the value passed at configure time (if any). And it then makes it part of INTERNAL_CFLAGS_BASE, instead. There is no reason that CPPFLAGS be useful for a certain class of source files, and not the rest. This is also consistent with what's done in GDB. gdb/gdbserver/ChangeLog: * Makefile.in (CPPFLAGS): Define. (INTERNAL_CFLAGS_BASE): Add ${CPPFLAGS}. (IPAGENT_CFLAGS): Remove ${CPPFLAGS}. Tested by rebuilding GDBserver with a dummy CPPFLAGS, and verifying that the compilation command was altered as expected.
2014-09-16Remove dead code from objc-lang.c (spurious "fprintf (stderr...")Sergio Durigan Junior2-5/+4
This obvious change removes dead code from objc-lang.c. I was grepping for "fprintf (stderr..." and found this code between "#if 0".."#endif" blocks. 2014-09-16 Sergio Durigan Junior <sergiodj@redhat.com> * objc-lang.c (find_implementation_from_class): Remove dead code.
2014-09-16Replace "fprintf (stderr..." by "fprintf_unfiltered (gdb_stdlog..."Sergio Durigan Junior2-11/+21
This is an obvious replacement of "fprintf (stderr..." by "fprintf_unfiltered (gdb_stdlog...", which is the standard to use in these cases. gdb/ChangeLog: 2014-09-16 Sergio Durigan Junior <sergiodj@redhat.com> PR cli/7233 * linux-nat.c (linux_nat_wait_1): Replace "fprintf (stderr..." by "fprintf_unfiltered (gdb_stdlog...)".
2014-09-16gdb.base/watch-bitfields.exp: Improve testSergio Durigan Junior2-26/+62
Make test messages unique and a couple other tweaks. gdb/testsuite/ 2014-09-16 Sergio Durigan Junior <sergiodj@redhat.com> Pedro Alves <palves@redhat.com> * gdb.base/watch-bitfields.exp: Pass string other than test file name to prepare_for_testing. (watch): New procedure. (expect_watchpoint): Use with_test_prefix. (top level): Factor out tests to ... (test_watch_location, test_regular_watch): ... these new procedures, and use with_test_prefix and gdb_continue_to_end.
2014-09-16Fix PR12526: -location watchpoints for bitfield argumentsPatrick Palka8-2/+214
PR 12526 reports that -location watchpoints against bitfield arguments trigger false positives when bits around the bitfield, but not the bitfield itself, are modified. This happens because -location watchpoints naturally operate at the byte level, not at the bit level. When the address of a bitfield lvalue is taken, information about the bitfield (i.e. its offset and size) is lost in the process. This information must first be retained throughout the lifetime of the -location watchpoint. This patch achieves this by adding two new fields to the watchpoint struct: val_bitpos and val_bitsize. These fields are set when a watchpoint is first defined in watch_command_1. They are both equal to zero if the watchpoint is not a -location watchpoint or if the argument is not a bitfield. Then these bitfield parameters are used inside update_watchpoint and watchpoint_check to extract the actual value of the bitfield from the watchpoint address, with the help of a local helper function extract_bitfield_from_watchpoint_value. Finally when creating a HW breakpoint pointing to a bitfield, we optimize the address and length of the breakpoint. By skipping over the bytes that don't cover the bitfield, this step reduces the frequency at which a read watchpoint for the bitfield is triggered. It also reduces the number of times a false-positive call to check_watchpoint is triggered for a write watchpoint. gdb/ PR breakpoints/12526 * breakpoint.h (struct watchpoint): New fields val_bitpos and val_bitsize. * breakpoint.c (watch_command_1): Use these fields to retain bitfield information. (extract_bitfield_from_watchpoint_value): New function. (watchpoint_check): Use it. (update_watchpoint): Use it. Optimize the address and length of a HW watchpoint pointing to a bitfield. * value.h (unpack_value_bitfield): New prototype. * value.c (unpack_value_bitfield): Make extern. gdb/testsuite/ PR breakpoints/12526 * gdb.base/watch-bitfields.exp: New file. * gdb.base/watch-bitfields.c: New file.
2014-09-16Remove documention of dead "target vxworks"Pedro Alves2-170/+10
"target vxworks" and friends have been removed 10 years ago already: commit e84ecc995d6a5e4e9114d3cea61717b8a573afb6 Author: Andrew Cagney <cagney@redhat.com> AuthorDate: Sat Nov 13 23:10:02 2004 +0000 2004-11-13 Andrew Cagney <cagney@gnu.org> * configure.tgt: Delete i[34567]86-*-vxworks*, m68*-netx-*, m68*-*-vxworks*, mips*-*-vxworks*, powerpc-*-vxworks*, and sparc-*-vxworks*. * NEWS: Mention that vxworks was deleted. (...) * remote-vxmips.c, remote-vx.c: Delete. * remote-vx68.c: Delete. (...) This removes related leftover cruft from the manual. gdb/doc/ 2014-09-16 Pedro Alves <palves@redhat.com> * gdb.texinfo (Starting) <run command>: Don't mention VxWorks. (Embedded OS): Remove VxWorks menu entry. (VxWorks): Remove node.
2014-09-16Rename current_inferior as current_thread in gdbserverGary Benson28-245/+277
GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-16Fix watchpoint-stops-at-right-insn.expPedro Alves2-1/+7
Silly typo... gdb/testsuite/ 2014-09-16 Pedro Alves <palves@redhat.com> * gdb.base/watchpoint-stops-at-right-insn.exp (test): Compare software and hardware addresses, not software address against itself.
2014-09-16Add test to make sure GDB knows which "kind" of watchpoint the target hasPedro Alves3-0/+215
This adds a test that makes sure GDB knows whether the target has continuable, or non-continuable watchpoints. That is, the test confirms that GDB presents a watchpoint value change at the first instruction right after the instruction that changes memory. gdb/testsuite/ChangeLog: 2014-09-16 Pedro Alves <palves@redhat.com> * gdb.base/watchpoint-stops-at-right-insn.c: New file. * gdb.base/watchpoint-stops-at-right-insn.exp: New file.
2014-09-16Add hardware watchpoint support for x86 GNU Hurd.Samuel Thibault6-1/+188
gdb/ * config/i386/i386gnu.mh (NATDEPFILES): Add x86-nat.o and x86-dregs.o. * gnu-nat.c (inf_threads): New function. * gnu-nat.h (inf_threads_ftype): New typedef. (inf_threads): New declaration. * i386gnu-nat.c: Include "x86-nat.h" and "inf-child.h". [i386_DEBUG_STATE] (i386_gnu_dr_get, i386_gnu_dr_set) (i386_gnu_dr_set_control_one, i386_gnu_dr_set_control) (i386_gnu_dr_set_addr_one, i386_gnu_dr_set_addr) (i386_gnu_dr_get_reg, i386_gnu_dr_get_addr, 386_gnu_dr_get_status) (i386_gnu_dr_get_control): New functions. (reg_addr): New structure. (_initialize_i386gnu_nat) [i386_DEBUG_STATE]: Initialize hardware i386 debugging register hooks. * NEWS: Mention this.
2014-09-16Remove support for testing against dead "target vxworks"Pedro Alves15-492/+54
"target vxworks" and friends have been removed 10 years ago already: commit e84ecc995d6a5e4e9114d3cea61717b8a573afb6 Author: Andrew Cagney <cagney@redhat.com> AuthorDate: Sat Nov 13 23:10:02 2004 +0000 2004-11-13 Andrew Cagney <cagney@gnu.org> * configure.tgt: Delete i[34567]86-*-vxworks*, m68*-netx-*, m68*-*-vxworks*, mips*-*-vxworks*, powerpc-*-vxworks*, and sparc-*-vxworks*. * NEWS: Mention that vxworks was deleted. (...) * remote-vxmips.c, remote-vx.c: Delete. * remote-vx68.c: Delete. (...) This removes related leftover cruft from the testsuite. Tested on x86_64 Fedora 20, native and gdbserver. gdb/testsuite/ 2014-09-16 Pedro Alves <palves@redhat.com> * config/vx.exp, config/vxworks.exp, config/vxworks29k.exp: Delete files. * gdb.base/a2-run.exp: Remove all code guarded by istarget "*-*-vxworks*" throughout. * gdb.base/break.exp: Likewise. * gdb.base/default.exp: Likewise. * gdb.base/scope.exp: Likewise. * gdb.base/sepdebug.exp: Likewise. * gdb.base/break.c: Remove all code guarded by #ifdef vxworks throughout. * gdb.base/run.c: Likewise. * gdb.base/sepdebug.c: Likewise. * gdb.hp/gdb.aCC/run.c: Likewise. * gdb.reverse/until-reverse.c: Likewise. * lib/gdb.exp (gdb_compile): Remove is_vxworks branch.
2014-09-16Another board file for remote hostYao Qi2-0/+89
In the recent review to my patch about copying files to remote host, we find that we need a board file which is more closely mapped real remote host testing to improve coverage. With the board file local-remote-host-native.exp, DejaGNU copies files to $build/gdb/testsuite/remote-host to emulate the effect of remote host. Is it OK? gdb/testsuite: 2014-09-16 Yao Qi <yao@codesourcery.com> * boards/local-remote-host-native.exp: New file.
2014-09-16Implement support for recording vector data transfer instructionsOmair Javaid2-1/+103
gdb: 2014-08-13 Omair Javaid <omair.javaid@linaro.org> * arm-tdep.c (arm_record_vdata_transfer_insn): Added record handler for vector data transfer instructions. (arm_record_coproc_data_proc): Updated.
2014-09-16Implement support for recording extension register ld/st insnOmair Javaid2-2/+183
gdb: 2014-08-13 Omair Javaid <omair.javaid@linaro.org> * arm-tdep.c (arm_record_asimd_vfp_coproc): Replace stub handler with arm_record_exreg_ld_st_insn. (arm_record_exreg_ld_st_insn): Add record handler for ex-register load/store insns.
2014-09-16Implement support for recording VFP data processing instructionsOmair Javaid2-1/+218
gdb: 2014-08-13 Omair Javaid <omair.javaid@linaro.org> * arm-tdep.c (arm_record_coproc_data_proc): Updated. (arm_record_vfp_data_proc_insn): Added record handler for VFP data processing instructions.
2014-09-16Implement support for recording thumb2 ASIMD struct ld/st insnsOmair Javaid2-1/+197
gdb: 2014-08-13 Omair Javaid <omair.javaid@linaro.org> * arm-tdep.c (thumb2_record_asimd_struct_ld_st): Add record handler for advance SIMD struct ld/st insn. (thumb2_record_decode_insn_handler): Replace stub handler with thumb2_record_asimd_struct_ld_st.
2014-09-16Implement support for recording arm/thumb mode coprocessor instructionsOmair Javaid2-10/+122
gdb: 2014-08-13 Omair Javaid <omair.javaid@linaro.org> * arm-tdep.c (arm_record_coproc_data_proc): Add record handler stubs for asimd, vfp and coprocessor insns. (arm_record_asimd_vfp_coproc): Add record handler for asimd, vfp and coprocessor insns. (thumb2_record_coproc_insn): New function. (thumb2_record_decode_insn_handler): Update coprocessor insns record handlers. (decode_insn): Install arm_record_asimd_vfp_coproc as handler for opcode 110 insns.
2014-09-14Fix set up of queue-signal.exp test.Doug Evans2-0/+47
The test does a backtrace to see which thread (#2 or #3) is assigned to which SIGUSR (1 or 2). If the main thread gets to all_threads_running before the sigusr threads get to their entry point, then the function name isn't in the backtrace and the test fails. Alas this version of the code is within epsilon of what I started with, and then over-simplified things.
2014-09-13New command queue-signal.Doug Evans8-6/+297
If I want to change the signalled state of multiple threads it's a bit cumbersome to do with the "signal" command. What you really want is a way to set the signal state of the desired threads and then just do "continue". This patch adds a new command, queue-signal, to accomplish this. Basically "signal N" == "queue-signal N" + "continue". That's not precisely true in that "signal" can be used to inject any signal, including signals set to "nopass"; whereas "queue-signal" just queues the signal as if the thread stopped because of it. "nopass" handling is done when the thread is resumed which "queue-signal" doesn't do. One could add extra complexity to allow queue-signal to be used to deliver "nopass" signals like the "signal" command. I have no current need for it so in the interests of incremental complexity, I have left such support out and just have the code flag an error if one tries to queue a nopass signal. gdb/ChangeLog: * NEWS: Mention new "queue-signal" command. * infcmd.c (queue_signal_command): New function. (_initialize_infcmd): Add new queue-signal command. gdb/doc/ChangeLog: * gdb.texinfo (Signaling): Document new queue-signal command. gdb/testsuite/ChangeLog: * gdb.threads/queue-signal.c: New file. * gdb.threads/queue-signal.exp: New file.
2014-09-13 * linux-nat.c (wait_lwp): Add debugging printf.Doug Evans2-0/+9
(linux_nat_wait_1): Ditto.
2014-09-13Pass plain-text prompt to with_gdb_prompt.Doug Evans3-3/+38
I had occasion to use with_gdb_prompt in a test for the patch for PR 17314 and was passing the plain text prompt as the value, "(top-gdb)", instead of a regexp, "\(top-gdb\)" (expressed as "\\(top-gdb\\)" in TCL). I then discovered that in order to restore the prompt gdb passes the original value of $gdb_prompt to "set prompt", which works because "set prompt \(gdb\) " is equivalent to "set prompt (gdb) ". Perhaps I'm being overly cautious but this feels a bit subtle, but at any rate as an API choice I'd much rather pass the plain text form to with_gdb_prompt. I also discovered that the initial value of gdb_prompt is set in two places to two different values. At the global level gdb.exp sets it to "\[(\]gdb\[)\]" and default_gdb_init sets it to "\\(gdb\\)". The former form is undesirable as an argument to "set prompt", but it's not clear to me that just deleting this code won't break anything. Thus I just changed the value to be consistent and added a comment. gdb/testsuite/ChangeLog: * lib/gdb.exp (gdb_prompt): Add comment and change initial value to be consistent with what default_gdb_init uses. (with_gdb_prompt): Change form of PROMPT argument from a regexp to the plain text of the prompt. Add some logging printfs. * gdb.perf/disassemble.exp: Update call to with_gdb_prompt.
2014-09-12after gdb_run_cmd, gdb_expect -> gdb_test_multiple/gdb_testPedro Alves21-463/+125
See: https://sourceware.org/ml/gdb-patches/2014-09/msg00404.html We have a number of places that do gdb_run_cmd followed by gdb_expect, when it would be better to use gdb_test_multiple or gdb_test. This converts all that "grep gdb_run_cmd -A 2 | grep gdb_expect" found. Tested on x86_64 Fedora 20, native and gdbserver. gdb/testsuite/ 2014-09-12 Pedro Alves <palves@redhat.com> * gdb.arch/gdb1558.exp: Replace uses of gdb_expect after gdb_run_cmd with gdb_test_multiple or gdb_test throughout. * gdb.arch/i386-size-overlap.exp: Likewise. * gdb.arch/i386-size.exp: Likewise. * gdb.arch/i386-unwind.exp: Likewise. * gdb.base/a2-run.exp: Likewise. * gdb.base/break.exp: Likewise. * gdb.base/charset.exp: Likewise. * gdb.base/chng-syms.exp: Likewise. * gdb.base/commands.exp: Likewise. * gdb.base/dbx.exp: Likewise. * gdb.base/find.exp: Likewise. * gdb.base/funcargs.exp: Likewise. * gdb.base/jit-simple.exp: Likewise. * gdb.base/reread.exp: Likewise. * gdb.base/sepdebug.exp: Likewise. * gdb.base/step-bt.exp: Likewise. * gdb.cp/mb-inline.exp: Likewise. * gdb.cp/mb-templates.exp: Likewise. * gdb.objc/basicclass.exp: Likewise. * gdb.threads/killed.exp: Likewise.
2014-09-12[IRIX] eliminate deprecated_insert_raw_breakpoint usesPedro Alves5-119/+102
The IRIX support wants to set a breakpoint to be hit when the startup phase is complete, which is where shared libraries have been mapped in. AFAIU, for most IRIX ports, that location is the entry point. For MIPS IRIX however, GDB needs to set a breakpoint earlier, in __dbx_link, as explained by: #ifdef SYS_syssgi /* On mips-irix, we need to stop the inferior early enough during the startup phase in order to be able to load the shared library symbols and insert the breakpoints that are located in these shared libraries. Stopping at the program entry point is not good enough because the -init code is executed before the execution reaches that point. So what we need to do is to insert a breakpoint in the runtime loader (rld), more precisely in __dbx_link(). This procedure is called by rld once all shared libraries have been mapped, but before the -init code is executed. Unfortuantely, this is not straightforward, as rld is not part of the executable we are running, and thus we need the inferior to run until rld itself has been mapped in memory. For this, we trace all syssgi() syscall exit events. Each time we detect such an event, we iterate over each text memory maps, get its associated fd, and scan the symbol table for __dbx_link(). When found, we know that rld has been mapped, and that we can insert the breakpoint at the symbol address. Once the dbx_link() breakpoint has been inserted, the syssgi() notifications are no longer necessary, so they should be canceled. */ proc_trace_syscalls_1 (pi, SYS_syssgi, PR_SYSEXIT, FLAG_SET, 0); #endif The loop in irix_solib_create_inferior_hook then runs until whichever breakpoint is hit first, the one set by solib-irix.c or the one set by procfs.c. Note the comment in disable_break talks about __dbx_init, but I think that's a typo for __dbx_link: - /* Note that it is possible that we have stopped at a location that - is different from the location where we inserted our breakpoint. - On mips-irix, we can actually land in __dbx_init(), so we should - not check the PC against our breakpoint address here. See procfs.c - for more details. */ This looks very much like referring to the loop in irix_solib_create_inferior_hook stopping at __dbx_link instead of at the entry point. What this patch does is convert these deprecated raw breakpoints to standard solib_event breakpoints. When the first solib-event breakpoint is hit, we delete all solib-event breakpoints. We do that in the so_ops->handle_event hook. This allows getting rid of the loop in irix_solib_create_inferior_hook completely, which should allow properly handling signals and other events in the early startup phase, like in SVR4. Built on x86_64 Fedora 20 with --enable-targets=all (builds solib-irix.c). Joel tested that with an earlier version of this patch "info shared" after starting a program gave the same list of shared libraries as before. gdb/ChangeLog: 2014-09-12 Pedro Alves <palves@redhat.com> * breakpoint.c (remove_solib_event_breakpoints_at_next_stop) (create_and_insert_solib_event_breakpoint): New functions. * breakpoint.h (create_and_insert_solib_event_breakpoint) (remove_solib_event_breakpoints_at_next_stop): New declarations. * procfs.c (dbx_link_bpt_addr, dbx_link_bpt): Delete globals. (remove_dbx_link_breakpoint): Delete function. (insert_dbx_link_bpt_in_file): Use create_and_insert_solib_event_breakpoint instead of deprecated_insert_raw_breakpoint. (procfs_wait): Don't check whether we hit __dbx_link here. (procfs_mourn_inferior): Don't delete the __dbx_link breakpoint here. * solib-irix.c (base_breakpoint): Delete global. (disable_break): Delete function. (enable_break): Use create_solib_event_breakpoint instead of deprecated_insert_raw_breakpoint. (irix_solib_handle_event): New function. (irix_solib_create_inferior_hook): Don't run the target or disable the mapping-complete breakpoint here. (_initialize_irix_solib): Install irix_solib_handle_event as so_ops->handle_event hook.
2014-09-12PR tdep/17379: Fix internal-error when stack pointer is invalid.Edjunior Barbosa Machado5-3/+87
The problem is that rs6000_frame_cache attempts to read the stack backchain via read_memory_unsigned_integer, which throws an exception if the stack pointer is invalid. With this patch, it calls safe_read_memory_integer instead, which doesn't throw an exception and allows for safe handling of that situation. gdb/ChangeLog 2014-09-12 Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com> Ulrich Weigand  <uweigand@de.ibm.com> PR tdep/17379 * rs6000-tdep.c (rs6000_frame_cache): Use safe_read_memory_integer instead of read_memory_unsigned_integer. gdb/testcase/ChangeLog 2014-09-12 Edjunior Barbosa Machado <emachado@linux.vnet.ibm.com> PR tdep/17379 * gdb.arch/powerpc-stackless.S: New file. * gdb.arch/powerpc-stackless.exp: New file.
2014-09-12testsuite: Fix runaway attach processesJan Kratochvil3-6/+15
I have started seeing occasional runaway 'attach' processes these days. I cannot be certain it is really caused by this patch, for example grep 'FAIL.*cmdline attach run' does not show anything in my logs. But as I remember this 'attach' runaway process always happened in GDB (but I do not remember it in the past months) I think it would be most safe to just solve it forever by [attached]. gdb/testsuite/ChangeLog 2014-09-12 Jan Kratochvil <jan.kratochvil@redhat.com> * gdb.base/attach.c: Include unistd.h. (main): Call alarm. Add label postloop. * gdb.base/attach.exp (do_attach_tests): Use gdb_get_line_number, gdb_breakpoint, gdb_continue_to_breakpoint. (test_command_line_attach_run): Kill ${testpid} in one exit path.
2014-09-12Clarify GDBSERVER use in linux-waitpid.cGary Benson2-5/+13
This commit makes linux-waitpid.c include common-defs.h. GDB's inclusion of defs.h is removed, but gdbserver's inclusion of server.h remains to support some gdbserver-specific debug code that cannot presently be merged. A new FIXME documents this. gdb/ChangeLog: * nat/linux-waitpid.c: Include common-defs.h. [GDBSERVER]: Add FIXME comment. [!GDBSERVER]: Don't include defs.h or signal.h. (linux_debug) [!GDBSERVER]: Remove empty block.
2014-09-12Remove GDBSERVER uses from x86-dregs.cGary Benson2-6/+7
This commit makes nat/x86-dregs.c include common-defs.h rather than defs.h or server.h. An extra header required including in order to support this change. gdb/ChangeLog: * nat/x86-dregs.c: Include common-defs.h and break-common.h. Don't include defs.h or server.h.
2014-09-12Remove GDBSERVER uses from linux-btrace.cGary Benson3-7/+9
This commit makes nat/linux-btrace.c include common-defs.h rather than defs.h or server.h. A couple of minor changes were required to support this change. gdb/ChangeLog: * nat/linux-btrace.c: Include common-defs.h. Don't include defs.h, server.h or gdbthread.h. * nat/linux-btrace.h (struct target_ops): New forward declaration.
2014-09-12Include common-defs.h instead of defs.h/server.h in shared codeGary Benson20-106/+42
This commit makes 19 of the 22 shared .c files in common, nat and target include common-defs.h instead of defs.h/server.h. The remaining three files need slight extra work and are dealt with in separate commits. gdb/ChangeLog: * common/agent.c: Include common-defs.h. Don't include defs.h or server.h. * common/buffer.c: Likewise. * common/common-debug.c: Likewise. * common/common-utils.c: Likewise. * common/errors.c: Likewise. * common/filestuff.c: Likewise. * common/format.c: Likewise. * common/gdb_vecs.c: Likewise. * common/print-utils.c: Likewise. * common/ptid.c: Likewise. * common/rsp-low.c: Likewise. * common/signals.c: Likewise. * common/vec.c: Likewise. * common/xml-utils.c: Likewise. * nat/linux-osdata.c: Likewise. * nat/linux-procfs.c: Likewise. * nat/linux-ptrace.c: Likewise. * nat/mips-linux-watch.c: Likewise. * target/waitstatus.c: Likewise.
2014-09-12Introduce common-regcache.hGary Benson9-9/+80
This introduces common-regcache.h. This contains two functions that allow nat/linux-btrace.c to be simplified. A better long term solution would be unify the regcache code, but this is sufficient for now. gdb/ChangeLog: * common/common-regcache.h: New file. * Makefile.in (HFILES_NO_SRCDIR): Add common/common-regcache.h. * regcache.h: Include common-regcache.h. (regcache_read_pc): Don't declare. * regcache.c (get_thread_regcache_for_ptid): New function. * nat/linux-btrace.c: Don't include regcache.h. Include common-regcache.h. (perf_event_read_bts): Use get_thread_regcache_for_ptid. gdb/gdbserver/ChangeLog: * regcache.h: Include common-regcache.h. (regcache_read_pc): Don't declare. * regcache.c (get_thread_regcache_for_ptid): New function.
2014-09-11Make gdb/regcache.h self-contained.Thomas Schwinge2-0/+5
gdb/ * regcache.h (struct regset): Declare. Commit 0b3092721e5cfa1697f1dafe81efefdbb0236f21 added uses of struct regset to gdb/regcache.h, but that struct is not declared in this file, and, as it happens, also nowhere else in the #include chain on x86 GNU/Hurd. This results in warnings/errors such as: gcc-4.8 [...] ../../W._C._Handy/gdb/gdb.c In file included from ./nm.h:25:0, from ../../W._C._Handy/gdb/defs.h:454, from ../../W._C._Handy/gdb/gdb.c:19: ../../W._C._Handy/gdb/regcache.h:190:9: warning: 'struct regset' declared inside parameter list [enabled by default] size_t size); ^ ../../W._C._Handy/gdb/regcache.h:190:9: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default] ../../W._C._Handy/gdb/regcache.h:193:10: warning: 'struct regset' declared inside parameter list [enabled by default] int regnum, void *buf, size_t size); ^
2014-09-11gdb/17347 - Regression: GDB stopped on run with attached processPedro Alves7-10/+115
Doing: gdb --pid=PID -ex run Results in GDB getting a SIGTTIN, and thus ending stopped. That's usually indicative of a missing target_terminal_ours call. E.g., from the PR: $ sleep 1h & p=$!; sleep 0.1; gdb -batch sleep $p -ex run [1] 28263 [1] Killed sleep 1h [2]+ Stopped gdb -batch sleep $p -ex run The workaround is doing: gdb -ex "attach $PID" -ex "run" instead of gdb [-p] $PID -ex "run" With the former, gdb waits for the attach command to complete before moving on to the "run" command, because the interpreter is in sync mode at this point, within execute_command. But for the latter, attach_command is called directly from captured_main, and thus misses that waiting. IOW, "run" is running before the attach continuation has run, before the program stops and attach completes. The broken terminal settings are just one symptom of that. Any command that queries or requires input results in the same. The fix is to wait in catch_command_errors (which is specific to main.c nowadays), just like we wait in execute_command. gdb/ChangeLog: 2014-09-11 Pedro Alves <palves@redhat.com> PR gdb/17347 * main.c: Include "infrun.h". (catch_command_errors, catch_command_errors_const): Wait for the foreground command to complete. * top.c (maybe_wait_sync_command_done): New function, factored out from ... (maybe_wait_sync_command_done): ... here. * top.h (maybe_wait_sync_command_done): New declaration. gdb/testsuite/ChangeLog: 2014-09-11 Pedro Alves <palves@redhat.com> PR gdb/17347 * lib/gdb.exp (gdb_spawn_with_cmdline_opts): New procedure. * gdb.base/attach.exp (test_command_line_attach_run): New procedure. (top level): Call it.
2014-09-11testsuite: refactor spawn and wait for attachPedro Alves8-83/+48
Several places in the testsuite have a copy of a snippet of code that spawns a test program, waits a bit, and then does some PID munging for Cygwin. This is in order to have GDB attach to the spawned program. This refactors all that to a common procedure. (multi-attach.exp wants to spawn multiple processes, so this makes the new procedure's interface work with lists.) Tested on x86_64 Fedora 20. gdb/testsuite/ChangeLog: 2014-09-11 Pedro Alves <palves@redhat.com> * lib/gdb.exp (spawn_wait_for_attach): New procedure. * gdb.base/attach.exp (do_attach_tests, do_call_attach_tests) (do_command_attach_tests): Use spawn_wait_for_attach. * gdb.base/solib-overlap.exp: Likewise. * gdb.multi/multi-attach.exp: Likewise. * gdb.python/py-prompt.exp: Likewise. * gdb.python/py-sync-interp.exp: Likewise. * gdb.server/ext-attach.exp: Likewise.
2014-09-11Introduce common/symbol.hGary Benson8-15/+108
This introduces common/symbol.h. This file declares a function that the shared code can use and that the clients must implement. It also changes some shared code to use these functions. gdb/ChangeLog: * common/symbol.h: New file. * Makefile.in (HFILES_NO_SRCDIR): Add common/symbol.h. * minsyms.c (find_minimal_symbol_address): New function. * common/agent.c: Include common/symbol.h. [!GDBSERVER]: Don't include objfiles.h. (agent_look_up_symbols): Use find_minimal_symbol_address. gdb/gdbserver/ChangeLog: * symbol.c: New file. * Makefile.in (SFILES): Add symbol.c. (OBS): Add symbol.o.
2014-09-11Introduce target_{stop,continue}_ptidGary Benson6-35/+85
This commit introduces two new functions to stop and restart target processes that shared code can use and that clients must implement. It also changes some shared code to use these functions. gdb/ChangeLog: * target/target.h (target_stop_ptid, target_continue_ptid): Declare. * target.c (target_stop_ptid, target_continue_ptid): New functions. * common/agent.c [!GDBSERVER]: Don't include infrun.h. (agent_run_command): Always use target_stop_ptid and target_continue_ptid. gdb/gdbserver/ChangeLog: * target.c (target_stop_ptid, target_continue_ptid): New functions.
2014-09-11Introduce target/target.hGary Benson9-49/+139
This introduces target/target.h. This file declares some functions that the shared code can use and that clients must implement. It also changes some shared code to use these functions. gdb/ChangeLog: * target/target.h: New file. * Makefile.in (HFILES_NO_SRCDIR): Add target/target.h. * target.h: Include target/target.h. (target_read_memory, target_write_memory): Don't declare. * target.c (target_read_uint32): New function. * common/agent.c: Include target/target.h. [!GDBSERVER]: Don't include target.h. (helper_thread_id): Type changed to uint32_t. (agent_get_helper_thread_id): Use target_read_uint32. (agent_run_command): Always use target_read_memory and target_write_memory. (agent_capability): Type changed to uint32_t. (agent_capability_check): Use target_read_uint32. gdb/gdbserver/ChangeLog: * target.h: Include target/target.h. * target.c (target_read_memory, target_read_uint32) (target_write_memory): New functions.
2014-09-11Introduce show_debug_regsGary Benson11-54/+63
This commit adds a new global flag show_debug_regs to common-debug.h to replace the flag debug_hw_points used by gdbserver and by the Linux x86 and AArch64 ports, and to replace the flag maint_show_dr used by the Linux MIPS port. Note that some debug printing in the AArch64 port was enabled only if debug_hw_points > 1 but no way to set debug_hw_points to values other than 0 and 1 was provided; that code was effectively dead. This commit enables all debug printing if show_debug_regs is nonzero, so the AArch64 output will be more verbose than previously. gdb/ChangeLog: * common/common-debug.h (show_debug_regs): Declare. * common/common-debug.c (show_debug_regs): Define. * aarch64-linux-nat.c (debug_hw_points): Don't define. Replace all uses with show_debug_regs. Replace all uses that considered debug_hw_points as a multi-value integer with straight boolean uses. * x86-nat.c (debug_hw_points): Don't define. Replace all uses with show_debug_regs. * nat/x86-dregs.c (debug_hw_points): Don't declare. Replace all uses with show_debug_regs. * mips-linux-nat.c (maint_show_dr): Don't define. Replace all uses with show_debug_regs. gdb/gdbserver/ChangeLog: * server.h (debug_hw_points): Don't declare. * server.c (debug_hw_points): Don't define. Replace all uses with show_debug_regs. * linux-aarch64-low.c (debug_hw_points): Don't define. Replace all uses with show_debug_regs.
2014-09-11Fix gdb.fortran/array-element.exp failures.Gabriel Krisman Bertazi2-12/+8
This fixes two FAIL results on this testcase which were caused by a misplaced "continue" command. This testcase used to end inferior's execution too soon, causing the following tests to fail. Now we break right after inferior's loop and perform the rest of the tests there. gdb/testsuite/ChangeLog: * gdb.fortran/array-element.exp: Remove unexpected "continue" command in testcase. Simplify testcase.
2014-09-10Support gdbarch_convert_register_p targets in address_from_registerUlrich Weigand2-4/+26
Since the last change to address_from_register, it no longer supports targets that require a special conversion (gdbarch_convert_register_p) for plain pointer type; I had assumed no target does so. This turned out to be incorrect: MIPS64 n32 big-endian needs such a conversion in order to properly sign-extend pointer values. This patch fixes this regression by handling targets that need a special conversion in address_from_register as well. gdb/ChangeLog: * findvar.c (address_from_register): Handle targets requiring a special conversion routine even for plain pointer types.
2014-09-10AIX: Remove exec_one_dummy_insn hackUlrich Weigand2-57/+5
Old AIX versions required GDB to update the stack pointer register and execute at least one instruction before accessing the space newly allocated on the user stack. This was done using the exec_one_dummy_insn routine in rs6000-nat.c However, in currently supported AIX versions (tested on AIX 6.1), this hack is no longer necessary. In fact, removing the hack actually fixed several test case failures, and removes a call to deprecated_insert_raw_breakpoint. gdb/ChangeLog: * rs6000-nat.c (exec_one_dummy_insn): Remove. (store_register): Do not call exec_one_dummy_insn.
2014-09-10dynarr-ptr.exp: Add ptype tests.Joel Brobecker2-0/+28
This patch adds a number of "ptype" tests to gdb.dwarf2/dynarr-ptr.exp. gdb/testsuite/ChangeLog: * gdb.dwarf2/dynarr-ptr.exp: Add a few ptype tests.
2014-09-10Ada: Print bounds/length of pointer to array with dynamic boundsJoel Brobecker4-2/+93
Trying to print the bounds or the length of a pointer to an array whose bounds are dynamic results in the following error: (gdb) p foo.three_ptr.all'first Location address is not set. (gdb) p foo.three_ptr.all'length Location address is not set. This is because, after having dereferenced our array pointer, we use the type of the resulting array value, instead of the enclosing type. The former is the original type where the bounds are unresolved, whereas we need to get the actual array bounds. Similarly, trying to apply those attributes to the array pointer directly (without explicitly dereferencing it with the '.all' operator) yields the same kind of error: (gdb) p foo.three_ptr'first Location address is not set. (gdb) p foo.three_ptr'length Location address is not set. This is caused by the fact that the dereference was done implicitly in this case, and perform at the type level only, which is not sufficient in order to resolve the array type. This patch fixes both issues, thus allowing us to get the expected output: (gdb) p foo.three_ptr.all'first $1 = 1 (gdb) p foo.three_ptr.all'length $2 = 3 (gdb) p foo.three_ptr'first $3 = 1 (gdb) p foo.three_ptr'length $4 = 3 gdb/ChangeLog: * ada-lang.c (ada_array_bound): If ARR is a TYPE_CODE_PTR, dereference it first. Use value_enclosing_type instead of value_type. (ada_array_length): Likewise. gdb/testsuite/ChangeLog: * gdb.dwarf2/dynarr-ptr.exp: Add 'first, 'last and 'length tests.
2014-09-10Ada subscripting of pointer to array with dynamic boundsJoel Brobecker4-8/+125
Consider a pointer to an array which dynamic bounds, described in DWARF as follow: <1><25>: Abbrev Number: 4 (DW_TAG_array_type) <26> DW_AT_name : foo__array_type [...] <2><3b>: Abbrev Number: 5 (DW_TAG_subrange_type) [...] <40> DW_AT_lower_bound : 5 byte block: 97 38 1c 94 4 (DW_OP_push_object_address; DW_OP_lit8; DW_OP_minus; DW_OP_deref_size: 4) <46> DW_AT_upper_bound : 5 byte block: 97 34 1c 94 4 (DW_OP_push_object_address; DW_OP_lit4; DW_OP_minus; DW_OP_deref_size: 4) GDB is now able to correctly print the entire array, but not one element of the array. Eg: (gdb) p foo.three_ptr.all $1 = (1, 2, 3) (gdb) p foo.three_ptr.all(1) Cannot access memory at address 0xfffffffff4123a0c The problem occurs because we are missing a dynamic resolution of the variable's array type when subscripting the array. What the current code does is "fix"-ing the array type using the GNAT encodings, but that operation ignores any of the array's dynamic properties. This patch fixes the issue by using ada_value_ind to dereference the array pointer, which takes care of the array type resolution. It also continues to "fix" arrays described using GNAT encodings, so backwards compatibility is preserved. gdb/ChangeLog: * ada-lang.c (ada_value_ptr_subscript): Remove parameter "type". Adjust function implementation and documentation accordingly. (ada_evaluate_subexp) <OP_FUNCALL>: Only assign "type" if NOSIDE is EVAL_AVOID_SIDE_EFFECTS. Update call to ada_value_ptr_subscript. gdb/testsuite/ChangeLog: * gdb.dwarf2/dynarr-ptr.exp: Add subscripting tests.