aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2014-03-10Missing space before '(' in ada-lang.c::ada_evaluate_subexpJoel Brobecker2-3/+8
gdb/ChangeLog: * ada-lang.c (ada_evaluate_subexp): Add missing space before '(' in call to TYPE_CODE macro.
2014-03-10Minor style change in the previous commits' ChangeLog entry.Joel Brobecker1-2/+2
2014-03-10[Ada] Full view of tagged type with ptypeJerome Guitton7-10/+162
When evaluating an expression, if it is of a tagged type, GDB reads the tag in memory and deduces the full view. At parsing time, however, this operation is done only in the case of OP_VAR_VALUE. ptype does not go through a full evaluation of expressions so it may return some odd results: (gdb) print c.menu_name $1 = 0x0 (gdb) ptype $ type = system.strings.string_access (gdb) ptype c.menu_name type = <void> This change removes this peculiarity by extending the tag resolution to UNOP_IND and STRUCTOP_STRUCT. As in the case of OP_VAR_VALUE, this implies switching from EVAL_AVOID_SIDE_EFFECTS to EVAL_NORMAL when a tagged type is dereferenced. gdb/ * ada-lang.c (ada_evaluate_subexp): Resolve tagged types to full view in the case of UNOP_IND and STRUCTOP_STRUCT. gdb/testsuite/ * gdb.ada/tagged_access: New testcase.
2014-03-10Remove "hardware" from comments of "target_insert_breakpoint"Hui Zhu2-1/+6
This function is for simple breakpoint. So I post a patch to remove "hardware". Thanks, Hui 2014-03-10 Hui Zhu <hui@codesourcery.com> * target.h (target_insert_breakpoint): Remove "hardware" from its comments.
2014-03-07* dwarf2read.c (read_str_index): Rename local dwo_name to objf_name.Doug Evans2-5/+9
2014-03-07read_cutu_die_from_dwo: Misc minor cleanups.Doug Evans2-4/+9
* dwarf2read.c (read_cutu_die_from_dwo): Fix function comment. Remove unused local comp_dir_attr. Assert exactly one of stub_comp_unit_die, stub_comp_dir is non-NULL.
2014-03-07target.h: Expands complete_target_initialization and add_target comments.Joel Brobecker2-1/+10
Expand a bit the comments to answer some questions I had when looking at why a target of mine would not have some default methods set. gdb/ChangeLog: * target.h (complete_target_initialization, add_target): Add comment.
2014-03-07Make the go32-nat.c target inherit inf-child.c.Pedro Alves2-89/+71
So that all native targets inherit a single "superclass". Target methods that are set to or do the same as inf-child.c's are removed. Tested by cross building on Fedora 17. gdb/ 2014-03-07 Pedro Alves <palves@redhat.com> * go32-nat.c: Include inf-child.h. (go32_ops): Delete global. (go32_close, go32_detach, go32_prepare_to_store, go32_can_run): Delete methods. (go32_create_inferior): Push the passed in target pointer instead of referencing go32_ops. (init_go32_ops): Delete function. Moved parts to _initialize_go32_nat. (go32_target): New function, based on init_go32_ops, but inherit inf_child_target. (_initialize_go32_nat): Use go32_target. Move parts of init_go32_ops here.
2014-03-07btrace, test: fix gdb.btrace/data testMarkus Metzger2-2/+6
The format of the output changed. Fix the test. testsuite/ * gdb.btrace/data.exp: Update expected output.
2014-03-06Fix sol-thread.c build failure.Joel Brobecker2-3/+13
Some updates where needed after the minimal symbol handling got changed a little. This patch makes those changes. gdb/ChangeLog: * sol-thread.c: #include "symtab.h", "minsym.h" and "objfiles.h". (ps_pglobal_lookup): Use BMSYMBOL_VALUE_ADDRESS instead of SYMBOL_VALUE_ADDRESS. (info_cb): MSYMBOL_PRINT_NAME instead of SYMBOL_PRINT_NAME.
2014-03-06Remove argument optional_p from get_tracepoint_by_numberYao Qi4-17/+17
This patch is to remove parameter optional_p as it is always true, in order to simplify get_tracepoint_by_number. 'optional_p' was added by this change, 1999-11-18 Tom Tromey <tromey@cygnus.com> * tracepoint.h (get_tracepoint_by_number): Updated declaration. * tracepoint.c (trace_pass_command): Better error message. Fixed logic when `all' not specified. (get_tracepoint_by_number): Added `optional_p' argument. Fixed all callers. but after this patch, FYI: remove `static's from cli-utils.c https://sourceware.org/ml/gdb-patches/2011-03/msg00636.html 'optional_p' passed to get_tracepoint_by_number become always true. gdb: 2014-03-06 Yao Qi <yao@codesourcery.com> * breakpoint.c (get_tracepoint_by_number): Remove argument optional_p. All callers updated. Adjust comments. Update output message. * breakpoint.h (get_tracepoint_by_number): Update declaration.
2014-03-06Handle parse number error in goto_bookmark_commandYao Qi2-1/+11
In GDB mainline, the error message for goto-bookmark isn't perfect. (gdb) goto-bookmark 1.1 goto-bookmark: no bookmark found for ''. This patch tweaks the error message by checking the return value of get_number. With patch applied, it becomes: (gdb) goto-bookmark 1.1 goto-bookmark: invalid bookmark number '1.1'. gdb: 2014-03-06 Yao Qi <yao@codesourcery.com> * reverse.c (goto_bookmark_command): Add local 'p'. Emit error early if get_number returns zero. Use 'p' instead of 'args'.
2014-03-06Add a newline in output messagesYao Qi2-1/+6
Hi, GDB prints two warnings in one single line, as below: (gdb) p 1.2 $1 = 1.2 (gdb) enable $1.2 History value must have integer type.Bad breakpoint number '$1' This patch adds '\n' at the end of message. gdb: 2014-03-06 Yao Qi <yao@codesourcery.com> * cli/cli-utils.c (get_number_trailer): Add '\n' at the end of message.
2014-03-06Fix PR16508Yao Qi6-17/+97
This patch fixes PR16508, which is about MI "-trace-find frame-number 0" behaves differently from CLI "tfind 0". In CLI, we check both status->running and status->filename, but in MI, we only check status->running, which looks wrong to me. This patch moves the code of checking to a new function check_trace_running, and use it in both CLI and MI. This patch also adds a test case pr16508.exp, which fails without this fix, and passes with the fix applied. FAIL: gdb.trace/pr16508.exp: interpreter-exec mi "-trace-find frame-number 0" gdb: 2014-03-06 Yao Qi <yao@codesourcery.com> PR breakpoints/16508 * tracepoint.c (check_trace_running): New function. (trace_find_command): Move code to check_trace_running and call check_trace_running. (trace_find_pc_command): Likewise. (trace_find_tracepoint_command): Likewise. (trace_find_line_command): Likewise. (trace_find_range_command): Likewise. * tracepoint.h (check_trace_running): Likewise. * mi/mi-main.c (mi_cmd_trace_find): Call check_trace_running. gdb/testsuite: 2014-03-06 Yao Qi <yao@codesourcery.com> * gdb.trace/pr16508.exp: New file.
2014-03-06Change the default implementation of to_traceframe_info to tcomplainYao Qi3-2/+8
This patch is to change the default implementation of to_traceframe_info from 'return NULL' to tcomplain, which is intended. If new target supports tracepoint, this method should be implemented, otherwise, an error is thrown. gdb: 2014-03-06 Yao Qi <yao@codesourcery.com> * target.h (struct target_ops) <to_traceframe_info>: Use TARGET_DEFAULT_NORETURN (tcomplain ()). * target-delegates.c: Regenerated.
2014-03-05PR gdb/16575: stale breakpoint instructions in the code cachePedro Alves6-104/+127
In non-stop mode, or rather, breakpoints always-inserted mode, the code cache can easily end up with stale breakpoint instructions: All it takes is filling a cache line when breakpoints already exist in that memory region, and then delete the breakpoint. Vis. (from the new test): (gdb) set breakpoint always-inserted on (gdb) b 23 Breakpoint 2 at 0x400540: file ../../../src/gdb/testsuite/gdb.base/breakpoint-shadow.c, line 23. (gdb) b 24 Breakpoint 3 at 0x400547: file ../../../src/gdb/testsuite/gdb.base/breakpoint-shadow.c, line 24. disass main Dump of assembler code for function main: 0x000000000040053c <+0>: push %rbp 0x000000000040053d <+1>: mov %rsp,%rbp => 0x0000000000400540 <+4>: movl $0x1,-0x4(%rbp) 0x0000000000400547 <+11>: movl $0x2,-0x4(%rbp) 0x000000000040054e <+18>: mov $0x0,%eax 0x0000000000400553 <+23>: pop %rbp 0x0000000000400554 <+24>: retq End of assembler dump. So far so good. Now flush the code cache: (gdb) set code-cache off (gdb) set code-cache on Requesting a disassembly works as expected, breakpoint shadowing is applied: (gdb) disass main Dump of assembler code for function main: 0x000000000040053c <+0>: push %rbp 0x000000000040053d <+1>: mov %rsp,%rbp => 0x0000000000400540 <+4>: movl $0x1,-0x4(%rbp) 0x0000000000400547 <+11>: movl $0x2,-0x4(%rbp) 0x000000000040054e <+18>: mov $0x0,%eax 0x0000000000400553 <+23>: pop %rbp 0x0000000000400554 <+24>: retq End of assembler dump. However, now delete the breakpoints: (gdb) delete Delete all breakpoints? (y or n) y And disassembly shows the old breakpoint instructions: (gdb) disass main Dump of assembler code for function main: 0x000000000040053c <+0>: push %rbp 0x000000000040053d <+1>: mov %rsp,%rbp => 0x0000000000400540 <+4>: int3 0x0000000000400541 <+5>: rex.RB cld 0x0000000000400543 <+7>: add %eax,(%rax) 0x0000000000400545 <+9>: add %al,(%rax) 0x0000000000400547 <+11>: int3 0x0000000000400548 <+12>: rex.RB cld 0x000000000040054a <+14>: add (%rax),%al 0x000000000040054c <+16>: add %al,(%rax) 0x000000000040054e <+18>: mov $0x0,%eax 0x0000000000400553 <+23>: pop %rbp 0x0000000000400554 <+24>: retq End of assembler dump. Those breakpoint instructions are no longer installed in target memory they're stale in the code cache. Easily confirmed by just disabling the code cache: (gdb) set code-cache off (gdb) disass main Dump of assembler code for function main: 0x000000000040053c <+0>: push %rbp 0x000000000040053d <+1>: mov %rsp,%rbp => 0x0000000000400540 <+4>: movl $0x1,-0x4(%rbp) 0x0000000000400547 <+11>: movl $0x2,-0x4(%rbp) 0x000000000040054e <+18>: mov $0x0,%eax 0x0000000000400553 <+23>: pop %rbp 0x0000000000400554 <+24>: retq End of assembler dump. I stumbled upon this when writing a patch to infrun.c, that made handle_inferior_event & co fill in the cache before breakpoints were removed from the target. Recall that wait_for_inferior flushes the dcache for every event. So in that case, always-inserted mode was not necessary to trigger this. It's just a convenient way to expose the issue. The dcache works at the raw memory level. We need to update it whenever memory is written, no matter what kind of target memory object was originally passed down by the caller. The issue is that the dcache update code isn't reached when a caller explicitly writes raw memory. Breakpoint insertion/removal is one such case -- mem-break.c uses target_write_read_memory/target_write_raw_memory. The fix is to move the dcache update code from memory_xfer_partial_1 to raw_memory_xfer_partial so that it's always reachable. When we do that, we can actually simplify a series of things. memory_xfer_partial_1 no longer needs to handle writes for any kind of memory object, and therefore dcache_xfer_memory no longer needs to handle writes either. So the latter (dcache_xfer_memory) and its callees can be simplified to only care about reads. While we're touching dcache_xfer_memory's prototype, might as well rename it to reflect that fact that it only handles reads, and make it follow the new target_xfer_status/xfered_len style. This made me notice that dcache_xfer_memory loses the real error status if a memory read fails: we could have failed to read due to TARGET_XFER_E_UNAVAILABLE, for instance, but we always return TARGET_XFER_E_IO, hence the FIXME note. I felt that fixing that fell out of the scope of this patch. Currently dcache_xfer_memory handles the case of a write failing. The whole cache line is invalidated when that happens. However, dcache_update, the sole mechanism for handling writes that will remain after the patch, does not presently handle that scenario. That's a bug. The patch makes it handle that, by passing down the target_xfer_status status from the caller, so that it can better decide what to do itself. While I was changing the function's prototype, I constified the myaddr parameter, getting rid of the need for the cast as seen in its existing caller. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2014-03-05 Pedro Alves <palves@redhat.com> PR gdb/16575 * dcache.c (dcache_poke_byte): Constify ptr parameter. Return void. Update comment. (dcache_xfer_memory): Delete. (dcache_read_memory_partial): New, based on the read bits of dcache_xfer_memory. (dcache_update): Add status parameter. Use ULONGEST for len, and adjust. Discard cache lines if the reason for the update was error. * dcache.h (dcache_xfer_memory): Delete declaration. (dcache_read_memory_partial): New declaration. (dcache_update): Update prototype. * target.c (raw_memory_xfer_partial): Update the dcache here. (memory_xfer_partial_1): Don't handle dcache writes here. gdb/testsuite/ 2014-03-05 Pedro Alves <palves@redhat.com> PR gdb/16575 * gdb.base/breakpoint-shadow.exp (compare_disassembly): New procedure. (top level): Adjust to use it. Add tests that exercise breakpoint interaction with the code-cache.
2014-03-05sim: constify prog_nameMike Frysinger2-1/+5
There's no need for the prog_name handed down to the core to be mutable, so add const markings to it and all the related funcs.
2014-03-03move probes to be per-bfdTom Tromey3-15/+23
This patch moves the probe data from the objfile to the per-BFD object. This lets the probes be shared between different inferiors (and different objfiles when dlmopen is in use, should gdb ever handle that). 2014-03-03 Tom Tromey <tromey@redhat.com> * elfread.c (probe_key): Change to bfd_data. (elf_get_probes, probe_key_free, _initialize_elfread): Probes are now per-BFD, not per-objfile. * stap-probe.c (stap_probe_destroy): Update comment. (handle_stap_probe): Allocate on the per-BFD obstack.
2014-03-03change probes to be program-space-independentTom Tromey16-178/+256
This changes the probes to be independent of the program space. After this, when a probe's address is needed, it is determined by applying offsets at the point of use. This introduces a bound_probe object, similar to bound minimal symbols. Objects of this type are used when it's necessary to pass a probe and its corresponding objfile. This removes the backlink from probe to objfile, which was primarily used to fetch the architecture to use. This adds a get_probe_address function which calls a probe method to compute the probe's relocated address. Similarly, it adds an objfile parameter to the semaphore methods so they can do the relocation properly as well. 2014-03-03 Tom Tromey <tromey@redhat.com> * break-catch-throw.c (fetch_probe_arguments): Use bound probes. * breakpoint.c (create_longjmp_master_breakpoint): Use get_probe_address. (add_location_to_breakpoint, bkpt_probe_insert_location) (bkpt_probe_remove_location): Update. * breakpoint.h (struct bp_location) <probe>: Now a bound_probe. * elfread.c (elf_symfile_relocate_probe): Remove. (elf_probe_fns): Update. (insert_exception_resume_breakpoint): Change type of "probe" parameter to bound_probe. (check_exception_resume): Update. * objfiles.c (objfile_relocate1): Don't relocate probes. * probe.c (bound_probe_s): New typedef. (parse_probes): Use get_probe_address. Set sal's objfile. (find_probe_by_pc): Return a bound_probe. (collect_probes): Return a VEC(bound_probe_s). (compare_probes): Update. (gen_ui_out_table_header_info): Change type of "probes" parameter. Update. (info_probes_for_ops): Update. (get_probe_address): New function. (probe_safe_evaluate_at_pc): Update. * probe.h (struct probe_ops) <get_probe_address>: New field. <set_semaphore, clear_semaphore>: Add objfile parameter. (struct probe) <objfile>: Remove field. <arch>: New field. <address>: Update comment. (struct bound_probe): New. (find_probe_by_pc): Return a bound_probe. (get_probe_address): Declare. * solib-svr4.c (struct probe_and_action) <address>: New field. (hash_probe_and_action, equal_probe_and_action): Update. (register_solib_event_probe): Add address parameter. (solib_event_probe_at): Update. (svr4_create_probe_breakpoints): Add objfile parameter. Use get_probe_address. * stap-probe.c (struct stap_probe) <sem_addr>: Update comment. (stap_get_probe_address): New function. (stap_can_evaluate_probe_arguments, compute_probe_arg) (compile_probe_arg): Update. (stap_set_semaphore, stap_clear_semaphore): Compute semaphore's address. (handle_stap_probe): Don't relocate the probe. (stap_relocate): Remove. (stap_gen_info_probes_table_values): Update. (stap_probe_ops): Remove stap_relocate. * symfile-debug.c (debug_sym_relocate_probe): Remove. (debug_sym_probe_fns): Update. * symfile.h (struct sym_probe_fns) <sym_relocate_probe>: Remove. * symtab.c (init_sal): Use memset. * symtab.h (struct symtab_and_line) <objfile>: New field. * tracepoint.c (start_tracing, stop_tracing): Update.
2014-03-03comment fixesTom Tromey2-7/+11
This fixes up a few mildly erroneous comments in probe.h. 2014-03-03 Tom Tromey <tromey@redhat.com> * probe.h (parse_probes, find_probe_by_pc) (find_probes_in_objfile): Fix comments.
2014-03-02* infrun.c (handle_signal_stop): Replace test forDoug Evans2-16/+19
TARGET_WAITKIND_STOPPED with an assert.
2014-03-02guile/scm-objfile.c (ofscm_mark_objfile_smob): Fix typo in comment.Doug Evans2-1/+5
2014-03-02guile/lib/gdb/printing.scm (append-pretty-printer!): Fix thinko.Doug Evans2-1/+5
2014-03-01Silence ARI warning.Mark Kettenis2-1/+5
gdb/ChangeLog: * obsd-nat.c: Include "gdb_wait.h" instead of <sys/wait.h>.
2014-03-01Enable rhreads support on OpenBSD/i386.Mark Kettenis3-3/+11
gdb/ChangeLog: * i386obsd-nat.c: Include "obsd-nat.h". (_initialize_i386obsd_nat): Call obsd_add_target instead of add_target. * config/i386/obsd.mh (NATDEPFILES): Add obsd-nat.o.
2014-03-01Eliminate pointer signedness warning.Mark Kettenis2-1/+5
gdb/ChangeLog: * i386obsd-nat.c (i386obsd_supply_pcb): Cast 'sf' to 'gdb_byte *'.
2014-03-01Fix ChangeLog.Mark Kettenis1-2/+3
2014-03-01Enable rthreads support on OpenBSD/mips64.Mark Kettenis3-2/+10
gdb/ChangeLog: * mips64obsd-nat.c: Include "obsd-nath". (_initialize_mips64obsd_nat): Call obsd_add_target instead of add_target * config/mips/obsd64.mh (NATDEPFILES): Add obsd-nat.o.
2014-03-01Enable rthreads support on OpenBSD/amd64.Mark Kettenis3-3/+10
gdb/ChangeLog: * amd64obsd-nat.c (_initialize_amd64obsd_nat): Call obsd_add_target instead of add_target. * config/i386/obsd64.mh (NATDEPFILES): Add obsd-nat.o.
2014-02-28Remove the unnecesary argument METHOD to valops.c:find_oload_champ.Siva Chandra2-11/+24
* valops.c (find_oload_champ): Remove unneccesary argument METHOD. (find_overload_match): Update call to find_oload_champ. (find_oload_champ_namespace_loop): Likewise
2014-02-28Add sparc64obsd-nat.c to ALLDEPFILES.Mark Kettenis2-1/+4
gdb/ChangeLog: * Makefile.in (ALLDEPFILES): Add sparc64obsd-nat.c.
2014-02-28Enable rthreads supports on OpenBSD/sparc64.Mark Kettenis4-1/+141
gdb/ChangeLog: * configure.host (sparc64-*-openbsd*): Set gdb_host to obsd64. * config/sparc/obsd64.mh: New file. * sparc64obsd-nat.c: New file.
2014-02-28Stupid git never fucking does what I want!Mark Kettenis1-3/+3
2014-02-28Support rthreads on OpenBSD 5.2 and later.Mark Kettenis4-2/+219
OpenBSD 5.2 and later have a proper threads implementation based on kernel threads. Debugging support is provided through additional ptrace(2) requests, so this diff extends the generic code in inf-ptrace.c with OpenBSD-specific code to discover additional threads. gdb/ChangeLog: * obsd-nat.h: New file. * obsd-nat.c: New file. * Makefile.in (HFILES_NO_SRCDIR): Add obsd-nat.h. (ALLDEPFILES): Add obsd-nat.c.
2014-02-28constify ui_out_implTom Tromey6-13/+17
This patch constifies ui_out_impl in struct ui_out, and various instances of ui_out_impl. This removes a couple of FIXME comments (near cli_ui_out_impl and mi_ui_out_impl) that did not make sense to me. Tested by rebuilding. 2014-02-28 Tom Tromey <tromey@redhat.com> * cli-out.c (cli_ui_out_impl): Now const. Remove comment. * cli-out.h (cli_ui_out_impl): Now const. * mi/mi-out.c (mi_ui_out_impl): Now const. Remove comment. * ui-out.c (struct ui_out) <impl>: Now const. (default_ui_out_impl): Now const. (ui_out_new): Make 'impl' parameter const. * ui-out.h (ui_out_new): Update.
2014-02-27Prevent compiler warning.Mark Kettenis2-1/+5
GCC 4.2.1 complains about first_l_name may be used uninitialized, and my brain agrees. gdb/ChangeLog: * solib-svr4.c (svr4_read_so_list): Initialize first_l_name to 0.
2014-02-27StackGhost cookie is per-process.Mark Kettenis2-5/+5
gdb/ChangeLog: * sparc-nat.c (sparc_xfer_wcookie): Always use process ID.
2014-02-27Additional PR 8882 fix.Jan Kratochvil2-4/+8
runtest gdb.base/corefile.exp ==23174== ERROR: AddressSanitizer: heap-use-after-free on address 0x604400008c88 at pc 0x68f0be bp 0x7fffae9d7490 sp 0x7fffae9d7480 READ of size 8 at 0x604400008c88 thread T0 #0 0x68f0bd in svr4_read_so_list (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x68f0bd) #1 0x68f64e in svr4_current_sos_direct (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x68f64e) #2 0x68f757 in svr4_current_sos (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x68f757) #3 0xcebbff in update_solib_list (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xcebbff) 0x604400008c88 is located 8 bytes inside of 1104-byte region [0x604400008c80,0x6044000090d0) freed by thread T0 here: #0 0x7f52677500f9 (/lib64/libasan.so.0+0x160f9) #1 0xd2c68a in xfree (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xd2c68a) #2 0xceb364 in free_so (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xceb364) #3 0xca59f8 in do_free_so (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xca59f8) #4 0x93432a in do_my_cleanups (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x93432a) #5 0x934406 in do_cleanups (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x934406) #6 0x68efa9 in svr4_read_so_list (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x68efa9) I did not notice it during my review in: Re: [PATCH v2] Skip vDSO when reading SO list (PR 8882) https://sourceware.org/ml/gdb-patches/2013-09/msg00888.html gdb/ 2014-02-27 Jan Kratochvil <jan.kratochvil@redhat.com> Additional PR 8882 fix. * solib-svr4.c (svr4_read_so_list): Change first to first_l_name. Message-ID: <20140226220918.GA10431@host2.jankratochvil.net>
2014-02-27Linux waitpid/__WALL emulation wrapper: If WNOHANG is set, don't touch ↵Pedro Alves2-8/+18
sigprocmask. Just a small optimization. No need to block/unblock signals if we're not going to call sigsuspend. gdb/ 2014-02-27 Pedro Alves <palves@redhat.com> * nat/linux-waitpid.c (my_waitpid): Only block signals if WNOHANG isn't set.
2014-02-27Teach GDBserver's Linux backend about no unwaited-for children ↵Pedro Alves4-352/+568
(TARGET_WAITKIND_NO_RESUMED). GDBserver currently hangs forever in waitpid if the leader thread exits before other threads, or if all resumed threads exit - e.g., next over a thread exit with sched-locking on. This is exposed by leader-exit.exp. leader-exit.exp is part of a series of tests for a set of related problems. See <http://www.sourceware.org/ml/gdb-patches/2011-10/msg00704.html>: " To recap, on the Linux kernel, ptrace/waitpid don't allow reaping the leader thread until all other threads in the group are reaped. When the leader exits, it goes zombie, but waitpid will not return an exit status until the other threads are gone. This is presently exercised by the gdb.threads/leader-exit.exp test. The fix for that test, in linux-nat.c:wait_lwp, handles the case where we see the leader gone when we're stopping all threads to report an event to some other thread to the core. (...) The latter bit about not blocking if there no resumed threads in the process also applies to some other thread exiting, not just the main thread. E.g., this test starts a thread, and runs to a breakpoint in that thread: ... (gdb) c Continuing. [New Thread 0x7ffff75a4700 (LWP 23397)] [Switching to Thread 0x7ffff75a4700 (LWP 23397)] Breakpoint 2, thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 28 return 0; /* break-here */ (gdb) info threads * 2 Thread 0x7ffff75a4700 (LWP 23397) thread_a (arg=0x0) at ../../../src/gdb/testsuite/gdb.threads/no-unwaited-for-left.c:28 1 Thread 0x7ffff7fcb720 (LWP 23391) 0x00007ffff7bc606d in pthread_join (threadid=140737343276800, thread_return=0x0) at pthread_join.c:89 The thread will exit as soon as we resume it. But if we only resume that thread, leaving the rest of the threads stopped: (gdb) set scheduler-locking on (gdb) c Continuing. ^C^C^C^C^C^C^C^C " This patch fixes the issues by implementing TARGET_WAITKIND_NO_RESUMED on GDBserver, similarly to what the patch above did for native Linux GDB. gdb.threads/leader-exit.exp now passes. gdb.threads/no-unwaited-for-left.exp now at least errors out instead of hanging: continue Continuing. warning: Remote failure reply: E.No unwaited-for children left. [Thread 15454] #1 stopped. 0x00000034cf408e60 in pthread_join (threadid=140737353922368, thread_return=0x0) at pthread_join.c:93 93 lll_wait_tid (pd->tid); (gdb) FAIL: gdb.threads/no-unwaited-for-left.exp: continue stops when the main thread exits The gdb.threads/non-ldr-exc-*.exp tests are skipped because GDBserver unfortunately doesn't support fork/exec yet, but I'm confident this fixes the related issues. I'm leaving modeling TARGET_WAITKIND_NO_RESUMED in the RSP for a separate pass. (BTW, in case of error in response to a vCont, it would be better for GDB to query the target for the current thread, or re-select one, instead of assuming current inferior_ptid is still the selected thread.) This implementation is a little different from GDB's, because I'm avoiding bringing in more of this broken use of waitpid(PID) into GDBserver. Specifically, this avoids waitpid(PID) when stopping all threads. There's really no need for wait_for_sigstop to wait for each LWP in turn. Instead, with some refactoring, we make it reuse linux_wait_for_event. gdb/gdbserver/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * inferiors.h (A_I_NEXT, ALL_INFERIORS_TYPE, ALL_PROCESSES): New macros. * linux-low.c (delete_lwp, handle_extended_wait): Add debug output. (last_thread_of_process_p): Take a PID argument instead of a thread pointer. (linux_wait_for_lwp): Delete. (num_lwps, check_zombie_leaders, not_stopped_callback): New functions. (linux_low_filter_event): New function, party factored out from linux_wait_for_event. (linux_wait_for_event): Rename to ... (linux_wait_for_event_filtered): ... this. Add new filter ptid argument. Partly rewrite. Always use waitpid(-1, WNOHANG) and sigsuspend. Check for zombie leaders. (linux_wait_for_event): Reimplement as wrapper around linux_wait_for_event_filtered. (linux_wait_1): Handle TARGET_WAITKIND_NO_RESUMED. Assume that if a normal or signal exit is seen, it's the whole process exiting. (wait_for_sigstop): No longer a for_each_inferior callback. Rewrite on top of linux_wait_for_event_filtered. (stop_all_lwps): Call wait_for_sigstop directly. * server.c (resume, handle_target_event): Handle TARGET_WAITKIND_NO_RESUMED.
2014-02-27Move linux-nat.c:status_to_str to nat/linux-waitpid.c.Pedro Alves4-25/+40
So that gdbserver's Linux backend can use it too. gdb/ 2014-02-27 Pedro Alves <palves@redhat.com> PR 12702 * linux-nat.c (status_to_str): Moved to nat/linux-waitpid.c. * nat/linux-waitpid.c: Include string.h. (status_to_str): Moved here and made extern. * nat/linux-waitpid.h (status_to_str): New declaration.
2014-02-27Move ptid_match to common/ptid.c.Hui Zhu5-24/+32
So that gdbserver can use it too. gdb/ 2014-02-27 Hui Zhu <hui@codesourcery.com> PR 12702 * infrun.c (ptid_match): Move ... * common/ptid.c (ptid_match): ... here. * inferior.h (ptid_match): Move ... * common/ptid.h (ptid_match): ... here.
2014-02-27Call common OpenBSD ABI init code on OpenBSD/mips64.Mark Kettenis3-1/+10
* mips64obsd-tdep.c (mips64obsd_init_abi): Call obsd_init_abi. * configure.tgt (mips64*-*-openbsd*): Add obsd-tdep.c to gdb_target_obs.
2014-02-27Add gdbarch auxv parsing for OpenBSD.Mark Kettenis2-1/+32
gdb/Changelog: * obsd-tdep.c (obsd_auxv_parse): New function. (obsd_init_abi): Set auxv_parse.
2014-02-27Add auxv parsing to the architecture vector.Mark Kettenis5-0/+61
Necessary to fix parsing auxv entries from core files on systems that use the layout specified by ELF instead of the incompatible variant used by Linux. gdb/Changelog: * gdbarch.sh (auxv_parse): New. * gdbarch.h: Regenerated. * gdbarch.c: Regenerated. * auxv.c (target_auxv_parse): Call gdbarch_parse_auxv if provided.
2014-02-26guile: Add 'history-append!' procedure.Ludovic Courtès6-0/+56
gdb/ 2014-02-26 Ludovic Courtès <ludo@gnu.org> * guile/scm-value.c (gdbscm_history_append_x): New function. (value_functions): Add it. gdb/testsuite/ 2014-02-26 Ludovic Courtès <ludo@gnu.org> * gdb.guile/scm-value.exp (test_value_in_inferior): Add test for 'history-append!'. gdb/doc/ 2014-02-26 Ludovic Courtès <ludo@gnu.org> * gdb/doc/guile.texi (Basic Guile): Document 'history-append!'.
2014-02-26gdbserver/Windows: Rely purely on event info when handling DLL load eventJoel Brobecker2-168/+18
This is the GDBserver counterpart of a change we recently made in GDB to only rely on get_image_name to determine its name. This simplification, in turn, allows us to remove a fair amount of functions and globals which now become unused. gdb/gdbserver/ChangeLog: * win32-low.c (psapi_get_dll_name, * win32_CreateToolhelp32Snapshot): Delete. (win32_CreateToolhelp32Snapshot, win32_Module32First) (win32_Module32Next, load_toolhelp, toolhelp_get_dll_name): Delete. (handle_load_dll): Add function description. Remove code using psapi_get_dll_name and toolhelp_get_dll_name.
2014-02-26windows: Factorize handling of DLL load address offsetJoel Brobecker2-12/+22
This patch is a small cleanup that moves the magic 0x1000 offset to apply to a DLL's base address inside the win32_add_one_solib function, rather than delegate that reponsibility to its callers. gdb/gdbserver/ChangeLog: * win32-low.c (win32_add_one_solib): Add 0x1000 to load_addr. Add comment. (win32_add_all_dlls): Remove 0x1000 offset applied to DLL base address when calling win32_add_one_solib. (handle_load_dll): Delete local variable load_addr. Remove 0x1000 offset applied to DLL base address when calling win32_add_one_solib. (handle_unload_dll): Add comment.
2014-02-26gdbserver/windows: Ignore DLL load/unload events during child initialization.Joel Brobecker2-46/+61
This GDBserver patch mirrors a change made in GDB wich aims at simplifying DLL handling during the inferior initialization (process creation during the "run", or during an "attach"). Instead of processing each DLL load event, which is sometimes incomplete, we ignore these events until the inferior has completed its startup phase, and then just iterate over all DLLs via EnumProcessModules. As a side-effect, it fixes a small bug where win32_ensure_ntdll_loaded was missing a 0x1000 offset in the DLL base address. This problem should only be visible on the 64bit version of Windows 8.1, since this is the only platform where win32_ensure_ntdll_loaded is actually needed. gdb/gdbserver/ChangeLog: * win32-low.c (win32_add_all_dlls): Renames win32_ensure_ntdll_loaded. Rewrite function documentation. Adjust implementation to always load all DLLs. Add 0x1000 offset to DLL base address when calling win32_add_one_solib. (child_initialization_done): New static global. (do_initial_child_stuff): Set child_initialization_done to zero during child initialization, and 1 after. Replace call to win32_ensure_ntdll_loaded by call to win32_add_all_dlls. Add comment. (match_dll_by_basename, dll_is_loaded_by_basename): Delete. (handle_unload_dll): Add function documentation. (get_child_debug_event): Ignore load and unload DLL events during child initialization.
2014-02-26DWARF: Read constant-class addresses correctlyJoel Brobecker9-28/+491
Starting with DWARF version 4, the description of the DW_AT_high_pc attribute was amended to say: if it is of class constant, the value is an unsigned integer offset which when added to the low PC gives the address of the first location past the last instruction associated with the entity. A change was made in Apr 27th, 2012 to reflect that change: | commit 91da14142c0171e58a91ad58a32fd010b700e761 | Author: Mark Wielaard <mjw@redhat.com> | Date: Fri Apr 27 18:55:19 2012 +0000 | | * dwarf2read.c (dwarf2_get_pc_bounds): Check DW_AT_high_pc form to | see whether it is an address or a constant offset from DW_AT_low_pc. | (dwarf2_record_block_ranges): Likewise. | (read_partial_die): Likewise. Unfortunately, this new interpretation is now used regardless of the CU's DWARF version. It turns out that one of WindRiver's compilers (FTR: Diabdata 4.4) is generating DWARF version 2 info with DW_AT_high_pc attributes improperly using the data4 form. Because of that, we miscompute all high PCs incorrectly. This leads to a lot of symtabs having overlapping ranges, which in turn causes havoc in pc-to-symtab-and-line translations. One visible effect is when inserting a breakpoint on a given function: (gdb) b world Breakpoint 1 at 0x4005c4 The source location of the breakpoint is missing. The output should be: (gdb) b world Breakpoint 1 at 0x4005c8: file dw2-rel-hi-pc-world.c, line 24. What happens in this case is that the pc-to-SAL translation first starts be trying to find the symtab associated to our PC using each symtab's ranges. Because of the high_pc miscomputation, many symtabs end up matching, and the heuristic trying to select the most probable one unfortunately returns one that is unrelated (it really had no change in this case to do any better). Once we have the wrong symtab, the start searching the associated linetable, where the addresses are correct, thus finding no match, and therefore no SAL. This patch is an attempt at handling the situation as gracefully as we can, without guarantees. It introduces a new function "attr_value_as_address" which uses the correct accessor for getting the value of a given attribute. It then adjust the code throughout this unit to use this function instead of assuming that addresses always have the DW_FORM_addr format. It also fixes the original issue of miscomputing the high_pc by limiting the new interpretation of constant form DW_AT_high_pc attributes to units using DWARF version 4 or later. gdb/ChangeLog: * dwarf2read.c (attr_value_as_address): New function. (dwarf2_find_base_address, read_call_site_scope): Use attr_value_as_address in place of DW_ADDR. (dwarf2_get_pc_bounds): Use attr_value_as_address to get the low and high addresses. Slight rework of the handling of the high pc being a constant form, and limit it to DWARF verson 4 or higher. (dwarf2_record_block_ranges): Likewise. (read_partial_die): Likewise. (new_symbol_full): Use attr_value_as_address in place of DW_ADDR. gdb/testsuite/ChangeLog: * gdb.dwarf2/dw2-abs-hi-pc-hello-dbg.S: New file. * gdb.dwarf2/dw2-abs-hi-pc-hello.c: New file. * gdb.dwarf2/dw2-abs-hi-pc-world-dbg.S: New file. * gdb.dwarf2/dw2-abs-hi-pc-world.c: New file. * gdb.dwarf2/dw2-abs-hi-pc.c: New file. * gdb.dwarf2/dw2-abs-hi-pc.exp: New file. Tested on x86_64-linux.