This patch causes regressions in ada's operator_bp.exp test.
That's because it uses wild_match which expects arguments in
the original order.
There is still a bug here. It's hard to see because either minsyms
save the day, or the needed symtab gets expanded before linespecs
need it because of the call to cp_canonicalize_string_no_typedefs
in linespec.c:find_linespec_symbols.
But if you disable both of those things, then the bug is visible.
bash$ ./gdb -D ./data-directory testsuite/gdb.cp/anon-ns
(gdb) b doit(void)
Function "doit(void)" not defined.
gdb/ChangeLog:
Revert:
PR symtab/17602
* linespec.c (iterate_name_matcher): Fix arguments to symbol_name_cmp.
During debugging I get 10-30 seconds for a response to simple commands like:
(gdb) print vectorvar.size()
With this patch the performance gets to 1-2 seconds which is somehow
acceptable. The problem is that dwarf2_gdb_index_functions.lookup_symbol
(quick_symbol_functions::lookup_symbol) may return (and returns) NULL even for
symbols which are present in .gdb_index but which can be found in already
expanded symtab. But searching in the already expanded symtabs is just too
slow when there are 400000+ expanded symtabs. There would be needed some
single global hash table for each objfile so that one does not have to iterate
all symtabs. Which .gdb_index could perfectly serve for, just its
lookup_symbol() would need to return authoritative yes/no answers.
Even after such fix these two simple patches are useful for example for
non-.gdb_index files.
One can reproduce the slugging interactive GDB performance with:
#include <string>
using namespace std;
string var;
class C {
public:
void m() {}
};
int main() {
C c;
c.m();
return 0;
}
g++ -o slow slow.C -Wall -g $(pkg-config --libs gtkmm-3.0)
gdb ./slow -ex 'b C::m' -ex 'maintenance set per-command space' -ex 'maintenance set per-command symtab' -ex 'maintenance set per-command
time' -ex r
[...]
(gdb) p <tab><tab>
Display all 183904 possibilities? (y or n) n
(gdb) p/r var
$1 = {static npos = <optimized out>, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No
data fields>}, _M_p = 0x3a4db073d8 <std::string::_Rep::_S_empty_rep_storage+24> ""}}
Command execution time: 20.023000 (cpu), 20.118665 (wall)
^^^^^^^^^
Space used: 927997952 (+0 for this command)
Without DWZ there are X global blocks for X primary symtabs for X CUs of
objfile. With DWZ there are X+Y global blocks for X+Y primary symtabs for
X+Y CUs where Y are 'DW_TAG_partial_unit's.
For 'DW_TAG_partial_unit's (Ys) their blockvector is usually empty. But not
always, I have found there typedef symbols, there can IMO be optimized-out
static variables etc.
Neither of the patches should cause any visible behavior change.
gdb/ChangeLog
2014-12-04 Jan Kratochvil <jan.kratochvil@redhat.com>
* block.c (block_lookup_symbol_primary): New function.
* block.h (block_lookup_symbol_primary): New declaration.
* symtab.c (lookup_symbol_in_objfile_symtabs): Assert BLOCK_INDEX.
Call block_lookup_symbol_primary.
The necessity for this change has been revealed in the course of
investigation related to proposed changes in the treatment of the ISA
bit encoded in function symbols on the MIPS target. This change adds
support for Linux signal trampolines encoded with the microMIPS
instruction set. Such trampolines are used by the Linux kernel if
compiled as a microMIPS binary (even if the binary run/debugged itself
contains no microMIPS code at all).
To see if we need to check whether the execution mode selected matches
the given trampoline I have checked what the bit patterns of all the
trampoline sequences decode to in the opposite instruction set. This
produced useless or at least unusual code in most cases, for example:
microMIPS/EB, o32 sigreturn, decoded as MIPS code:
30401017 andi zero,v0,0x1017
00008b7c dsll32 s1,zero,0xd
MIPS/EL, o32 sigreturn, decoded as microMIPS code:
1017 2402 addi zero,s7,9218
000c 0000 sll zero,t0,0x0
However in some corner cases reasonable code can mimic a trampoline, for
example:
MIPS/EB, n32 rt_sigreturn, decoded as microMIPS code:
2402 sll s0,s0,1
1843 0000 sb v0,0(v1)
000c 0f3c jr t0
-- here the first instruction is a 16-bit one, making things nastier
even as there are some other microMIPS instructions whose first 16-bit
halfword is 0x000c and therefore matches this whole trampoline pattern.
To overcome this problem I have decided the signal trampoline unwinder
has to ask the platform backend whether it can apply a given trampoline
pattern to the code location being concerned or not. Anticipating the
acceptance of the ISA bit proposal I decided the handler not to merely
be a predicate, but also to be able to provide an adjusted PC if
required. I decided that returning zero will mean that the trampoline
pattern is not applicable and any other value is the adjusted PC to use;
a handler may return the value requested if the trampoline pattern and
the PC requested as-is are both accepted.
This changes the semantics of the trampoline unwinder a bit in that the
zero PC now has a special value. I think this should be safe as a NULL
pointer is generally supposed to be invalid.
* tramp-frame.h (tramp_frame): Add `validate' member.
* tramp-frame.c (tramp_frame_start): Validate trampoline before
scanning.
* mips-linux-tdep.c (MICROMIPS_INST_LI_V0): New macro.
(MICROMIPS_INST_POOL32A, MICROMIPS_INST_SYSCALL): Likewise.
(mips_linux_o32_sigframe): Initialize `validate' member.
(mips_linux_o32_rt_sigframe): Likewise.
(mips_linux_n32_rt_sigframe): Likewise.
(mips_linux_n64_rt_sigframe): Likewise.
(micromips_linux_o32_sigframe): New variable.
(micromips_linux_o32_rt_sigframe): Likewise.
(micromips_linux_n32_rt_sigframe): Likewise.
(micromips_linux_n64_rt_sigframe): Likewise.
(mips_linux_o32_sigframe_init): Handle microMIPS trampolines.
(mips_linux_n32n64_sigframe_init): Likewise.
(mips_linux_sigframe_validate): New function.
(micromips_linux_sigframe_validate): Likewise.
(mips_linux_init_abi): Install microMIPS trampoline unwinders.
Remove native-only core file handling on Sparc Solaris. Instead,
enable the sparc target generic core regset logic on Solaris by
providing appropriate register offset maps.
Thanks to Joel Brobecker for testing!
gdb/
* config/sparc/sol2.mh (NATDEPFILES): Remove core-regset.o.
* sparc-sol2-tdep.c: Include "regset.h".
(sparc32_sol2_supply_core_gregset): New function.
(sparc32_sol2_collect_core_gregset): Likewise.
(sparc32_sol2_supply_core_fpregset): Likewise.
(sparc32_sol2_collect_core_fpregset): Likewise.
(sparc32_sol2_gregset, sparc32_sol2_fpregset): New variables.
(sparc32_sol2_init_abi): Set tdep->gregset/sizeof_gregset and
tdep->fpregset/sizeof_fpregset.
* sparc64-sol2-tdep.c: Include "regset.h".
(sparc64_sol2_supply_core_gregset): New function.
(sparc64_sol2_collect_core_gregset): Likewise.
(sparc64_sol2_supply_core_fpregset): Likewise.
(sparc64_sol2_collect_core_fpregset): Likewise.
(sparc64_sol2_gregset, sparc64_sol2_fpregset): New variables.
(sparc64_sol2_init_abi): Set tdep->gregset/sizeof_gregset and
tdep->fpregset/sizeof_fpregset.
The definition does not use the typedef for the dtor function pointer
type that the declaration uses. It's a cosmetic-only change.
ChangeLog:
* common/cleanups.c (make_cleanup_dtor): Use typedef for dtor
type.
This patch reverts the addition of cplus_specific added here:
2010-07-16 Sami Wagiaalla <swagiaal@redhat.com>
* symtab.h (symbol_set_demangled_name): Now takes an optional objfile*
argument.
(cplus_specific): New struct.
* symtab.c (symbol_set_demangled_name): Updated.
Use cplus_specific for cplus symbols.
(symbol_get_demangled_name): Retrive the name from the cplus_specific
struct for cplus symbols.
(symbol_init_language_specific): Set cplus_specific for cplus symbols.
(symbol_set_names): Pass objfile to symbol_set_demangled_name.
* symtab.c (symbol_init_cplus_specific): New function.
It was added in anticipation of improved template support:
https://sourceware.org/ml/gdb-patches/2010-05/msg00594.htmlhttps://sourceware.org/ml/gdb-patches/2010-07/msg00284.html
However, minsyms pay the price for this space too.
For my standard benchmark this patch gets back 44MB of memory
when gdb starts. [There's still ~440MB of memory used
by the demangled ELF symbols of this benchmark, but that's another topic.]
When the improved templated support is added,
I wonder if this can be moved to struct symbol.
Hmmm, we already have a special version of
struct symbol for templates (struct template_symbol).
gdb/ChangeLog:
* symtab.c (symbol_init_cplus_specific): Delete.
(symbol_set_demangled_name): Remove special c++ support.
(symbol_get_demangled_name, symbol_set_language): Ditto.
* symtab.h (struct cplus_specific): Delete.
(struct general_symbol_info) <language_specific>: Remove
cplus_specific.
Fix a typo in the expedited registers for s390-te-linux64.
gdb/ChangeLog:
* features/Makefile (s390-te-linux64-expedite): Replace
non-existant r14 and r15 by r14l and r15l, respectively.
* regformats/s390-te-linux64.dat: Regenerate.
Remove native-only core file handling on GNU Hurd. Instead, enable the
x86 target generic core regset logic on the Hurd by providing an
appropriate register offset map.
Thanks to Samuel Thibault for testing!
gdb/
* config/i386/i386gnu.mh (NATDEPFILES): Remove core-regset.o.
* i386gnu-nat.c: Do not include <sys/procfs.h> or "gregset.h".
(CREG_OFFSET, creg_offset, CREG_ADDR): Remove.
(supply_gregset, supply_fpregset): Remove.
* i386gnu-tdep.c (i386gnu_gregset_reg_offset): New variable.
(i386gnu_init_abi): Set tdep->gregset_reg_offset, gregset_num_regs,
and sizeof_gregset.
There is already "add-auto-load-safe-path" which works
like "set auto-load safe-path" but in append mode.
There was missing an append equivalent for "set auto-load scripts-directory".
ABRT has directory /var/cache/abrt-di/ as an alternative one
to /usr/lib/debug/ . Therefore ABRT needs to use -iex parameters to add this
/var/cache/abrt-di/ directory as a first-class debuginfo directory.
Using absolute "set auto-load scripts-directory" would hard-code the path
possibly overriding local system directory additions; besides it would not be
nice anyway.
gdb/ChangeLog
2014-11-30 Jan Kratochvil <jan.kratochvil@redhat.com>
Add add-auto-load-scripts-directory.
* NEWS (Changes since GDB 7.8): Add add-auto-load-scripts-directory.
* auto-load.c (add_auto_load_dir): New function.
(_initialize_auto_load): Install it.
gdb/doc/ChangeLog
2014-11-30 Jan Kratochvil <jan.kratochvil@redhat.com>
Add add-auto-load-scripts-directory.
* gdb.texinfo (Auto-loading): Add add-auto-load-scripts-directory link.
(objfile-gdbdotext file): Add add-auto-load-scripts-directory.
I noticed in frame_id_eq() we were checking for the "l" frame_id being
invalid twice instead of checking both "l" and "r", so this patch
corrects it.
gdb/ChangeLog:
* frame.c (frame_id_eq): Fix the check for FID_STACK_INVALID.
This fixes a regression introduced by 6c659fc2c7.
gdb/ChangeLog:
* eval.c (evaluate_subexp): Check that thread stack temporaries
are not already enabled before enabling them.
I find local variables framereg and framesize is only used when cache
isn't NULL. This patch to move the code into "if (cache)" block.
gdb:
2014-11-29 Yao Qi <yao@codesourcery.com>
* arm-tdep.c (arm_analyze_prologue): Move local variables
'framereg' and 'framesize' to inner block. Move code to
inner block too.
gdb/ChangeLog:
* eval.c: Include gdbthread.h.
(evaluate_subexp): Enable thread stack temporaries before
evaluating a complete expression and clean them up after the
evaluation is complete.
* gdbthread.h: Include common/vec.h.
(value_ptr): New typedef.
(VEC (value_ptr)): New vector type.
(value_vec): New typedef.
(struct thread_info): Add new fields stack_temporaries_enabled
and stack_temporaries.
(enable_thread_stack_temporaries)
(thread_stack_temporaries_enabled_p, push_thread_stack_temporary)
(get_last_thread_stack_temporary)
(value_in_thread_stack_temporaries): Declare.
* gdbtypes.c (class_or_union_p): New function.
* gdbtypes.h (class_or_union_p): Declare.
* infcall.c (call_function_by_hand): Store return values of class
type as temporaries on stack.
* thread.c (enable_thread_stack_temporaries): New function.
(thread_stack_temporaries_enabled_p, push_thread_stack_temporary)
(get_last_thread_stack_temporary): Likewise.
(value_in_thread_stack_temporaries): Likewise.
* value.c (value_force_lval): New function.
* value.h (value_force_lval): Declare.
gdb/testsuite/ChangeLog:
* gdb.cp/chained-calls.cc: New file.
* gdb.cp/chained-calls.exp: New file.
* gdb.cp/smartp.exp: Remove KFAIL for "p c2->inta".
Dwarf register numbers are defined in "System V Application Binary
Interface AMD64 Architecture Processor Supplement Draft Version 0.99.6"
The amd64_dwarf_regmap array is missing the 8 MMX registers in Figure
3.36: DWARF Register Number Mapping page 57. This leads to a wrong
value for the registers past this point.
gdb/ChangeLog:
Pushed by Joel Brobecker <brobecker@adacore.com>.
* amd64-tdep.c (amd64_dwarf_regmap array): Add missing MMX
registers.
Tested on x86_64-linux.
Since Andreas Arnez' recent patch series, all Linux targets install
gdbarch_iterate_over_regset_sections routines. This means that on
Linux native targets, old-style core sniffers are never used.
Most Linux targets haven't been using such sniffers for a long time
anyway, but a couple remain: ia64 and sparc use core-regset.o, and
m68k installs its own core_fns. All this is now dead code, which
this commit removes.
gdb/
2014-11-28 Ulrich Weigand <uweigand@de.ibm.com>
* config/ia64/linux.mh (NATDEPFILES): Remove core-regset.o.
* config/sparc/linux.mh (NATDEPFILES): Likewise.
* config/sparc/linux64.mh (NATDEPFILES): Likewise.
* m68klinux-nat.c (fetch_core_registers): Remove.
(linux_elf_core_fns): Remove.
(_initialize_m68k_linux_nat): Do not call deprecated_add_core_fns.
Rework the comment to explain why we're still relying on GetFullPathName
even though gnulib ensures that canonicalize_file_name is now available
on all platforms, including Windows.
gdb/ChangeLog:
* utils.c (gdb_realpath): Rework comment about handling on
Windows.
Since lstat gnulib module is imported, we can use it unconditionally.
lstat usage was introduced by this patch
https://sourceware.org/ml/gdb-patches/2012-01/msg00390.html
during the review, it was suggested to import gnulib lstat module, but
we didn't do that.
gdb:
2014-11-28 Yao Qi <yao@codesourcery.com>
* configure.ac (AC_CHECK_FUNCS): Remove lstat.
* config.in, configure: Regenerate.
* symfile.c (find_separate_debug_file_by_debuglink): Remove
code checking HAVE_LSTAT is defined.
Since readlink module is imported, we can use it unconditionally.
This patch is to remove configure checks and HAVE_READLINK checks in
code. It was mentioned in the patch below
[RFA/commit] gdbserver: return ENOSYS if readlink not supported.
https://sourceware.org/ml/gdb-patches/2012-02/msg00148.html
to use readlink in gdbserver, but we chose something simple at that
moment.
gdb:
2014-11-28 Yao Qi <yao@codesourcery.com>
* configure.ac (AC_CHECK_FUNCS): Remove readlink.
* config.in, configure: Re-generate.
* inf-child.c (inf_child_fileio_readlink): Don't check
HAVE_READLINK is defined.
gdb/gdbserver:
2014-11-28 Yao Qi <yao@codesourcery.com>
* configure.ac(AC_CHECK_FUNCS): Remove readlink.
* config.in, configure: Re-generate.
* hostio.c (handle_unlink): Remove code checking HAVE_READLINK
is defined.
This patch is to import readlink gnulib module. stat module is imported
too, but it isn't used by gdb.
gdb:
2014-11-28 Yao Qi <yao@codesourcery.com>
* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add readlink.
* gnulib/aclocal.m4: Re-generated.
* gnulib/config.in: Likewise.
* gnulib/configure: Likewise.
* gnulib/import/Makefile.am: Likewise.
* gnulib/import/Makefile.in: Likewise.
* gnulib/import/m4/gnulib-cache.m4: Likewise.
* gnulib/import/m4/gnulib-comp.m4: Likewise.
* gnulib/import/dosname.h: New file
* gnulib/import/m4/largefile.m4: New file.
* gnulib/import/m4/readlink.m4: New file.
* gnulib/import/m4/stat.m4: New file.
* gnulib/import/readlink.c: New file.
* gnulib/import/stat.c: New file.
2014-11-25 Sandra Loosemore <sandra@codesourcery.com>
gdb/
* nios2-tdep.c (nios2_analyze_prologue): Replace restriction
that there can be only one stack adjustment in the prologue
with tests to detect specific disallowed stack adjustments.
instruction matching.
2014-11-25 Sandra Loosemore <sandra@codesourcery.com>
gdb/
* nios2-tdep.c (nios2_fetch_insn): Move up in file. Disassemble
the instruction as well as reading it from memory.
(nios2_match_add): New.
(nios2_match_sub): New.
(nios2_match_addi): New.
(nios2_match_orhi): New.
(nios2_match_stw): New.
(nios2_match_ldw): New.
(nios2_match_rdctl): New.
(enum branch_condition): New.
(nios2_match_branch): New.
(nios2_match_jmpi): New.
(nios2_match_calli): New.
(nios2_match_jmpr): New.
(nios2_match_callr): New.
(nios2_match_break): New.
(nios2_match_trap): New.
(nios2_in_epilogue_p): Rewrite to use new functions.
(nios2_analyze_prologue): Likewise.
(nios2_skip_prologue): Delete unused local limit_pc.
(nios2_breakpoint_from_pc): Make R1-specific encodings explicit.
(nios2_get_next_pc): Rewrite to use new functions.
2014-11-24 Samuel Thibault <samuel.thibault@ens-lyon.org>
* gdb/gnu-nat.c (inf_validate_procinfo): Multiply the number of
elements pi_len by the size of the elements before calling
vm_deallocate.
(inf_validate_task_sc): Likewise, and properly deallocate the
noise array.
gdb/ChangeLog:
* gdbtypes.c (print_args): Renamed from print_arg_types. Print arg
number and name if present. All callers updated.
(dump_fn_fieldlists): Fix indentation of args.
A recent change...
commit 1a853c5224
Date: Wed Nov 12 10:10:49 2014 +0000
Subject: make "permanent breakpoints" per location and disableable
... broke function calls on sparc-elf when running over QEMU. Any
function call should demonstrate the problem.
For instance, seen from the debugger:
(gdb) call pn(1234)
[Inferior 1 (Remote target) exited normally]
The program being debugged exited while in a function called from GDB.
Evaluation of the expression containing the function
And seen from QEMU:
qemu: fatal: Trap 0x02 while interrupts disabled, Error state
[register dump removed]
What happens in this case is that GDB sets the inferior function call
by not only creating the dummy frame, but also writing a breakpoint
instruction at the return address for our function call. See infcall.c:
/* Write a legitimate instruction at the point where the infcall
breakpoint is going to be inserted. While this instruction
is never going to be executed, a user investigating the
memory from GDB would see this instruction instead of random
uninitialized bytes. We chose the breakpoint instruction
as it may look as the most logical one to the user and also
valgrind 3.7.0 needs it for proper vgdb inferior calls.
If software breakpoints are unsupported for this target we
leave the user visible memory content uninitialized. */
bp_addr_as_address = bp_addr;
bp_bytes = gdbarch_breakpoint_from_pc (gdbarch, &bp_addr_as_address,
&bp_size);
if (bp_bytes != NULL)
write_memory (bp_addr_as_address, bp_bytes, bp_size);
This instruction triggers a change introduced by the commit above,
where we consider bp locations as being permanent breakpoints
if there is already a breakpoint instruction at that address:
+ if (bp_loc_is_permanent (loc))
+ {
+ loc->inserted = 1;
+ loc->permanent = 1;
+ }
As a result, when resuming the program's execution for the inferior
function call, GDB decides that it does not need to insert a breakpoint
at this address, expecting the target to just report a SIGTRAP when
trying to execute that instruction.
But unfortunately for us, at least some versions of QEMU for SPARC
just terminate the execution entirely instead of reporting a breakpoint,
thus producing the behavior reported here.
Although it appears like QEMU might be misbehaving and should therefore
be fixed (to be verified) from the user's point of view, the recent
change does introduce a regression. So this patch tries to mitigate
a bit the damage by handling such infcall breakpoints as special and
making sure that they are never considered permanent, thus restoring
the previous behavior specifically for those breakpoints.
The option of not writing the breakpoint instructions in the first
place was considered, and would probably work also. But the comment
associated to it seems to indicate that there is still reason to
keep it.
gdb/ChangeLog:
* breakpoint.c (bp_loc_is_permanent): Return 0 if LOC corresponds
to a bp_call_dummy breakpoint type.
Tested on x86_64-linux. Also testing on sparc-elf/QEMU using
AdaCore's testsuite.
SA_RESTART allows system calls to be restarted across a signal handler.
By specifying this flag we fix the issue where if the user is being
prompted to answer yes or no, and the terminal gets resized in the
meantime, the prompt will think that the user sent an EOF and so it will
take the default action for that prompt (in the case of the quit prompt,
it will quit GDB).
gdb/ChangeLog:
* tui/tui-win.c (tui_initialize_win): Specify SA_RESTART when
registering the signal handler.
This patch fixes the annoying bug where key sequences such as Alt_F or
Alt_B (go forward or backwards by a word) do not behave promptly in TUI.
You have to press a third key in order for the key sequence to register.
This is mostly ncurses' fault. Calling wgetch() normally causes ncurses
to read only a single key from stdin. However if the key read is the
start-sequence key (^[ a.k.a. ESC) then wgetch() reads TWO keys from
stdin, storing the 2nd key into an internal FIFO buffer and returning
the start-sequence key. The extraneous read of the 2nd key makes us
miss its corresponding stdin event, so the event loop blocks until a
third key is pressed. This explains why such key sequences do not
behave promptly in TUI.
To fix this issue, we must somehow compensate for the missed stdin event
corresponding to the 2nd byte of a key sequence. This patch achieves
this by hacking up the stdin event handler to conditionally execute the
readline callback multiple times in a row. This is done via a new
global variable, call_stdin_event_handler_again_p, which is set from
tui_getc() when we receive a start-sequence key and notice extra pending
input in the ncurses buffer.
Tested on x86_64-unknown-linux-gnu.
gdb/ChangeLog:
* event-top.h (call_stdin_event_handler_again_p): Declare.
* event-top.c (call_stdin_event_handler_again_p): Define.
(stdin_event_handler): Use it.
* tui/tui-io.c (tui_getc): Prepare to call the stdin event
handler again if there is pending input following a
start sequence.
This way the user can know the index of the latest checkpoint without
having to run "info checkpoints" afterwards.
gdb/ChangeLog:
* linux-fork.c (checkpoint_command): Print index of new
checkpoint in response message.
In read_string, we have this line
chunksize = (len == -1 ? min (8, fetchlimit) : fetchlimit);
but chunksize is only used in the block that lne == -1, so IWBN to
move chunksize to the block in which it is used, and simplify the
condition setting chunksize. This patch also moves 'found_nul' to
inner block. This patch also splits a paragraph of comment into two,
and move them to different condition blocks (len > 0 and len == -1)
respectively.
gdb:
2014-11-23 Yao Qi <yao@codesourcery.com>
* valprint.c (read_string): Move local variables 'found_nul',
'chunksize' and 'limit' to inner scope. Update comments.