aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
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.
2014-02-26make "file" use the BFD cache betterTom Tromey2-4/+16
Right now the "file" command will discard the exec_bfd and then possibly open a new one. If this ends up reopening the same file, it can cause needless work by gdb -- destroying all the per-BFD data just to re-read it again. This patch changes the code to hold a reference to the old exec_bfd while opening the new one. The possible downside of this is a higher peak memory use. 2014-02-26 Tom Tromey <tromey@redhat.com> * exec.c (exec_file_attach): Hold a reference to exec_bfd.
2014-02-26add short-circuit logic to elfread.cTom Tromey5-13/+41
If minimal symbols have already been read into a per-BFD object, then a symbol reader can skip re-reading them. This changes the ELF reader to do so. We only skip the work if the file is ELF+DWARF. If it has stabs or mdebug sections, then I think extra information is computed during the minsym creation pass; and so we must still repeat it. Eventually even this will go away, once all symbol types have switched to being progspace-independent. In the meantime this has no negative effect -- it is just a missing optimization for a small set of users. This change also required a somewhat non-obvious change to the OBJSTAT accounting code. If a symbol reader skips re-reading minimal symbols, then the corresponding OBJSTAT will not be updated. This leads to a test failure in gdb.base/maint.exp. To fix this, I've moved the needed stat field out of objfile and into the per-BFD object. 2014-02-26 Tom Tromey <tromey@redhat.com> * elfread.c (elf_read_minimal_symbols): Return early if minimal symbols have already been read. Add "ei" parameter. (elf_symfile_read): Call elf_read_minimal_symbols earlier. * minsyms.c (prim_record_minimal_symbol_full): Update. * objfiles.h (struct objstats) <n_minsyms>: Move... (struct objfile_per_bfd_storage) <n_minsyms>: ... here. * symmisc.c (print_objfile_statistics): Update.
2014-02-26split out elf_read_minimal_symbolsTom Tromey2-31/+48
This is just a simple refactoring in elfread.c to split out the minsym-reading code into its own function. 2014-02-26 Tom Tromey <tromey@redhat.com> * elfread.c (elf_read_minimal_symbols): New function, from elf_symfile_read. (elf_symfile_read): Call it.
2014-02-26move minimal symbols to per-bfdTom Tromey6-75/+120
Now that minimal symbols are independent of the program space, we can move them to the per-BFD object. This lets us save memory in the multi-inferior case; and, once the symbol readers are updated, time. The other prerequisite for this move is that all the objects referred to by the minimal symbols have a lifetime at least as long as the per-BFD object. I think this is satisfied partially by this patch (moving the copied names there) and partially by earlier patches moving the demangled name hash. This patch contains a bit of logic to avoid creating new minimal symbols if they have already been read for a given BFD. This allows us to avoid trying to update all the symbol readers for this condition. At first glance this may seem like a hack, but some symbol readers mix psym and minsym reading, and would require logic just like this regardless -- and it is simpler and less error-prone to just do the work in a central spot. 2014-02-26 Tom Tromey <tromey@redhat.com> * minsyms.c (lookup_minimal_symbol, iterate_over_minimal_symbols) (lookup_minimal_symbol_text, lookup_minimal_symbol_by_pc_name) (lookup_minimal_symbol_solib_trampoline) (lookup_minimal_symbol_by_pc_section_1) (lookup_minimal_symbol_and_objfile): Update. (prim_record_minimal_symbol_full): Use the per-BFD obstack. Don't allocate a minimal symbol if minsyms have already been read. (build_minimal_symbol_hash_tables): Update. (install_minimal_symbols): Do nothing if minsyms already read. Use the per-BFD obstack. (terminate_minimal_symbol_table): Use the per-BFD obstack. * objfiles.c (allocate_objfile): Call terminate_minimal_symbol_table later. (have_minimal_symbols): Update. * objfiles.h (struct objfile_per_bfd_storage) <msymbols, minimal_symbol_count, msymbol_hash, msymbol_demangled_hash>: Move from struct objfile. <minsyms_read>: New field. (struct objfile) <msymbols, minimal_symbol_count, msymbol_hash, msymbol_demangled_hash>: Move. (ALL_OBJFILE_MSYMBOLS): Update. * symfile.c (read_symbols): Set minsyms_read. (reread_symbols): Update. * symmisc.c (dump_objfile, dump_msymbols): Update.
2014-02-26change minsyms not to be relocated at read-timeTom Tromey14-139/+67
This removes the runtime offsets from minsyms. Instead, these offsets will now be applied whenever the minsym's address is computed. This patch redefines MSYMBOL_VALUE_ADDRESS to actually use the offsets from the given objfile. Then, it updates all the symbol readers, changing them so that they do not add in the section offset when creating the symbol. This change also lets us remove relocation of minsyms from objfile_relocate1 and also msymbols_sort. 2014-02-26 Tom Tromey <tromey@redhat.com> * minsyms.c (msymbols_sort): Remove. * minsyms.h (msymbols_sort): Remove. * objfiles.c (objfile_relocate1): Don't relocate minsyms. * symtab.h (MSYMBOL_VALUE_ADDRESS): Use objfile offsets. * elfread.c (elf_symtab_read): Don't add section offsets. * xcoffread.c (record_minimal_symbol): Don't add section offset to minimal symbol address. * somread.c (text_offset, data_offset): Remove. (som_symtab_read): Don't add section offsets to minimal symbol addresses. * coff-pe-read.c (add_pe_forwarded_sym, read_pe_exported_syms): Don't add section offsets to minimal symbols. * coffread.c (coff_symtab_read): Don't add section offsets to minimal symbol addresses. * machoread.c (macho_symtab_add_minsym): Don't add section offset to minimal symbol addresses. * mipsread.c (read_alphacoff_dynamic_symtab): Don't add section offset to minimal symbol addresses. * mdebugread.c (parse_partial_symbols): Don't add section offset to minimal symbol addresses. * dbxread.c (read_dbx_dynamic_symtab): Don't add section offset to minimal symbol addresses.
2014-02-26start change to progspace independenceTom Tromey71-223/+383
This patch starts changing minimal symbols to be independent of the program space. Specifically, it adds a new objfile parameter to MSYMBOL_VALUE_ADDRESS and changes all the code to use it. This is needed so we can change gdb to apply the section offset when a minsym's address is computed, as opposed to baking the offsets into the symbol itself. A few spots still need the unrelocated address. For these, we introduce MSYMBOL_VALUE_RAW_ADDRESS. As a convenience, we also add the new macro BMSYMBOL_VALUE_ADDRESS, which computes the address of a bound minimal symbol. This just does the obvious thing with the fields. Note that this change does not actually enable program space independence. That requires more changes to gdb. However, to ensure that these changes compile properly, this patch does add the needed section lookup code to MSYMBOL_VALUE_ADDRESS -- it just ensures it has no effect at runtime by multiplying the offset by 0. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_main_name): Update. (ada_add_standard_exceptions): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (skip_prologue_function, arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * blockframe.c (get_pc_function_start) (find_pc_partial_function_gnu_ifunc): Update. * breakpoint.c (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-valprint.c (c_val_print): Update. * coff-pe-read.c (add_pe_forwarded_sym): Update. * common/agent.c (agent_look_up_symbols): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * dwarf2read.c (dw2_find_pc_sect_symtab): Update. * elfread.c (elf_gnu_ifunc_record_cache) (elf_gnu_ifunc_resolve_by_got): Update. * findvar.c (default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * hppa-hpux-tdep.c (hppa64_hpux_search_dummy_call_sequence) (hppa_hpux_find_dummy_bpaddr): Update. * hppa-tdep.c (hppa_symbol_address): Update. * infcmd.c (until_next_command): Update. * jit.c (jit_read_descriptor, jit_breakpoint_re_set_internal): Update. * linespec.c (minsym_found, add_minsym): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update. * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * maint.c (maintenance_translate_address): Update. * minsyms.c (lookup_minimal_symbol_by_pc_name): Update. (frob_address): New function. (lookup_minimal_symbol_by_pc_section_1): Use raw addresses, frob_address. Rename parameter to "pc_in". (compare_minimal_symbols, compact_minimal_symbols): Use raw addresses. (find_solib_trampoline_target, minimal_symbol_upper_bound): Update. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * mips-tdep.c (mips_skip_pic_trampoline_code): Update. * objc-lang.c (find_objc_msgsend): Update. * objfiles.c (objfile_relocate1): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-valprint.c (pascal_val_print): Update. * parse.c (write_exp_msymbol): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup) (ppc_elfv2_skip_entrypoint): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * printcmd.c (build_address_symbolic, msym_info) (address_info): Update. * proc-service.c (ps_pglobal_lookup): Update. * psymtab.c (find_pc_sect_psymtab_closer) (find_pc_sect_psymtab, find_pc_sect_symtab_from_partial): Change msymbol parameter to bound_minimal_symbol. * ravenscar-thread.c (get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sh64-tdep.c (sh64_elf_make_msymbol_special): Use raw address. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, main_got): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (link_map_start): Update. * solib-spu.c (spu_enable_break, ocl_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol, scan_file_globals): Update. * stack.c (find_frame_funname): Update. * symfile-debug.c (debug_qf_expand_symtabs_matching) (debug_qf_find_pc_sect_symtab): Update. * symfile.c (simple_read_overlay_table) (simple_overlay_update): Update. * symfile.h (struct quick_symbol_functions) <find_pc_sect_symtab>: Change type of msymbol to bound_minimal_symbol. * symmisc.c (dump_msymbols): Update. * symtab.c (find_pc_sect_symtab_via_partial) (find_pc_sect_psymtab, find_pc_sect_line, skip_prologue_sal) (search_symbols, print_msymbol_info): Update. * symtab.h (MSYMBOL_VALUE_RAW_ADDRESS): New macro. (MSYMBOL_VALUE_ADDRESS): Redefine. (BMSYMBOL_VALUE_ADDRESS): New macro. * tracepoint.c (scope_info): Update. * tui/tui-disasm.c (tui_find_disassembly_address) (tui_get_begin_asm_address): Update. * valops.c (find_function_in_inferior): Update. * value.c (value_static_field, value_fn_field): Update.
2014-02-26use bound_minsym as result for lookup_minimal_symbol et alTom Tromey63-375/+484
This patch changes a few minimal symbol lookup functions to return a bound_minimal_symbol rather than a pointer to the minsym. This change helps prepare gdb for computing a minimal symbol's address at the point of use. Note that this changes even those functions that ostensibly search a single objfile. That was necessary because, in fact, those functions can search an objfile and its separate debug objfiles; and it is important for the caller to know in which objfile the minimal symbol was actually found. The bulk of this patch is mechanical. 2014-02-26 Tom Tromey <tromey@redhat.com> * ada-lang.c (ada_update_initial_language): Update. (ada_main_name, ada_has_this_exception_support): Update. * ada-tasks.c (ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * arm-tdep.c (arm_skip_stub): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * breakpoint.c (struct breakpoint_objfile_data) <overlay_msym, longjmp_msym, terminate_msym, exception_msym>: Change type to bound_minimal_symbol. (create_overlay_event_breakpoint) (create_longjmp_master_breakpoint) (create_std_terminate_master_breakpoint) (create_exception_master_breakpoint): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * c-exp.y (classify_name): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * d-lang.c (d_main_name): Update. * dbxread.c (find_stab_function_addr, end_psymtab): Update. * dec-thread.c (enable_dec_thread): Update. * dwarf2loc.c (call_site_to_target_addr): Update. * elfread.c (elf_gnu_ifunc_resolve_by_got): Update. * eval.c (evaluate_subexp_standard): Update. * findvar.c (struct minsym_lookup_data) <result>: Change type to bound_minimal_symbol. <objfile>: Remove. (minsym_lookup_iterator_cb, default_read_var_value): Update. * frame.c (inside_main_func): Update. * frv-tdep.c (frv_frame_this_id): Update. * gcore.c (call_target_sbrk): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v3-abi.c (gnuv3_get_typeid, gnuv3_skip_trampoline): Update. * go-lang.c (go_main_name): Update. * hppa-hpux-tdep.c (hppa_hpux_skip_trampoline_code) (hppa_hpux_find_import_stub_for_addr): Update. * hppa-tdep.c (hppa_extract_17, hppa_lookup_stub_minimal_symbol): Update. Change return type. * hppa-tdep.h (hppa_lookup_stub_minimal_symbol): Change return type. * jit.c (jit_breakpoint_re_set_internal): Update. * linux-fork.c (inferior_call_waitpid, checkpoint_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update * m32c-tdep.c (m32c_return_value) (m32c_m16c_address_to_pointer): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * minsyms.c (lookup_minimal_symbol_internal): Rename to lookup_minimal_symbol. Change return type. (lookup_minimal_symbol): Remove. (lookup_bound_minimal_symbol): Update. (lookup_minimal_symbol_text): Change return type. (lookup_minimal_symbol_solib_trampoline): Change return type. * minsyms.h (lookup_minimal_symbol, lookup_minimal_symbol_text) (lookup_minimal_symbol_solib_trampoline): Change return type. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * objc-lang.c (lookup_objc_class, lookup_child_selector) (value_nsstring, find_imps): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-lang.c (pascal_main_name): Update. * ppc-linux-tdep.c (ppc_linux_spe_context_lookup): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * proc-service.c (ps_pglobal_lookup): Update. * ravenscar-thread.c (get_running_thread_msymbol): Change return type. (has_ravenscar_runtime, get_running_thread_id): Update. * remote.c (remote_check_symbols): Update. * sol-thread.c (ps_pglobal_lookup): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base, frv_relocate_section_addresses): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook) (som_solib_desire_dynamic_linker_symbols, link_map_start): Update. * solib-spu.c (spu_enable_break): Update. * solib-svr4.c (elf_locate_base, enable_break): Update. * spu-tdep.c (spu_get_overlay_table, spu_catch_start) (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. * symfile.c (simple_read_overlay_table): Update. * symtab.c (find_pc_sect_line): Update. * tracepoint.c (scope_info): Update. * tui-disasm.c (tui_get_begin_asm_address): Update. * value.c (value_static_field): Update.
2014-02-26make MSYMBOL_VALUE_ADDRESS an rvalueTom Tromey5-5/+18
This changes MSYMBOL_VALUE_ADDRESS to be an rvalue. In a later patch we change this macro to compute its value; this patch introduces a setter to make the break a bit cleaner. 2014-02-26 Tom Tromey <tromey@redhat.com> * minsyms.c (prim_record_minimal_symbol_full): Use SET_MSYMBOL_VALUE_ADDRESS. * objfiles.c (objfile_relocate1): Use SET_MSYMBOL_VALUE_ADDRESS. * sh64-tdep.c (sh64_elf_make_msymbol_special): Use SET_MSYMBOL_VALUE_ADDRESS. * symtab.h (MSYMBOL_VALUE_ADDRESS): Expand to an rvalue. (SET_MSYMBOL_VALUE_ADDRESS): New macro.
2014-02-26change minsym representationTom Tromey83-331/+537
In a later patch we're going to change the minimal symbol address calculation to apply section offsets at the point of use. To make it simpler to catch potential problem spots, this patch changes the representation of minimal symbols and introduces new minimal-symbol-specific variants of the various accessors. This is necessary because it would be excessively ambitious to try to convert all the symbol types at once. The core of this change is just renaming a field in minimal_symbol; the rest is just a fairly mechanical rewording. 2014-02-26 Tom Tromey <tromey@redhat.com> * symtab.h (struct minimal_symbol) <mginfo>: Rename from ginfo. (MSYMBOL_VALUE, MSYMBOL_VALUE_ADDRESS, MSYMBOL_VALUE_BYTES) (MSYMBOL_BLOCK_VALUE, MSYMBOL_VALUE_CHAIN, MSYMBOL_LANGUAGE) (MSYMBOL_SECTION, MSYMBOL_OBJ_SECTION, MSYMBOL_NATURAL_NAME) (MSYMBOL_LINKAGE_NAME, MSYMBOL_PRINT_NAME, MSYMBOL_DEMANGLED_NAME) (MSYMBOL_SET_LANGUAGE, MSYMBOL_SEARCH_NAME) (MSYMBOL_MATCHES_SEARCH_NAME, MSYMBOL_SET_NAMES): New macros. * ada-lang.c (ada_main_name): Update. (ada_lookup_simple_minsym): Update. (ada_make_symbol_completion_list): Update. (ada_add_standard_exceptions): Update. * ada-tasks.c (read_atcb, ada_tasks_inferior_data_sniffer): Update. * aix-thread.c (pdc_symbol_addrs, pd_enable): Update. * amd64-windows-tdep.c (amd64_skip_main_prologue): Update. * arm-tdep.c (skip_prologue_function): Update. (arm_skip_stack_protector, arm_skip_stub): Update. * arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update. (arm_wince_skip_main_prologue): Update. * auxv.c (ld_so_xfer_auxv): Update. * avr-tdep.c (avr_scan_prologue): Update. * ax-gdb.c (gen_var_ref): Update. * block.c (call_site_for_pc): Update. * blockframe.c (get_pc_function_start): Update. (find_pc_partial_function_gnu_ifunc): Update. * breakpoint.c (create_overlay_event_breakpoint): Update. (create_longjmp_master_breakpoint): Update. (create_std_terminate_master_breakpoint): Update. (create_exception_master_breakpoint): Update. (resolve_sal_pc): Update. * bsd-uthread.c (bsd_uthread_lookup_address): Update. * btrace.c (ftrace_print_function_name, ftrace_function_switched): Update. * c-valprint.c (c_val_print): Update. * coff-pe-read.c (add_pe_forwarded_sym): Update. * coffread.c (coff_symfile_read): Update. * common/agent.c (agent_look_up_symbols): Update. * dbxread.c (find_stab_function_addr): Update. (end_psymtab): Update. * dwarf2loc.c (call_site_to_target_addr): Update. (func_verify_no_selftailcall): Update. (tailcall_dump): Update. (call_site_find_chain_1): Update. (dwarf_expr_reg_to_entry_parameter): Update. * elfread.c (elf_gnu_ifunc_record_cache): Update. (elf_gnu_ifunc_resolve_by_got): Update. * f-valprint.c (info_common_command): Update. * findvar.c (read_var_value): Update. * frame.c (get_prev_frame_1): Update. (inside_main_func): Update. * frv-tdep.c (frv_skip_main_prologue): Update. (frv_frame_this_id): Update. * glibc-tdep.c (glibc_skip_solib_resolver): Update. * gnu-v2-abi.c (gnuv2_value_rtti_type): Update. * gnu-v3-abi.c (gnuv3_rtti_type): Update. (gnuv3_skip_trampoline): Update. * hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline): Update. (hppa64_hpux_in_solib_call_trampoline): Update. (hppa_hpux_skip_trampoline_code): Update. (hppa64_hpux_search_dummy_call_sequence): Update. (hppa_hpux_find_import_stub_for_addr): Update. (hppa_hpux_find_dummy_bpaddr): Update. * hppa-tdep.c (hppa_symbol_address) (hppa_lookup_stub_minimal_symbol): Update. * i386-tdep.c (i386_skip_main_prologue): Update. (i386_pe_skip_trampoline_code): Update. * ia64-tdep.c (ia64_convert_from_func_ptr_addr): Update. * infcall.c (get_function_name): Update. * infcmd.c (until_next_command): Update. * jit.c (jit_breakpoint_re_set_internal): Update. (jit_inferior_init): Update. * linespec.c (minsym_found): Update. (add_minsym): Update. * linux-fork.c (info_checkpoints_command): Update. * linux-nat.c (get_signo): Update. * linux-thread-db.c (inferior_has_bug): Update. * m32c-tdep.c (m32c_return_value): Update. (m32c_m16c_address_to_pointer): Update. (m32c_m16c_pointer_to_address): Update. * m32r-tdep.c (m32r_frame_this_id): Update. * m68hc11-tdep.c (m68hc11_get_register_info): Update. * machoread.c (macho_resolve_oso_sym_with_minsym): Update. * maint.c (maintenance_translate_address): Update. * minsyms.c (add_minsym_to_hash_table): Update. (add_minsym_to_demangled_hash_table): Update. (msymbol_objfile): Update. (lookup_minimal_symbol): Update. (iterate_over_minimal_symbols): Update. (lookup_minimal_symbol_text): Update. (lookup_minimal_symbol_by_pc_name): Update. (lookup_minimal_symbol_solib_trampoline): Update. (lookup_minimal_symbol_by_pc_section_1): Update. (lookup_minimal_symbol_and_objfile): Update. (prim_record_minimal_symbol_full): Update. (compare_minimal_symbols): Update. (compact_minimal_symbols): Update. (build_minimal_symbol_hash_tables): Update. (install_minimal_symbols): Update. (terminate_minimal_symbol_table): Update. (find_solib_trampoline_target): Update. (minimal_symbol_upper_bound): Update. * mips-linux-tdep.c (mips_linux_skip_resolver): Update. * mips-tdep.c (mips_stub_frame_sniffer): Update. (mips_skip_pic_trampoline_code): Update. * msp430-tdep.c (msp430_skip_trampoline_code): Update. * objc-lang.c (selectors_info): Update. (classes_info): Update. (find_methods): Update. (find_imps): Update. (find_objc_msgsend): Update. * objfiles.c (objfile_relocate1): Update. * objfiles.h (ALL_OBJFILE_MSYMBOLS): Update. * obsd-tdep.c (obsd_skip_solib_resolver): Update. * p-valprint.c (pascal_val_print): Update. * parse.c (write_exp_msymbol): Update. * ppc-linux-tdep.c (powerpc_linux_in_dynsym_resolve_code) (ppc_linux_spe_context_lookup, ppc_elfv2_skip_entrypoint): Update. * ppc-sysv-tdep.c (convert_code_addr_to_desc_addr): Update. * printcmd.c (build_address_symbolic): Update. (sym_info): Update. (address_info): Update. * proc-service.c (ps_pglobal_lookup): Update. * psymtab.c (find_pc_sect_psymtab_closer): Update. (find_pc_sect_psymtab): Update. * python/py-framefilter.c (py_print_frame): Update. * ravenscar-thread.c (get_running_thread_id): Update. * record-btrace.c (btrace_call_history, btrace_get_bfun_name): Update. * remote.c (remote_check_symbols): Update. * rs6000-tdep.c (rs6000_skip_main_prologue): Update. (rs6000_skip_trampoline_code): Update. * sh64-tdep.c (sh64_elf_make_msymbol_special): Update. * sol2-tdep.c (sol2_skip_solib_resolver): Update. * solib-dsbt.c (lm_base): Update. * solib-frv.c (lm_base): Update. (main_got): Update. * solib-irix.c (locate_base): Update. * solib-som.c (som_solib_create_inferior_hook): Update. (som_solib_desire_dynamic_linker_symbols): Update. (link_map_start): Update. * solib-spu.c (spu_enable_break): Update. (ocl_enable_break): Update. * solib-svr4.c (elf_locate_base): Update. (enable_break): Update. * spu-tdep.c (spu_get_overlay_table): Update. (spu_catch_start): Update. (flush_ea_cache): Update. * stabsread.c (define_symbol): Update. (scan_file_globals): Update. * stack.c (find_frame_funname): Update. (frame_info): Update. * symfile.c (simple_read_overlay_table): Update. (simple_overlay_update): Update. * symmisc.c (dump_msymbols): Update. * symtab.c (fixup_section): Update. (find_pc_sect_line): Update. (skip_prologue_sal): Update. (search_symbols): Update. (print_msymbol_info): Update. (rbreak_command): Update. (MCOMPLETION_LIST_ADD_SYMBOL): New macro. (completion_list_objc_symbol): Update. (default_make_symbol_completion_list_break_on): Update. * tracepoint.c (scope_info): Update. * tui/tui-disasm.c (tui_find_disassembly_address): Update. (tui_get_begin_asm_address): Update. * valops.c (find_function_in_inferior): Update. * value.c (value_static_field): Update. (value_fn_field): Update.
2014-02-26introduce minimal_symbol_upper_boundTom Tromey5-51/+83
This introduces minimal_symbol_upper_bound and changes various bits of code to use it. Since this function is intimately tied to the implementation of minimal symbol tables, I believe it belongs in minsyms.c. The new function is extracted from find_pc_partial_function_gnu_ifunc. This isn't a "clean" move because the old function interleaved the caching and the computation; but this doesn't make sense for the new code. 2014-02-26 Tom Tromey <tromey@redhat.com> * blockframe.c (find_pc_partial_function_gnu_ifunc): Use bound minimal symbols. Move code that knows about minsym table layout... * minsyms.c (minimal_symbol_upper_bound): ... here. New function. * minsyms.h (minimal_symbol_upper_bound): Declare. * objc-lang.c (find_objc_msgsend): Use bound minimal symbols, minimal_symbol_upper_bound.
2014-02-26[Python] Make regexp collection printers work with typedefs as well.Joel Brobecker6-0/+121
Consider the following type for which we would like to provide a pretty-printer and manage it via RegexpCollectionPrettyPrinter: typedef long time_t; Currently, this does not work because this framework only considers the type's tag name: typename = gdb.types.get_basic_type(val.type).tag if not typename: return None This patch extends it to use the type's name if the basic type does not have a tag name, thus allowing the framework to also work with typedefs like the above. gdb/ChangeLog: * python/lib/gdb/printing.py (RegexpCollectionPrettyPrinter): Use the type's name if its basic type does not have a tag. gdb/testsuite/ChangeLog: * testsuite/gdb.python/py-pp-re-notag.c: New file. * testsuite/gdb.python/py-pp-re-notag.ex: New file. * testsuite/gdb.python/py-pp-re-notag.p: New file.
2014-02-26Add comment in dwarf2read.c::read_subrange_typeJoel Brobecker2-0/+11
This comment explains why we sometimes sign-extend the range type bounds when we normally shouldn't have to. gdb/ChangeLog: * dwarf2read.c (read_subrange_type): Add comment.
2014-02-26DWARF: Set enum type "flag_enum" and "unsigned" flags at type creation.Joel Brobecker5-16/+197
Consider the following Ada code: -- An array whose index is an enumeration type with 128 enumerators. type Enum_T is (Enum_000, Enum_001, [...], Enum_128); type Table is array (Enum_T) of Boolean; When the compiler is configured to generate pure DWARF debugging info, trying to print type Table's description yields: ptype pck.table type = array (enum_000 .. -128) of boolean The expected output was: ptype pck.table type = array (enum_000 .. enum_128) of boolean The DWARF debugging info for our array looks like this: <1><44>: Abbrev Number: 5 (DW_TAG_array_type) <45> DW_AT_name : pck__table <50> DW_AT_type : <0x28> <2><54>: Abbrev Number: 6 (DW_TAG_subrange_type) <55> DW_AT_type : <0x5c> <59> DW_AT_lower_bound : 0 <5a> DW_AT_upper_bound : 128 The array index type is, by construction with the DWARF standard, a subrange of our enumeration type, defined as follow: <2><5b>: Abbrev Number: 0 <1><5c>: Abbrev Number: 7 (DW_TAG_enumeration_type) <5d> DW_AT_name : pck__enum_t <69> DW_AT_byte_size : 1 <2><6b>: Abbrev Number: 8 (DW_TAG_enumerator) <6c> DW_AT_name : pck__enum_000 <7a> DW_AT_const_value : 0 [etc] Therefore, while processing these DIEs, the array index type ends up being a TYPE_CODE_RANGE whose target type is our enumeration type. But the problem is that we read the upper bound as a negative value (-128), which is then used as is by the type printer to print the array upper bound. This negative value explains the "-128" in the output. To understand why the range type's upper bound is read as a negative value, one needs to look at how it is determined, in read_subrange_type: orig_base_type = die_type (die, cu); base_type = check_typedef (orig_base_type); [... high is first correctly read as 128, but then ...] if (!TYPE_UNSIGNED (base_type) && (high & negative_mask)) high |= negative_mask; The negative_mask is applied, here, because BASE_TYPE->FLAG_UNSIGNED is not set. And the reason for that is because the base_type was only partially constructed during the call to die_type. While the enum is constructed on the fly by read_enumeration_type, its flag_unsigned flag is only set later on, while creating the symbols corresponding to the enum type's enumerators (see process_enumeration_scope), after we've already finished creating our range type - and therefore too late. My first naive attempt at fixing this problem consisted in extracting the part in process_enumeration_scope which processes all enumerators, to generate the associated symbols, but more importantly set the type's various flags when necessary. However, this does not always work well, because we're still in the subrange_type's scope, and it might be different from the scope where the enumeration type is defined. So, instead, what this patch does to fix the issue is to extract from process_enumeration_scope the part that determines whether the enumeration type should have the flag_unsigned and/or the flag_flag_enum flags set. It turns out that, aside from the code implementing the loop, this part is fairly independent of the symbol creation. With that part extracted, we can then use it at the end of our enumeration type creation, to produce a type which should now no longer need any adjustment. Once the enumeration type produced is correctly marked as unsigned, the subrange type's upper bound is then correctly read as an unsigned value, therefore giving us an upper bound of 128 instead of -128. gdb/ChangeLog: * dwarf2read.c (update_enumeration_type_from_children): New function, mostly extracted from process_structure_scope. (read_enumeration_type): Call update_enumeration_type_from_children. (process_enumeration_scope): Do not set THIS_TYPE's flag_unsigned and flag_flag_enum fields. gdb/testsuite/ChangeLog: * gdb.dwarf2/arr-subrange.c, gdb.dwarf2/arr-subrange.exp: New files.
2014-02-26Mention PR breakpoints/16292 in corresponding ChangeLog entry.Pedro Alves1-0/+1
2014-02-26bsd-uthread.c: Don't install a to_xfer_partial methodPedro Alves2-16/+6
Whatever the comment about deprecated_xfer_memory referred to, deprecated_xfer_memory is gone now. There's no need to install a target method that just delegates, as that's what the default delegator does already. Tested by building an --enable-targets=all gdb on x86_64 Fedora 17. gdb/ 2014-02-26 Pedro Alves <palves@redhat.com> * bsd-uthread.c (bsd_uthread_xfer_partial): Delete function. (bsd_uthread_target): Don't install bsd_uthread_xfer_partial as to_xfer_partial method.
2014-02-26eliminate target_ops->deprecated_xfer_memoryPedro Alves3-148/+12
As no target uses it anymore, it can finally go away. After removing the deprecated_xfer_memory handling from default_xfer_partial, we can delete the latter, because the only thing it does is delegate to the target beneath unconditionally, which is what the delegator installed by target-delegates.c will do for us if no to_xfer_partial method is installed. This was the last user of de_fault, so that goes away too. Tested on x86_64 Fedora 17. gdb/ 2014-02-26 Pedro Alves <palves@redhat.com> * target.c (complete_target_initialization): Don't install default_xfer_partial as to_xfer_partial hook. (nomemory): Delete. (update_current_target): Don't INHERIT nor de_fault deprecated_xfer_memory. Delete de_fault macro. (default_xfer_partial, deprecated_debug_xfer_memory): Delete. (setup_target_debug): Don't install a deprecated_xfer_memory hook. * target.h (struct target_ops) <deprecated_xfer_memory>: Delete field.
2014-02-26go32-nat.c: Don't install a deprecated_xfer_memory methodPedro Alves2-20/+63
This removes yet another instance of a deprecated_xfer_memory user. Unfortunately djgpp's write_child function takes a non-const buffer pointer, while GDB's xfer_partial api passes a const pointer. To be const-correct, we need to copy that buffer to a non-const buffer, and pass the copy to write_child. This is actually what target.c:default_xfer_partial itself does, when calling into the ops->deprecated_xfer_memory hook. Tested by cross-building djgpp gdb, on x86-64 Fedora 17. gdb/ 2014-02-26 Pedro Alves <palves@redhat.com> * go32-nat.c (my_write_child): New function. (go32_xfer_memory): Rewrite as to_xfer_partial helper. (go32_xfer_partial): New function. (init_go32_ops): Don't install a deprecated_xfer_memory hook. Instead install a to_xfer_partial hook.
2014-02-26nto-procfs.c: Don't install a deprecated_xfer_memory methodPedro Alves2-24/+42
This removes yet another instance of a deprecated_xfer_memory user. Completely untested. gdb/ 2014-02-26 Pedro Alves <palves@redhat.com> * nto-procfs.c (procfs_xfer_memory): Adjust interface as a to_xfer_partial helper. Rewrite. (procfs_xfer_partial): New function. (init_procfs_ops): Don't install a deprecated_xfer_memory hook. Install a to_xfer_partial hook.
2014-02-26remote-m32r-sdi.c: Don't install a deprecated_xfer_memory methodPedro Alves2-18/+50
This removes yet another instance of a deprecated_xfer_memory user. Tested by building a --enable-targets=all gdb, on x86-64 Fedora 17. gdb/ 2014-02-26 Pedro Alves <palves@redhat.com> * remote-m32r-sdi.c (send_data): Constify 'buf' parameter. (m32r_xfer_memory): Adjust as a to_xfer_partial helper. (m32r_xfer_partial): New function. (init_m32r_ops): Don't install a deprecated_xfer_memory hook. Install a to_xfer_partial hook.
2014-02-26remote-mips.c: Don't install a deprecated_xfer_memory methodPedro Alves2-24/+49
This removes another yet instance of a deprecated_xfer_memory user. Tested by building a --enable-targets=all gdb, on x86-64 Fedora 17. gdb/ 2014-02-26 Pedro Alves <palves@redhat.com> * remote-mips.c (mips_xfer_memory): Adjust as to_xfer_partial helper. (mips_xfer_partial): New function. (_initialize_remote_mips): Don't install a deprecated_xfer_memory hook. Install a to_xfer_partial hook.
2014-02-26DWARF: Add array DW_AT_bit_stride and DW_AT_byte_stride supportJoel Brobecker7-6/+187
Consider the following declarations in Ada... type Item is range -32 .. 31; for Item'Size use 6; type Table is array (Natural range 0 .. 4) of Item; pragma Pack (Table); ... which declare a packed array whose elements are 6 bits long. The debugger currently does not notice that the array is packed, and thus prints values of this type incorrectly. This can be seen in the "ptype" output: (gdb) ptype table type = array (0 .. 4) of foo.item Normally, the debugger should print: (gdb) ptype table type = array (0 .. 4) of foo.item <packed: 6-bit elements> The debugging information for this array looks like this: .uleb128 0xf # (DIE (0x15c) DW_TAG_array_type) .long .LASF9 # DW_AT_name: "pck__table" .byte 0x6 # DW_AT_bit_stride .long 0x1a9 # DW_AT_type .uleb128 0x10 # (DIE (0x16a) DW_TAG_subrange_type) .long 0x3b # DW_AT_type .byte 0 # DW_AT_lower_bound .byte 0x4 # DW_AT_upper_bound .byte 0 # end of children of DIE 0x15c The interesting part is the DW_AT_bit_stride attribute, which tells the size of the array elements is 6 bits, rather than the normal element type's size. This patch adds support for this attribute by first creating gdbtypes.c::create_array_type_with_stride, which is an enhanced version of create_array_type taking an extra parameter as the stride. The old create_array_type can then be re-implemented very simply by calling the new create_array_type_with_stride. We can then use this new function from dwarf2read, to create arrays with or without stride. gdb/ChangeLog: * gdbtypes.h (create_array_type_with_stride): Add declaration. * gdbtypes.c (create_array_type_with_stride): New function, renaming create_array_type, but with an added parameter called "bit_stride". (create_array_type): Re-implement using create_array_type_with_stride. * dwarf2read.c (read_array_type): Add support for DW_AT_byte_stride and DW_AT_bit_stride attributes. gdb/testsuite/ChangeLog: * gdb.dwarf2/arr-stride.c: New file. * gdb.dwarf2/arr-stride.exp: New file. The test, relying purely on generating an assembly file, only verifies the type description of our array. But I was also able to verify manually that the debugger print values of these types correctly as well (which was not the case prior to this patch).
2014-02-26Multiple Ada task-specific breakpoints at the same address.Pedro Alves4-8/+41
With the test changed as in the patch, against current mainline, we get: (gdb) PASS: gdb.ada/tasks.exp: info tasks before inserting breakpoint break break_me task 1 Breakpoint 2 at 0x4030b0: file /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.ada/tasks/foo.adb, line 27. (gdb) PASS: gdb.ada/tasks.exp: break break_me task 1 break break_me task 3 Note: breakpoint 2 also set at pc 0x4030b0. Breakpoint 3 at 0x4030b0: file /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.ada/tasks/foo.adb, line 27. (gdb) PASS: gdb.ada/tasks.exp: break break_me task 3 continue Continuing. [Switching to Thread 0x7ffff7dc7700 (LWP 27133)] Breakpoint 2, foo.break_me () at /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.ada/tasks/foo.adb:27 27 null; (gdb) FAIL: gdb.ada/tasks.exp: continue to breakpoint info tasks ID TID P-ID Pri State Name 1 63b010 48 Waiting on RV with 3 main_task 2 63bd80 1 48 Accept or Select Term task_list(1) * 3 63f510 1 48 Accepting RV with 1 task_list(2) 4 642ca0 1 48 Accept or Select Term task_list(3) (gdb) PASS: gdb.ada/tasks.exp: info tasks after hitting breakpoint The breakpoint that caused a stop is breakpoint 3, but GDB end up reporting (and running breakpoint commands of) "Breakpoint 2" instead. The issue is that the bpstat_check_breakpoint_conditions logic of "wrong thread" is missing the "wrong task" check. This is usually harmless, because the thread hop code in infrun.c code that handles wrong-task-hitting-breakpoint does check for task-specific breakpoints (within breakpoint_thread_match): /* Check if a regular breakpoint has been hit before checking for a potential single step breakpoint. Otherwise, GDB will not see this breakpoint hit when stepping onto breakpoints. */ if (regular_breakpoint_inserted_here_p (aspace, stop_pc)) { if (!breakpoint_thread_match (aspace, stop_pc, ecs->ptid)) thread_hop_needed = 1; } IOW, usually, when one only has a task specific breakpoint at a given address, things work correctly. Put another task-specific or non-task-specific breakpoint there, and things break. A patch that eliminates the special thread hop code in infrun.c is what exposed this, as after that GDB solely relies on bpstat_check_breakpoint_conditions to know whether the right or wrong task hit a breakpoint. IOW, given the latent bug, Ada task-specific breakpoints become non-task-specific, and that is caught by the testsuite, as: break break_me task 3 Breakpoint 2 at 0x4030b0: file /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.ada/tasks/foo.adb, line 27. (gdb) PASS: gdb.ada/tasks.exp: break break_me task 3 continue Continuing. [Switching to Thread 0x7ffff7fcb700 (LWP 17122)] Breakpoint 2, foo.break_me () at /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.ada/tasks/foo.adb:27 27 null; (gdb) PASS: gdb.ada/tasks.exp: continue to breakpoint info tasks ID TID P-ID Pri State Name 1 63b010 48 Waiting on RV with 2 main_task * 2 63bd80 1 48 Accepting RV with 1 task_list(1) 3 63f510 1 48 Accept or Select Term task_list(2) 4 642ca0 1 48 Accept or Select Term task_list(3) (gdb) FAIL: gdb.ada/tasks.exp: info tasks after hitting breakpoint It was after seeing this that I thought of how to expose the bug with current mainline. Tested on x86_64 Fedora 17. gdb/ 2014-02-26 Pedro Alves <palves@redhat.com> * breakpoint.c (bpstat_check_breakpoint_conditions): Handle task-specific breakpoints. gdb/testsuite/ 2014-02-26 Pedro Alves <palves@redhat.com> * gdb.ada/tasks.exp: Set a task-specific breakpoint at break_me that won't ever trigger. Make sure that GDB reports the correct breakpoint that caused the stop.
2014-02-25Re-implement ia64-linux-nat.c::ia64_linux_xfer_partialPedro Alves2-12/+28
[description of this patch and ChangeLog entry by Joel Brobecker] The recent implementation was questionable, and if it worked, it was only by chance because the requested length is large enough that only one read was sufficient. Note that the implementation before that also made that assumption, in the form of only handling TARGET_OBJECT_UNWIND_TABLE xfer requests when offset was zero. gdb/ChangeLog: * ia64-linux-nat.c (ia64_linux_xfer_partial): Reimplement handling of object == TARGET_OBJECT_UNWIND_TABLE.
2014-02-25Annotate comments for Doxygen.Stan Shebs2-64/+72
2014-02-25PR gdb/16626Jan Kratochvil2-2/+5
gdb/testsuite/ 2014-02-25 Jan Kratochvil <jan.kratochvil@redhat.com> PR gdb/16626 * gdb.base/auto-load.exp: Fix out-of-srctree run. Message-ID: <87k3cjt3jl.fsf@fleche.redhat.com>
2014-02-25remove target_ignoreTom Tromey3-10/+5
This removes target_ignore, which isn't used any more. 2014-02-25 Tom Tromey <tromey@redhat.com> * target.h (target_ignore): Don't declare. * target.c (target_ignore): Remove.
2014-02-25PR gdb/16626Jan Kratochvil6-3/+96
Fix auto-load 7.7 regression, the regression affects any loading from /usr/share/gdb/auto-load . 5b2bf9471f1499bee578fcd60c05afe85794e280 is the first bad commit commit 5b2bf9471f1499bee578fcd60c05afe85794e280 Author: Doug Evans <xdje42@gmail.com> Date: Fri Nov 29 21:29:26 2013 -0800 Move .debug_gdb_script processing to auto-load.c. Simplify handling of auto-loaded objfile scripts. Fedora 20 x86_64 $ gdb -q /usr/lib64/libgobject-2.0.so Reading symbols from /usr/lib64/libglib-2.0.so.0.3800.2...Reading symbols from /usr/lib/debug/usr/lib64/libglib-2.0.so.0.3800.2.debug...done. done. (gdb) _ Fedora Rawhide x86_64 $ gdb -q /usr/lib64/libgobject-2.0.so Reading symbols from /usr/lib64/libglib-2.0.so...Reading symbols from /usr/lib/debug/usr/lib64/libglib-2.0.so.0.3990.0.debug...done. done. warning: File "/usr/lib64/libglib-2.0.so.0.3990.0-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load:/usr/bin/mono-gdb.py". To enable execution of this file add add-auto-load-safe-path /usr/lib64/libglib-2.0.so.0.3990.0-gdb.py line to your configuration file "/home/jkratoch/.gdbinit". To completely disable this security protection add set auto-load safe-path / line to your configuration file "/home/jkratoch/.gdbinit". For more information about this security protection see the "Auto-loading safe path" section in the GDB manual. E.g., run from the shell: info "(gdb)Auto-loading safe path" (gdb) _ That is it tries to load "forbidden" /usr/lib64/libglib-2.0.so.0.3990.0-gdb.py but it should load instead /usr/share/gdb/auto-load/usr/lib64/libglib-2.0.so.0.3990.0-gdb.py* Although that is also not exactly this way, there does not exist any /usr/lib64/libglib-2.0.so.0.3990.0-gdb.py despite regressed GDB says so. gdb/ 2014-02-24 Jan Kratochvil <jan.kratochvil@redhat.com> PR gdb/16626 * auto-load.c (auto_load_objfile_script_1): Change filename to debugfile. gdb/testsuite/ 2014-02-24 Jan Kratochvil <jan.kratochvil@redhat.com> PR gdb/16626 * gdb.base/auto-load-script: New file. * gdb.base/auto-load.c: New file. * gdb.base/auto-load.exp: New file. Message-ID: <20140223212400.GA8831@host2.jankratochvil.net>
2014-02-25Fix dw2-icycle.exp -fsanitize=address GDB crash.Jan Kratochvil2-10/+5
binutils readelf -wi: <4><a2>: Abbrev Number: 26 (DW_TAG_inlined_subroutine) <a3> DW_AT_abstract_origin: <0x5a> <a7> DW_AT_low_pc : 0x400590 <ab> DW_AT_high_pc : 0x4 <af> DW_AT_call_file : 1 <b0> DW_AT_call_line : 20 <b1> DW_AT_sibling : <0xb8> <2><b8>: Abbrev Number: 35 (DW_TAG_inlined_subroutine) <b9> DW_AT_abstract_origin: <0x5a> <bd> DW_AT_low_pc : 0x400590 <c1> DW_AT_high_pc : 0x4 <c5> DW_AT_call_file : 1 <c6> DW_AT_call_line : 29 <b1> DW_AT_sibling points to the next DIE - but that DIE is 2 levels upwards - definitely not a sibling. This confuses GDB up to a crash: ==32143== ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6024000198ac at pc 0xb4d104 bp 0x7fff63e96e70 sp 0x7fff63e96e60 READ of size 1 at 0x6024000198ac thread T0 #0 0xb4d103 in read_unsigned_leb128 (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xb4d103) #1 0xb15f3c in peek_die_abbrev (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xb15f3c) #2 0xb46185 in load_partial_dies (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xb46185) #3 0xb103fb in process_psymtab_comp_unit_reader (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xb103fb) #4 0xb0d2a9 in init_cutu_and_read_dies (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xb0d2a9) #5 0xb1115f in process_psymtab_comp_unit (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xb1115f) #6 0xb1235f in dwarf2_build_psymtabs_hard (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xb1235f) #7 0xb05536 in dwarf2_build_psymtabs (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0xb05536) #8 0x86d5a5 in read_psyms (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x86d5a5) #9 0x9b1c37 in require_partial_symbols (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x9b1c37) #10 0x9bf2d0 in read_symbols (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x9bf2d0) #11 0x9c014c in syms_from_objfile_1 (/home/jkratoch/redhat/gdb-clean/gdb/gdb+0x9c014c) gdb/testsuite/ 2014-02-25 Jan Kratochvil <jan.kratochvil@redhat.com> Fix dw2-icycle.exp -fsanitize=address GDB crash. * gdb.dwarf2/dw2-icycle.S: Remove all DW_AT_sibling. Message-ID: <20140224201011.GA28926@host2.jankratochvil.net>
2014-02-25Adjust ia64_linux_xfer_partial following to_xfer_partial API change.Joel Brobecker2-5/+29
ia64-linux-nat.c no longer compiles because ia64_linux_xfer_partial no longer matches the to_xfer_partial prototype. This patch fixes the problem by adjusting it accordingly. gdb/ChangeLog: * ia64-linux-nat.c (ia64_linux_xfer_partial): Add function documentation. Adjust prototype to match the target_ops to_xfer_partial method. Adjust implementation accordingly.
2014-02-25Fix a format issue of ChangeLog.Hui Zhu1-1/+1
2014-02-252014-02-25 Hui Zhu <hui@codesourcery.com>Hui Zhu2-1/+6
* target.h (target_ops): Fix TARGET_DEFAULT_RETURN of to_traceframe_info.
2014-02-25Use 16-bit integer type for rl78 register pairs.Kevin Buettner2-6/+82
This patch changes rl78-tdep.c so that a 16-bit type is used for register pairs instead of a pointer type as was previously the case. This will cause these register pairs to be displayed as integers instead of as a data address with a 0xf0000 ORed in. E.g. registers ax, bc, de, and hl might now be displayed like this: (gdb) info registers ax bc de hl ax 0x6 6 bc 0x0 0 de 0x10c3 4291 hl 0x108d 423 Whereas, before, they were displayed as follows: (gdb) info registers ax bc de hl ax 0xf0006 0xf0006 bc 0xf0000 0xf0000 de 0xf10c3 0xf10c3 hl 0xf108d 0xf108d These pairs are 16 bit quantities and should be displayed as such. This change also affects the way that the banked register pairs are displayed. Within GDB, the banked register pairs are named bank0_rp0, bank0_rp1, .., bank3_rp2, bank3_rp3. However, these register pairs need to be used as addresses in DWARF expressions. I have added 16 pseudo registers corresponding to banked register pairs. These new pseudo registers are all hidden from the user and have a pointer type. Values from these registers are intended to be used in DWARF expressions. Therefore, rl78_dwarf_reg_to_regnum() has been adjusted to return these new pseudo register numbers. I had a much simpler patch which only changed the types, but it showed a number of regressions due to integer values from the banked register pairs being used as part of an address expression. This current patch shows no regressions and now displays values of register pairs correctly. * rl78-tdep.c ( RL78_BANK0_RP0_PTR_REGNUM, RL78_BANK0_RP1_PTR_REGNUM) (RL78_BANK0_RP2_PTR_REGNUM, RL78_BANK0_RP3_PTR_REGNUM) (RL78_BANK1_RP0_PTR_REGNUM, RL78_BANK1_RP1_PTR_REGNUM) (RL78_BANK1_RP2_PTR_REGNUM, RL78_BANK1_RP3_PTR_REGNUM) (RL78_BANK2_RP0_PTR_REGNUM, RL78_BANK2_RP1_PTR_REGNUM) (RL78_BANK2_RP2_PTR_REGNUM, RL78_BANK2_RP3_PTR_REGNUM) (RL78_BANK3_RP0_PTR_REGNUM, RL78_BANK3_RP1_PTR_REGNUM) (RL78_BANK3_RP2_PTR_REGNUM, RL78_BANK3_RP3_PTR_REGNUM): New constants. (rl78_register_type): Use a data pointer type for SP and new pseudo registers mentioned above. Use a 16 bit integer type for all other register pairs. (rl78_register_name, rl78_g10_register_name): Update for new pseudo registers. (rl78_pseudo_register_read): Likewise. (rl78_pseudo_register_write): Likewise. (rl78_dwarf_reg_to_regnum): Return register numbers representing to the newly added pseudo registers.
2014-02-24 * value.c (record_latest_value): Fix comment.Doug Evans3-15/+11
* printcmd.c (print_command_1): Remove code to handle -1 return from record_latest_value.
2014-02-24lib/gdb.exp (run_on_host): Log error output if program fails.Doug Evans2-0/+5
2014-02-24procfs.c: Don't install a deprecated_xfer_memory methodPedro Alves2-46/+36
This removes yet another instance of a deprecated_xfer_memory user, and fixes a nasty regression as a side-effect: (gdb) start Temporary breakpoint 1 at 0x19070: file simple_main.adb, line 4. Starting program: /[...]/simple_main Warning: Cannot insert breakpoint 1. Cannot access memory at address 0x19070 Cannot insert breakpoint -3. Temporarily disabling shared library breakpoints: breakpoint #-3 The regression was introduced by the to_xfer_partial transition to return a status enum. procfs_xfer_partial was updated but not the case where object is TARGET_OBJECT_MEMORY. As result, procfs_xfer_partial was returning the length xfered rather than the status, and the xfered buffer was left uninitialized. gdb/ 2014-02-19 Pedro Alves <palves@redhat.com> * procfs.c (procfs_target): Don't install procfs_xfer_memory as deprecated_xfer_memory hook. (procfs_xfer_partial): Call procfs_xfer_memory instead of the deprecated_xfer_memory target hook. (procfs_xfer_memory): Adjust interface as a to_xfer_partial helper.
2014-02-24Fix a GDB assert failure on windowsYuanhui Zhang2-1/+7
A GDB internal error is found on native mingw32 target. (gdb) run ../../binutils-gdb/gdb/target.c:1483: internal-error: target_xfer_partial: Assertion `*xfered_len > 0' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) This error was introduced by the following snippet in commit 9b409511d07fe375284701af34909fb539029caf > @@ -2536,27 +2538,30 @@ windows_xfer_shared_libraries (struct target_ops *ops, > } > > obstack_free (&obstack, NULL); > - return len; > + *xfered_len = (ULONGEST) len; > + return TARGET_XFER_OK; > } In the original code, len is returned, which could be 0, but after that commit, only TARGET_XFER_OK is returned, which is wrong. If len is 0, TARGET_XFER_EOF should be returned. (it is 0 in enum target_xfer_status declaration). gdb: 2014-02-24 Yuanhui Zhang <asmwarrior@gmail.com> * windows-nat.c (windows_xfer_shared_libraries): Return TARGET_XFER_EOF if LEN is zero to fix an assert failure when requested object is TARGET_OBJECT_LIBRARIES.
2014-02-24Rename TARGET_XFER_E_UNAVAILABLE to TARGET_XFER_UNAVAILABLEYao Qi8-18/+32
Nowadays, TARGET_XFER_E_UNAVAILABLE isn't regarded as an error in to_xfer_partial interface, so _E_ looks odd. This patch is to replace TARGET_XFER_E_UNAVAILABLE with TARGET_XFER_UNAVAILABLE, and change its value from -2 to 2. Since there is no comparison on the value of 'enum target_xfer_status', so it should be safe. gdb: 2014-02-24 Yao Qi <yao@codesourcery.com> * target.h (enum target_xfer_status) <TARGET_XFER_E_UNAVAILABLE>: Rename it to ... <TARGET_XFER_UNAVAILABLE>: ... it with setting value 2 explicitly. New. * corefile.c (memory_error_message): User updated. * exec.c (section_table_read_available_memory): Likewise. * record-btrace.c (record_btrace_xfer_partial): Likewise. * target.c (target_xfer_status_to_string): Likewise. (raw_memory_xfer_partial): Likewise. (memory_xfer_partial_1, target_xfer_partial): Likewise. * valops.c (read_value_memory): Likewise. * exec.h: Update comments.
2014-02-24Tweak target_xfer_status_to_stringYao Qi3-5/+14
This patch tweaks target_xfer_status_to_string on comments and argument name. gdb: 2014-02-24 Yao Qi <yao@codesourcery.com> * target.c (target_xfer_status_to_string): Rename argument err to status. * target.h (target_xfer_status_to_string): Update declaration. Replace target_xfer_error_to_string with target_xfer_status_to_string in comment.
2014-02-24Unbreak mips native buildYao Qi2-2/+7
When I build mips native gdb today, I get the follow error, ../../../git/gdb/mips-linux-nat.c: In function '_initialize_mips_linux_nat': ../../../git/gdb/mips-linux-nat.c:792:15: error: assignment from incompatible pointer type [-Werror] cc1: all warnings being treated as errors It looks an oversight of recent target_ops delegation patches. This patch is to fix the build error. gdb: 2014-02-24 Yao Qi <yao@codesourcery.com> * mips-linux-nat.c (super_close): Update its type. (mips_linux_close): Pass 'self' to super_close.