Pedro pointed out that a test in py-parameter.exp had an empty
message. This fixes it.
testsuite/ChangeLog
2018-05-02 Tom Tromey <tom@tromey.com>
* gdb.python/py-parameter.exp: Set test message.
PR python/20084 points out that the Python API doesn't handle the
var_zuinteger and var_zuinteger_unlimited parameter types.
This patch adds support for these types.
Regression tested on x86-64 Fedora 26.
ChangeLog
2018-05-02 Tom Tromey <tom@tromey.com>
PR python/20084:
* python/python.c (gdbpy_parameter_value): Handle var_zuinteger
and var_zuinteger_unlimited.
* python/py-param.c (struct parm_constant): Add PARAM_ZUINTEGER
and PARAM_ZUINTEGER_UNLIMITED.
(set_parameter_value): Handle var_zuinteger and
var_zuinteger_unlimited.
(add_setshow_generic): Likewise.
(parmpy_init): Likewise.
doc/ChangeLog
2018-05-02 Tom Tromey <tom@tromey.com>
PR python/20084:
* python.texi (Parameters In Python): Document PARAM_ZUINTEGER and
PARAM_ZUINTEGER_UNLIMITED.
testsuite/ChangeLog
2018-05-02 Tom Tromey <tom@tromey.com>
PR python/20084:
* gdb.python/py-parameter.exp: Add PARAM_ZUINTEGER and
PARAM_ZUINTEGER_UNLIMITED tests.
Fix a null dereference when casting a value to a unit type.
ChangeLog
2018-04-28 Dan Robertson <danlrobertson89@gmail.com>
PR rust/23124
* gdb/rust-exp.y (convert_params_to_types): Ensure that the params
pointer is not null before dereferencing it.
testsuite/ChangeLog
2018-04-28 Dan Robertson <danlrobertson89@gmail.com>
PR rust/23124
* gdb.rust/expr.exp: Test that the unit type is correctly parsed
when casting.
This adds an "alignof" attribute to gdb.Type in the Python API.
2018-04-30 Tom Tromey <tom@tromey.com>
* NEWS: Mention Type.align.
* python/py-type.c (typy_get_alignof): New function.
(type_object_getset): Add "alignof".
2018-04-30 Tom Tromey <tom@tromey.com>
* python.texi (Types In Python): Document Type.align.
2018-04-30 Tom Tromey <tom@tromey.com>
* gdb.python/py-type.exp: Check align attribute.
* gdb.python/py-type.c: New "aligncheck" global.
This adds alignof and _Alignof to the C/C++ expression parser, and
adds new tests to test the features. The tests are written to try to
ensure that gdb's knowledge of alignment rules stays in sync with the
compiler's.
2018-04-30 Tom Tromey <tom@tromey.com>
PR exp/17095:
* NEWS: Update.
* std-operator.def (UNOP_ALIGNOF): New operator.
* expprint.c (dump_subexp_body_standard) <case UNOP_ALIGNOF>:
New.
* eval.c (evaluate_subexp_standard) <case UNOP_ALIGNOF>: New.
* c-lang.c (c_op_print_tab): Add alignof.
* c-exp.y (ALIGNOF): New token.
(exp): Add "ALIGNOF" production.
(ident_tokens): Add _Alignof and alignof.
2018-04-30 Tom Tromey <tom@tromey.com>
PR exp/17095:
* gdb.dwarf2/dw2-align.exp: New file.
* gdb.cp/align.exp: New file.
* gdb.base/align.exp: New file.
* lib/gdb.exp (gdb_int128_helper): New proc.
(has_int128_c, has_int128_cxx): New caching procs.
This is version 2 of the patch to add inclusive range support for
Rust. I believe it addresses all review comments.
Rust recently stabilized the inclusive range feature:
https://github.com/rust-lang/rust/issues/28237
An inclusive range is an expression like "..= EXPR" or "EXPR ..=
EXPR". It is like an ordinary range, except the upper bound is
inclusive, not exclusive.
This patch adds support for this feature to gdb.
Regression tested on x86-64 Fedora 27.
2018-04-27 Tom Tromey <tom@tromey.com>
PR rust/22545:
* rust-lang.c (rust_inclusive_range_type_p): New function.
(rust_range): Handle inclusive ranges.
(rust_compute_range): Likewise.
* rust-exp.y (struct rust_op) <inclusive>: New field.
(DOTDOTEQ): New constant.
(range_expr): Add "..=" productions.
(operator_tokens): Add "..=" token.
(ast_range): Add "inclusive" parameter.
(convert_ast_to_expression) <case OP_RANGE>: Handle inclusive
ranges.
* parse.c (operator_length_standard) <case OP_RANGE>: Handle new
bounds values.
* expression.h (enum range_type) <NONE_BOUND_DEFAULT_EXCLUSIVE,
LOW_BOUND_DEFAULT_EXCLUSIVE>: New constants.
Update comments.
* expprint.c (print_subexp_standard): Handle new bounds values.
(dump_subexp_body_standard): Likewise.
2018-04-27 Tom Tromey <tom@tromey.com>
PR rust/22545:
* gdb.rust/simple.exp: Add inclusive range tests.
I noticed that if you set a breakpoint on an ifunc before the ifunc is
resolved, and then let the program call the ifunc, thus resolving it,
GDB end up with a location for that original breakpoint that is
pointing to the ifunc target, but it is left pointing to the first
address of the function, instead of after its prologue. After
prologue is what you get if you create a new breakpoint at that point.
1) With no debug info for the target function:
1.a) Set before resolving, and then program continued passed resolving:
Num Type Disp Enb Address What
1 breakpoint keep y 0x0000000000400753 <final>
1.b) Breakpoint set after inferior resolved ifunc:
Num Type Disp Enb Address What
2 breakpoint keep y 0x0000000000400757 <final+4>
2) With debug info for the target function:
1.a) Set before resolving, and then program continued passed resolving:
Num Type Disp Enb Address What
1 breakpoint keep y 0x0000000000400753 in final at gdb/testsuite/gdb.base/gnu-ifunc-final.c:20
1.b) Breakpoint set after inferior resolved ifunc:
Num Type Disp Enb Address What
2 breakpoint keep y 0x000000000040075a in final at gdb/testsuite/gdb.base/gnu-ifunc-final.c:21
The problem is that elf_gnu_ifunc_resolver_return_stop (called by the
internal breakpoint that traps the resolver returning) does not agree
with linespec.c:minsym_found. It does not skip to the function's
start line (i.e., past the prologue). We can now use the
find_function_start_sal overload added by the previous commmit to fix
this.
New tests included, which fail before the patch, and pass afterwards.
gdb/ChangeLog:
2018-04-26 Pedro Alves <palves@redhat.com>
* elfread.c (elf_gnu_ifunc_resolver_return_stop): Use
find_function_start_sal instead of find_pc_line.
gdb/testsuite/ChangeLog:
2018-04-26 Pedro Alves <palves@redhat.com>
* gdb.base/gnu-ifunc.exp (set-break): Test that GDB resolves
ifunc breakpoint locations correctly of ifunc breakpoints set
while the program resolves the ifunc.
This patch extends/rewrites the gdb.base/gnu-ifunc.exp testcase to
cover the many different fixes in earlier patches. (This was actually
what encovered most of the problems.)
The current testcase uses an ifunc symbol with the same name as the
ifunc resolver symbol and makes sure to compile the ifunc resolver
without debug info. That does not model how ifuncs are implemented in
gcc/ifunc nowadays. Instead, what we have is that the glibc ifunc
resolvers nowadays are written in C and end up with debug info.
Also, in some cases the ifunc target is written in assembly, but in
other cases it's written in C. In the case of target function written
in C, if the target function has debug info, when we set a break on
the ifunc, we want to set it past the prologue of the target function.
Currently GDB gets that wrong.
To make sure we cover all the different scenarios, the testcase is
tweaked to cover all the different combinations of
- An ifunc resolver with the same name as the user-visible symbol vs
an ifunc resolver with a different name as the user-visible symbol.
- ifunc resolver compiled with and without debug info.
- ifunc target function compiled with and without debug info.
The testcase currently sets breakpoints on ifuncs, calls ifunc
functions, steps into ifunc functions, etc. After this series, this
all works and the testcase passes cleanly.
While working on this, I noticed that "b gnu_ifunc" before and after
the inferior resolved the ifunc would end up with a breakpoint with
different locations. That's now covered by new tests inside the new
"set-break" procedure.
It also tests other things like making sure we can't call an ifunc
without a return-type case if we don't know the type of the target.
And making sure that we pass enough arguments when we do know the
type.
gdb/testsuite/ChangeLog:
2018-04-26 Pedro Alves <palves@redhat.com>
* gdb.base/gnu-ifunc-final.c: New file.
* gdb.base/gnu-ifunc.c (final): Delete, moved to gnu-ifunc-final.c.
* gdb.base/gnu-ifunc.exp (executable): Delete.
(staticexecutable): Adjust.
(lib_opts, exec_opts): Delete.
(make_binsuffix, build, set-break): New procedures.
(misc_tests): New, with tests factored out from the top level.
(top level): Test different combinations of ifunc resolver name,
resolver with and with debug info, and ifunc target with and
without debug info. Wrap static tests with with_target_prefix.
After the previous patch, on Fedora 27 (glibc 2.26), if you try
calling strlen in the inferior, you now get:
(top-gdb) p strlen ("hello")
'__strlen_avx2' has unknown return type; cast the call to its declared return type
This is correct, because __strlen_avx2 is written in assembly.
We can improve on this though -- if the final ifunc resolved/target
function has no debug info, but the ifunc _resolver_ does have debug
info, we can try extracting the final function's type from the type
that the resolver returns. E.g.,:
typedef size_t (*strlen_t) (const char*);
size_t my_strlen (const char *) { /* some implementation */ }
strlen_t strlen_resolver (unsigned long hwcap) { return my_strlen; }
extern size_t strlen (const char *s);
__typeof (strlen) strlen __attribute__ ((ifunc ("strlen_resolver")));
In the strlen example above, the resolver returns strlen_t, which is a
typedef for pointer to a function that returns size_t. "strlen_t" is
the type of both the user-visible "strlen", and of the the target
function that implements it.
This patch teaches GDB to extract that type.
This is done for actual inferior function calls (in infcall.c), and
for ptype (in eval_call). By the time we get to either of these
places, we've already lost the original symbol/minsym, and only have
values and types to work with. Hence the changes to c-exp.y and
evaluate_var_msym_value, to ensure that we propagate the ifunc
minsymbol's info.
The change to make ifunc symbols have no/unknown return type exposes a
latent problem -- gdb.compile/compile-ifunc.exp calls a no-debug-info
function, but we did not warn about it. The test is fixed by this
commit too.
gdb/ChangeLog:
2018-04-26 Pedro Alves <palves@redhat.com>
* blockframe.c (find_gnu_ifunc_target_type): New function.
(find_function_type): New.
* eval.c (evaluate_var_msym_value): For GNU ifunc types, always
return a value with a memory address.
(eval_call): For calls to GNU ifunc functions, try to find the
type of the target function from the type that the resolver
returns.
* gdbtypes.c (objfile_type): Don't install a return type for ifunc
symbols.
* infcall.c (find_function_return_type): Delete.
(find_function_addr): Add 'function_type' parameter. For calls to
GNU ifunc functions, try to find the type of the target function
from the type that the resolver returns, and return it via
FUNCTION_TYPE.
(call_function_by_hand_dummy): Adjust to use the function type
returned by find_function_addr.
(find_function_addr): Add 'function_type' parameter and move
description here.
* symtab.h (find_function_type, find_gnu_ifunc_target_type): New
declarations.
gdb/testsuite/ChangeLog:
2018-04-26 Pedro Alves <palves@redhat.com>
* gdb.compile/compile-ifunc.exp: Also expect "function has unknown
return type" warnings.
Since f67c0c9171 ("Enable 'set print inferior-events' and improve
detach/fork/kill/exit messages"), when detaching a remote process, we
get, for detach against a remote target:
(gdb) detach
Detaching from program: ...., process 5388
Ending remote debugging.
[Inferior 1 (Thread 5388.5388) detached]
^^^^^^^^^^^^^^^^
That is incorrect, for it is printing a thread id as string while we
should be printing the process id instead. I.e., either one of:
[Inferior 1 (process 5388) detached]
[Inferior 1 (Remote target) detached]
depending on remote stub support for the multi-process extensions.
Similarly, after killing a process, we're printing thread ids while we
should be printing process ids. E.g., on native GNU/Linux:
(gdb) k
Kill the program being debugged? (y or n) y
[Inferior 1 (Thread 0x7ffff7faa8c0 (LWP 30721)) has been killed]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
while it should have been:
Kill the program being debugged? (y or n) y
[Inferior 1 (process 30721) has been killed]
^^^^^^^^^^^^^
There's a wording inconsistency between detach and kill:
[Inferior 1 (process 30721) has been killed]
[Inferior 1 (process 30721) detached]
Given we were already saying "detached" instead of "has been
detached", and we used to say just "exited", and given that the "has
been" doesn't really add any information, this commit changes the
message to just "killed":
[Inferior 1 (process 30721) killed]
gdb/ChangeLog:
2018-04-25 Pedro Alves <palves@redhat.com>
* infcmd.c (kill_command): Print the pid as string, not the whole
thread's ptid. Add comment. s/has been killed/killed/ in output
message.
* remote.c (remote_detach_1): Print the pid as string, not the
whole thread's ptid.
gdb/testsuite/ChangeLog:
2018-04-25 Pedro Alves <palves@redhat.com>
* gdb.base/hook-stop.exp: Expect "killed" instead of "has been
killed".
* gdb.base/kill-after-signal.exp: Likewise.
* gdb.threads/kill.exp: Likewise.
This patch aims to turn 'set print inferior-events' always on, and do
some cleanup on the messages printed by GDB when various inferior
events happen (attach, detach, fork, kill, exit).
To make sure that the patch is correct, I've tested it with a handful
of combinations of 'set follow-fork-mode', 'set detach-on-fork' and
'set print inferior-events'. In the end, I decided to make my
hand-made test into an official testcase. More on that below.
Using the following program as an example:
#include <unistd.h>
int main ()
{
fork ();
return 0;
}
We see the following outputs from the patched GDB:
- With 'set print inferior-events on':
(gdb) r
Starting program: a.out
[Detaching after fork from child process 27749]
[Inferior 1 (process 27745) exited normally]
(gdb)
- With 'set print inferior-events off':
(gdb) r
Starting program: a.out
[Inferior 1 (process 27823) exited normally]
(gdb)
Comparing this against an unpatched GDB:
- With 'set print inferior-events off' and 'set follow-fork-mode
child':
(gdb) r
Starting program: a.out
[Inferior 2 (process 5993) exited normally]
(gdb)
Compare this against an unpatched GDB:
(unpatched-gdb) r
Starting program: a.out
[New process 5702]
[Inferior 2 (process 5702) exited normally]
(unpatched-gdb)
It is possible to notice that, in this scenario, the patched GDB
will lose the '[New process %d]' message.
- With 'set print inferior-events on', 'set follow-fork-mode child'
and 'set detach-on-fork on':
(gdb) r
Starting program: a.out
[Attaching after process 27905 fork to child process 27909]
[New inferior 2 (process 27909)]
[Detaching after fork from parent process 27905]
[Inferior 1 (process 27905) detached]
[Inferior 2 (process 27909) exited normally]
(gdb)
Compare this output with an unpatched GDB, using the same settings:
(unpatched-gdb) r
Starting program: a.out
[New inferior 28033]
[Inferior 28029 detached]
[New process 28033]
[Inferior 2 (process 28033) exited normally]
[Inferior 28033 exited]
(unpatched-gdb)
As can be seen above, I've also made a few modifications to messages
that are printed when 'set print inferior-events' is on. For example,
a few of the messages did not contain the '[' and ']' as
prefix/suffix, which led to a few inconsistencies like:
Attaching after process 22995 fork to child process 22999.
[New inferior 22999]
Detaching after fork from child process 22999.
[Inferior 22995 detached]
[Inferior 2 (process 22999) exited normally]
So I took the opportunity and included the square brackets where
applicable. I have also made the existing messages more uniform, by
always printing "Inferior %d (process %d)..." where applicable. This
makes it easier to identify the inferior number and the PID number
from the messages.
As suggested by Pedro, the "[Inferior %d exited]" message from
'exit_inferior' has been removed, because it got duplicated when
'inferior-events' is on. I'm also using the
'add_{thread,inferior}_silent' versions (instead of their verbose
counterparts) on some locations, also to avoid duplicated messages.
For example, a patched GDB with 'set print inferior-events on', 'set
detach-on-fork on' and 'set follow-fork-mode child', but using
'add_thread', would print:
(gdb) run
Starting program: a.out
[Attaching after process 25088 fork to child process 25092.]
[New inferior 25092] <--- duplicated
[Detaching after fork from child process 25092.]
[Inferior 25088 detached]
[New process 25092] <--- duplicated
[Inferior 2 (process 25092) exited normally]
But if we use 'add_thread_silent' (with the same configuration as
before):
(gdb) run
Starting program: a.out
[Attaching after process 31606 fork to child process 31610]
[New inferior 2 (process 31610)]
[Detaching after fork from parent process 31606]
[Inferior 1 (process 31606) detached]
[Inferior 2 (process 31610) exited normally]
As for the tests, the configuration options being exercised are:
- follow-fork-mode: child/parent
- detach-on-fork: on/off
- print inferior-events: on/off
It was also necessary to perform adjustments on several testcases,
because the expected messages changed considerably.
Built and regtested on BuildBot, without regressions.
gdb/ChangeLog:
2018-04-24 Jan Kratochvil <jan.kratochvil@redhat.com>
Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
* infcmd.c (kill_command): Print message when inferior has
been killed.
* inferior.c (print_inferior_events): Remove 'static'. Set as
'1'.
(add_inferior): Improve message printed when
'print_inferior_events' is on.
(exit_inferior): Remove message printed when
'print_inferior_events' is on.
(detach_inferior): Improve message printed when
'print_inferior_events' is on.
(initialize_inferiors): Use 'add_inferior_silent' to set
'current_inferior_'.
* inferior.h (print_inferior_events): Declare here as
'extern'.
* infrun.c (follow_fork_inferior): Print '[Attaching...]' or
'[Detaching...]' messages when 'print_inferior_events' is on.
Use 'add_thread_silent' instead of 'add_thread'. Add '[' and ']'
as prefix/suffix for messages. Remove periods. Fix erroneous
'Detaching after fork from child...', replace it by '... from
parent...'.
(handle_vfork_child_exec_or_exit): Add '[' and ']' as
prefix/suffix when printing 'Detaching...' messages. Print
them when 'print_inferior_events' is on.
* remote.c (remote_detach_1): Print message when detaching
from inferior and '!is_fork_parent'.
gdb/testsuite/ChangeLog:
2018-04-24 Jan Kratochvil <jan.kratochvil@redhat.com>
Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
* gdb.base/attach-non-pgrp-leader.exp: Adjust 'Detaching...'
regexps to expect for '[Inferior ... detached]' as well.
* gdb.base/attach.exp: Likewise.
* gdb.base/catch-syscall.exp (check_for_program_end): Adjust
"gdb_continue_to_end".
(test_catch_syscall_with_wrong_args): Likewise.
* gdb.base/foll-fork.exp: Adjust regexps to match '[' and
']'. Don't set 'verbose' on.
* gdb.base/foll-vfork.exp: Likewise.
* gdb.base/fork-print-inferior-events.c: New file.
* gdb.base/fork-print-inferior-events.exp: New file.
* gdb.base/hook-stop.exp: Adjust regexps to expect for new
'[Inferior ... has been killed]' message.
* gdb.base/kill-after-signal.exp: Likewise.
* gdb.base/solib-overlap.exp: Adjust regexps to expect for new
detach message.
* gdb.threads/kill.exp: Adjust regexps to expect for new kill
message.
* gdb.threads/clone-attach-detach.exp: Adjust 'Detaching...'
regexps to expect for '[Inferior ... detached]' as well.
* gdb.threads/process-dies-while-detaching.exp: Likewise.
As reported in PR 23104, -ldl doesn't work on FreeBSD. Replace it with
shlib_load, which adds the right flags for dynamic library loading based
on the current target platform.
The test still passes on Linux, and should now pass on FreeBSD, though I
did not test personally.
gdb/testsuite/ChangeLog:
PR gdb/23104
* gdb.base/info-shared.exp: Replace libs=-ldl with shlib_load.
Problems:
1. linking -dl lib on FreeBSD platform
2. backtrace from ld-elf shows r_debug_state() instead of _dl_debug_state()
Cause:
1. There is no dl library on FreeBSD platform test has to ignore linking "-ldl"
2. The stop due to a shared library event shows backtrace frame #0
function as r_debug_state()
gdb/ChangeLog:
PR gdb/23095
* gdb/testsuite/gdb.base/break-probes.exp: Pass shlib_load to
prepare_for_testing. Set normal_bp to r_debug_state if target
is bsd.
The hang occurs when GDB tries to call inferior functions on two
different threads with scheduler-locking turned on. The first call works
fine, with the call to infrun_async(1) causing the signal_handler to be
marked and the event to be handled, but then the event loop resets the
"ready" member to zero, while leaving infrun_is_async set to 1. As a
result, GDB hangs if the user switches to another thread and calls a
second function because calling infrun_async(1) a second time has no
effect, meaning the inferior call events are never handled.
The added test case provokes the above issue.
gdb/testsuite/ChangeLog:
* gdb.threads/multiple-successive-infcall.c: New test.
* gdb.threads/multiple-successive-infcall.exp: New file.
I noticed that quirk_rust_enum can crash when presented with a union
whose fields are all scalar types.
This patch adds a new test case and fixes the bug.
Regression tested on Fedora 26 x86-64.
2018-04-17 Tom Tromey <tom@tromey.com>
* dwarf2read.c (quirk_rust_enum): Handle unions correctly.
2018-04-17 Tom Tromey <tom@tromey.com>
* gdb.rust/simple.rs (Union): New type.
(main): New local "u".
* gdb.rust/simple.exp (test_one_slice): Add new test case.
After this commit:
b744723f57 -- Show line numbers in output for "info var/func/type"
the test cases dbx.exp and info-fun.exp yield new FAILs because two
regular expressions have not been adjusted to the changed output yet.
This is fixed.
gdb/testsuite/ChangeLog:
* gdb.base/dbx.exp (test_whereis): Adjust regexp to added line
number information in output of "whereis" command.
* gdb.base/info-fun.exp: Likewise, for "info fun" command.
The GDB commands "info variables", "info functions", and "info types" show
the appropriate list of definitions matching the given pattern. They also
group them by source files. But no line numbers within these source files
are shown.
The line number information is particularly useful to the user when a
simple "grep" doesn't readily point to a definition. This is often the
case when the definition involves a macro, occurs within a namespace, or
when the identifier appears very frequently in the source file.
This patch enriches the printout of these commands by the line numbers and
adjusts affected test cases to the changed output where necessary. The
new output looks like this:
(gdb) i variables
All defined variables:
File foo.c:
3: const char * const foo;
1: int x;
The line number is followed by a colon and a tab character, which is then
followed by the symbol definition. If no line number is available, the
tab is printed out anyhow, so definitions line up.
gdb/ChangeLog:
* symtab.c (print_symbol_info): Precede the symbol definition by
the line number when available.
* NEWS: Advertise this enhancement.
gdb/doc/ChangeLog:
* gdb.texinfo (Symbols): Mention the fact that "info
variables/functions/types" show source files and line numbers.
gdb/testsuite/ChangeLog:
* gdb.ada/info_types.exp: Adjust expected output to the line
numbers now printed by "info var/func/type".
* gdb.base/completion.exp: Likewise.
* gdb.base/included.exp: Likewise.
* gdb.cp/cp-relocate.exp: Likewise.
* gdb.cp/cplusfuncs.exp: Likewise.
* gdb.cp/namespace.exp: Likewise.
* gdb.dwarf2/dw2-case-insensitive.exp: Likewise.
Add new set/show commands to set the processor that is used for enabling
errata workarounds when decoding branch trace.
The general format is "<vendor>:<identifier>" but we also allow two
special values "auto" and "none".
The default is "auto", which is the current behaviour of having GDB
determine the processor on which the trace was recorded.
If that cpu is not known to the trace decoder, e.g. when using an old
decoder on a new system, decode may fail with "unknown cpu". In most
cases it should suffice to 'downgrade' decode to assume an older cpu.
Unfortunately, we can't do this automatically.
The other special value, "none", disables errata workarounds.
gdb/
* NEWS (New options): announce set/show record btrace cpu.
* btrace.c: Include record-btrace.h.
(btrace_compute_ftrace_pt): Skip enabling errata workarounds if
the vendor is unknown.
(btrace_compute_ftrace_1): Add cpu parameter. Update callers.
Maybe overwrite the btrace configuration's cpu.
(btrace_compute_ftrace): Add cpu parameter. Update callers.
(btrace_fetch): Add cpu parameter. Update callers.
(btrace_maint_update_pt_packets): Call record_btrace_get_cpu.
Maybe overwrite the btrace configuration's cpu. Skip enabling
errata workarounds if the vendor is unknown.
* python/py-record-btrace.c: Include record-btrace.h.
(recpy_bt_begin, recpy_bt_end, recpy_bt_instruction_history)
(recpy_bt_function_call_history): Call record_btrace_get_cpu.
* record-btrace.c (record_btrace_cpu_state_kind): New.
(record_btrace_cpu): New.
(set_record_btrace_cpu_cmdlist): New.
(record_btrace_get_cpu): New.
(require_btrace_thread, record_btrace_info)
(record_btrace_resume_thread): Call record_btrace_get_cpu.
(cmd_set_record_btrace_cpu_none): New.
(cmd_set_record_btrace_cpu_auto): New.
(cmd_set_record_btrace_cpu): New.
(cmd_show_record_btrace_cpu): New.
(_initialize_record_btrace): Initialize set/show record btrace cpu
commands.
* record-btrace.h (record_btrace_get_cpu): New.
testsuite/
* gdb.btrace/cpu.exp: New.
doc/
* gdb.texinfo: Document set/show record btrace cpu.
With version 7.3 GCC supports new options
-mindirect-branch=<choice>
-mfunction-return=<choice>
The choices are:
keep behaves as before
thunk jumps through a thunk
thunk-external jumps through an external thunk
thunk-inline jumps through an inlined thunk
For thunk and thunk-external, GDB would, on a call to the thunk, step into
the thunk and then resume to its caller assuming that this is an
undebuggable function. On a return thunk, GDB would stop inside the
thunk.
Make GDB step through such thunks instead.
Before:
Temporary breakpoint 1, main ()
at gdb.base/step-indirect-call-thunk.c:37
37 x = apply (inc, 41);
(gdb) s
apply (op=0x80483e6 <inc>, x=41)
at gdb.base/step-indirect-call-thunk.c:29
29 return op (x);
(gdb)
30 }
After:
Temporary breakpoint 1, main ()
at gdb.base/step-indirect-call-thunk.c:37
37 x = apply (inc, 41);
(gdb) s
apply (op=0x80483e6 <inc>, x=41)
at gdb.base/step-indirect-call-thunk.c:29
29 return op (x);
(gdb)
inc (x=41) at gdb.base/step-indirect-call-thunk.c:23
23 return x + 1;
This is independent of the step-mode. In order to step into the thunk,
you would need to use stepi.
When stepping over an indirect call thunk, GDB would first step through
the thunk, then recognize that it stepped into a sub-routine and resume to
the caller (of the thunk). Not sure whether this is worth optimizing.
Thunk detection is implemented via gdbarch. I implemented the methods for
IA. Other architectures may run into unexpected fails.
The tests assume a fixed number of instruction steps to reach a thunk.
This depends on the compiler as well as the architecture. They may need
adjustments when we add support for more architectures. Or we can simply
drop those tests that cover being able to step into thunks using
instruction stepping.
When using an older GCC, the tests will fail to build and will be reported
as untested:
Running .../gdb.base/step-indirect-call-thunk.exp ...
gdb compile failed, \
gcc: error: unrecognized command line option '-mindirect-branch=thunk'
gcc: error: unrecognized command line option '-mfunction-return=thunk'
=== gdb Summary ===
# of untested testcases 1
gdb/
* infrun.c (process_event_stop_test): Call
gdbarch_in_indirect_branch_thunk.
* gdbarch.sh (in_indirect_branch_thunk): New.
* gdbarch.c: Regenerated.
* gdbarch.h: Regenerated.
* x86-tdep.h: New.
* x86-tdep.c: New.
* Makefile.in (ALL_TARGET_OBS): Add x86-tdep.o.
(HFILES_NO_SRCDIR): Add x86-tdep.h.
(ALLDEPFILES): Add x86-tdep.c.
* arch-utils.h (default_in_indirect_branch_thunk): New.
* arch-utils.c (default_in_indirect_branch_thunk): New.
* i386-tdep: Include x86-tdep.h.
(i386_in_indirect_branch_thunk): New.
(i386_elf_init_abi): Set in_indirect_branch_thunk gdbarch
function.
* amd64-tdep: Include x86-tdep.h.
(amd64_in_indirect_branch_thunk): New.
(amd64_init_abi): Set in_indirect_branch_thunk gdbarch function.
testsuite/
* gdb.base/step-indirect-call-thunk.exp: New.
* gdb.base/step-indirect-call-thunk.c: New.
* gdb.reverse/step-indirect-call-thunk.exp: New.
* gdb.reverse/step-indirect-call-thunk.c: New.
Commit
b2e586e ("Defer breakpoint reset when cloning progspace for fork
child")
fixed following fork childs when the executable is position-independent.
This patch adds a little test for it.
gdb/testsuite/ChangeLog:
* gdb.base/pie-fork.c: New file.
* gdb.base/pie-fork.exp: New file.
Building with --coverage pointed out that there was no Rust test for
initializing a structure using the ".." initializer. This patch adds
such a test.
Regression tested on x86-64 Fedora 26.
2018-04-11 Tom Tromey <tom@tromey.com>
* gdb.rust/simple.exp: Add test for ".." struct initializer.
On my multi-target branch I was occasionaly seeing a FAIL like this:
(gdb) PASS: gdb.base/fork-running-state.exp: detach-on-fork=off: follow-fork=parent: non-stop: kill parent
[Inferior 2 (process 32672) exited normally]
kill inferior 2
warning: Inferior ID 2 is not running.
(gdb) FAIL: gdb.base/fork-running-state.exp: detach-on-fork=off: follow-fork=parent: non-stop: kill child (the program exited)
... other similar fails ...
Turns out to be a testcase bug/race. A tweak like this increases the
changes of hitting the race substancially:
--- a/gdb/testsuite/gdb.base/fork-running-state.c
+++ b/gdb/testsuite/gdb.base/fork-running-state.c
@@ -29,7 +29,7 @@ fork_child (void)
{
while (1)
{
- sleep (1);
+ usleep (100);
The testcase has two processes, parent and child fork. The problem is
that the child exits itself if it notices the parent is gone, but the
testcase .exp does not expect that.
I first wrote a patch that handled the different combinations of
non-stop/detach-on-fork/follow-fork/schedule-multiple, making the .exp
file know when to expect the child to exit itself vs when to kill it
explicitly, but the result was that the code to kill the parent and
child was getting about as large as the test code that is the actual
point of the testcase, above the kills.
So I scratched that approach and came up with a simpler patch --
simply make the child not exit itself when the parent exits.
The .exp file is going to kill both parent and child explicitly, and,
main() already calls alarm() as a safeguard. I don't think we lose
anything.
gdb/testsuite/ChangeLog:
2018-04-10 Pedro Alves <palves@redhat.com>
* gdb.base/fork-running-state.c (fork_child): Don't exit if parent
exits. Instead loop running forever.
(fork_parent): Run forever too.
I see some failures in the gdb.mi/mi-stack.exp test. The test runs to
the callee4 function:
int callee4 (void)
{
int A=1;
int B=2;
int C;
int D[3] = {0, 1, 2};
C = A + B;
return 0;
}
and expects to be stopped at the A=1 line. However, when gcc generates
some stack protection code, it will stop at the { instead, as shown by
this disassembly (after I did "break callee4" and "run"):
(gdb) disassemble /s
Dump of assembler code for function callee4:
/home/simark/src/binutils-gdb/gdb/testsuite/gdb.mi/mi-stack.c:
26 {
0x00005555555546ca <+0>: push %rbp
0x00005555555546cb <+1>: mov %rsp,%rbp
0x00005555555546ce <+4>: sub $0x20,%rsp
=> 0x00005555555546d2 <+8>: mov %fs:0x28,%rax
0x00005555555546db <+17>: mov %rax,-0x8(%rbp)
0x00005555555546df <+21>: xor %eax,%eax
27 int A=1; /* callee4 begin */
0x00005555555546e1 <+23>: movl $0x1,-0x20(%rbp)
28 int B=2;
0x00005555555546e8 <+30>: movl $0x2,-0x1c(%rbp)
The rest of the test relies on execution stopping on the A=1, so many things
fail after that. This patch uses mi_continue_to_line instead, to stop at the
A=1 line precisely.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-stack.exp (test_stack_frame_listing): Use
mi_continue_to_line.
* gdb.mi/mi-stack.c (callee4): Add comment.
When a 64-bits (x86-64) gdbarch is created, it is first born as a
32-bits gdbarch in i386_gdbarch_init. The call gdbarch_init_osabi will
call the handler register for the selected (arch, osabi) pair, such as
amd64_linux_init_abi. The various amd64 handlers call amd64_init_abi,
which turns the gdbarch into a 64-bits one.
When selecting the i386:x86-64 architecture with no osabi, no such
handler is ever called, so the gdbarch stays (wrongfully) a 32-bits one.
My first idea was to manually call amd64_init_abi & al in
i386_gdbarch_init when the osabi is GDB_OSABI_NONE. However, this
doesn't work in a build of GDB where i386 is included as a target but
not amd64. My next option (implemented in this patch), is to allow
registering handlers for GDB_OSABI_NONE. I added two such handlers in
amd64-tdep.c, so now it works the same as for the "normal" osabis. It
required re-ordering things in gdbarch_init_osabi to allow running
handlers for GDB_OSABI_NONE.
Without this patch applied (but with the previous one*) :
(gdb) set osabi none
(gdb) set architecture i386:x86-64
The target architecture is assumed to be i386:x86-64
(gdb) p sizeof(void*)
$1 = 4
and now:
(gdb) set osabi none
(gdb) set architecture i386:x86-64
The target architecture is assumed to be i386:x86-64
(gdb) p sizeof(void*)
$1 = 8
* Before the previous patch, which fixed "set osabi none", this bug was
hidden because we didn't actually try to generate a gdbarch for no
osabi, it would always fall back on Linux. Generating the gdbarch for
amd64/linux did work.
gdb/ChangeLog:
PR gdb/22979
* amd64-tdep.c (amd64_none_init_abi): New function.
(amd64_x32_none_init_abi): New function.
(_initialize_amd64_tdep): Register handlers for x86-64 and
x64_32 with GDB_OSABI_NONE.
* osabi.c (gdbarch_init_osabi): Allow running handlers for the
GDB_OSABI_NONE osabi.
gdb/testsuite/ChangeLog:
PR gdb/22979
* gdb.arch/amd64-osabi.exp: New file.
I was looking for a way to reproduce easily PR 22979 by doing this:
(gdb) set architecture i386:x86-64
(gdb) set osabi none
However, I noticed that even though I did "set osabi none", the gdbarch
gdb created was for Linux:
(gdb) set debug arch 1
(gdb) set architecture i386:x86-64
...
(gdb) set osabi none
gdbarch_find_by_info: info.bfd_arch_info i386:x86-64
gdbarch_find_by_info: info.byte_order 1 (little)
gdbarch_find_by_info: info.osabi 4 (GNU/Linux) <--- Wrong?
gdbarch_find_by_info: info.abfd 0x0
gdbarch_find_by_info: info.tdep_info 0x0
gdbarch_find_by_info: Previous architecture 0x1e6fd30 (i386:x86-64)
selected
gdbarch_update_p: Architecture 0x1e6fd30 (i386:x86-64) unchanged
This is because the value GDB_OSABI_UNKNOWN has an unclear role,
sometimes meaning "no osabi" and sometimes "please selected
automatically". Doing "set osabi none" sets the requested osabi to
GDB_OSABI_UNKNOWN, in which case gdbarch_info_fill overrides it with a
value from the target description, or the built-in default osabi. This
means that it's impossible to force GDB not to use an osabi with "set
osabi". Since my GDB's built-in default osabi is Linux, it always falls
back to GDB_OSABI_LINUX.
To fix it, I introduced GDB_OSABI_NONE, which really means "I don't want
any osabi". GDB_OSABI_UNKNOWN can then be used only for "not set yet,
please auto-detect". GDB_OSABI_UNINITIALIZED now seems unnecessary
since it overlaps with GDB_OSABI_UNKNOWN, so I think it can be removed
and gdbarch_info::osabi can be initialized to GDB_OSABI_UNKNOWN.
gdb/ChangeLog:
PR gdb/22980
* defs.h (enum gdb_osabi): Remove GDB_OSABI_UNINITIALIZED, add
GDB_OSABI_NONE.
* arch-utils.c (gdbarch_info_init): Don't set info->osabi.
* osabi.c (gdb_osabi_names): Add "unknown" entry.
gdb/testsuite/ChangeLog:
PR gdb/22980
* gdb.base/osabi.exp: New file.
The original problem was fixed (see related PR 22242). But using a typedef
as the declared type for a static member variable, as commented in this PR,
is still causing gdb to get into infinite loop when printing the static
member's value. This problem can be reproduced as follows:
% cat t.cc
class A {
typedef A type;
public:
bool operator==(const type& other) { return true; }
static const type INSTANCE;
};
const A A::INSTANCE;
int main() {
A a;
if (a == A::INSTANCE) {
return -1;
}
return 0;
}
% g++ -g t.cc
% gdb -ex "start" -ex "p a" a.out
The fix is rather trivial - in cp_print_static_field(), should call
check_typedef() to get the static member's real type and use it to
check whether it's a struct or an array.
As Simon suggested, I've added a new test case to the testsuite
and am passing the original type, not the real type, as argument
to both cp_print_value_fields() and val_print().
Re-tested on both aarch64-linux-gnu and amd64-linux-gnu. No regressions.
This is a command we somehow forgot to contribute at the time the Ada
language was first contributed to the FSF. This command allows
the user to change the maximum size we allow when reading memory
from dynamic objects (the default is 65536 bytes).
At the moment, this limit is only used by Ada, and so the implementation
is kept inside ada-lang.c. However, it is conceivable that other language
might want to use it also to handle the same kind of issues; for instance,
this might be useful when handling dynamic types in C. So the name
of the setting was made language-neutral, to allow for this.
Note that an alias for "set var" needs to be introduced as well.
We are not adding a test for that, since this is a feature that is
already exercized by numerous existing tests.
gdb/ChangeLog
* NEWS: Add entry describing new "set|show varsize-limit" command.
* ada-lang.c (_initialize_ada_language): Add "set/show varsize-limit"
command.
* printcmd.c (_initialize_printcmd): Add "set var" alias of
"set variable".
gdb/doc/ChangeLog:
* gdb.texinfo (Ada Settings): New subsubsection.
gdb/testsuite/ChangeLog:
* gdb.ada/varsize_limit: New testcase.
Tested on x86_64-linux.
This patch fixes a known failure in gdb.ada/maint_with_ada.exp
(maintenance check-psymtabs). Another way to witness the same
issue is by considering the following Ada declarations...
type Wrapper is record
A : Integer;
end record;
u00045 : constant Wrapper := (A => 16#060287af#);
pragma Export (C, u00045, "symada__cS");
... which declares a variable name "u00045" but with a linkage
name which is "symada__cS". This variable is a record with one
component, the Ada equivalent of a struct with one field in C.
Trying to print that variable's value currently yields:
(gdb) p /x <symada__cS>
'symada(char, signed)' has unknown type; cast it to its declared type
This indicates that GDB was only able to find the minimal symbol,
but not the full symbol. The expected output is:
(gdb) print /x <symada__cS>
$1 = (a => 0x60287af)
The error message gives a hint about what's happening: We processed
the symbol through gdb_demangle, which in the case of this particular
symbol name, ends up matching the C++ naming scheme. As a result,
the demangler transforms our symbol name into 'symada(char, signed)',
thus breaking Ada lookups.
This patch fixes the issue by first introducing a new language_defn
attribute called la_store_sym_names_in_linkage_form_p, which is a boolean
to be set to true for the few languages that do not want their symbols
to have their names stored in demangled form, and false otherwise.
We then use this language attribute to skip the call to gdb_demangle
for all languages whose la_store_sym_names_in_linkage_form_p is true.
In terms of the selection of languages for which the new attribute
is set to true, the selection errs on the side of preserving the
existing behavior, and only changes the behavior for the languages
where we are certain storing symbol names in demangling form is not
needed. It is conceivable that other languages might be in the same
situation, but I not knowing in detail the symbol name enconding
strategy, I decided to play it safe and let other language maintainers
potentially adjust their language if it makes sense to do so.
gdb/ChangeLog:
PR gdb/22670
* dwarf2read.c (dwarf2_physname): Do not return the demangled
symbol name if the CU's language stores symbol names in linkage
format.
* language.h (struct language_defn)
<la_store_sym_names_in_linkage_form_p>: New field. Adjust
all instances of this struct.
gdb/testsuite/ChangeLog:
* gdb.ada/maint_with_ada.exp: Remove PR gdb/22670 setup_kfail.
* gdb.ada/notcplusplus: New testcase.
* gdb.base/c-linkage-name.c: New file.
* gdb.base/c-linkage-name.exp: New testcase.
Tested on x86_64-linux.
This also passes AdaCore's internal GDB testsuite.
If a C-c comes while the Python code for a frame filter is running, it
will be turned into a Python KeyboardException. It seems good for
this to be treated like a GDB quit, so this patch changes
py-framefilter.c to notice this situation and call throw_quit in this
case.
gdb/ChangeLog
2018-03-26 Tom Tromey <tom@tromey.com>
* python/py-framefilter.c (throw_quit_or_print_exception): New
function.
(gdbpy_apply_frame_filter): Use it.
gdb/testsuite/ChangeLog
2018-03-26 Tom Tromey <tom@tromey.com>
* gdb.python/py-framefilter.exp: Add test for KeyboardInterrupt.
* gdb.python/py-framefilter.py (name_error): New global.
(ErrorInName.function): Use name_error.
When a frame filter elides some frames, they are still printed by
"bt", indented a few spaces. PR backtrace/15582 notes that it would
be nice for users if elided frames could simply be dropped. This
patch adds this capability.
gdb/ChangeLog
2018-03-26 Tom Tromey <tom@tromey.com>
PR backtrace/15582:
* stack.c (backtrace_command): Parse "hide" argument.
* python/py-framefilter.c (py_print_frame): Handle PRINT_HIDE.
* extension.h (enum frame_filter_flags) <PRINT_HIDE>: New
constant.
gdb/doc/ChangeLog
2018-03-26 Tom Tromey <tom@tromey.com>
PR backtrace/15582:
* gdb.texinfo (Backtrace): Mention "hide" argument.
gdb/testsuite/ChangeLog
2018-03-26 Tom Tromey <tom@tromey.com>
PR backtrace/15582:
* gdb.python/py-framefilter.exp: Add "bt hide" test.
c++/22968 involves the inability of ptype to find a type definition for
a type defined inside another type. I recently added some additional
support for nested type definitions, but I apparently overlooked psymbols.
The user reports that using -readnow fixes the problem:
$ gdb 22968 -ex "ptype Outer::Inner"
There is no field named Inner
$ gdb -readnow 22968 -ex "ptype Outer::Inner"
type = struct Outer::Inner {
<no data field>
}
We clearly did not find a psymbol for Outer::Inner because it was located
in another CU. This patch addresses this problem by scanning structs
for additional psymbols. Rust is already doing this.
With this patch, the identical result to "-readnow" is given (without
using `-readnow', of course).
gdb/ChangeLog:
PR c++/22968
* dwarf2read.c (scan_partial_symbols): Scan structs/classes for
nested type definitions for C++, too.
gdb/testsuite/ChangeLog:
PR c++/22968
* gdb.cp/subtypes.exp: New file.
* gdb.cp/subtypes.h: New file.
* gdb.cp/subtypes.cc: New file.
* gdb.cp/subtypes-2.cc: New file.
This test starts up and confirms that $xmm0 has the value 0, it then
modifies $xmm0 (in the inferior) and confirms that the new value can
be read (in GDB).
On some machines I was noticing that this test would occasionally
fail, and on investigation I believe that the reason for this is that
the test is linked as a dynamically linked executable and makes use of
the system libraries during startup. The reason that this causes
problems is that both the runtime linker and the startup code run
before main can, and do (on at least some platforms) make use of the
XMM registers.
In this commit I modify the test program slightly to allow it to be
linked statically, without using the startup libraries. Now by the
time GDB reaches the symbol main we have only executed one 'nop'
instruction, and the XMM registers should all have the value 0. I've
extended the test script to confirm that $xmm0 to $xmm15 are all
initially 0, and I also check that at the point after $xmm0 has been
modified, all the other XMM registers ($xmm1 to $xmm15) are still 0.
The test program is still linked against libc in order that we can
call the exit function, however, we now call _exit rather than exit in
order to avoid all of the usual cleanup that exit does. This clean up
tries to tear down things that are usually setup during the startup
code, but now this isn't called calling exit will just result in a
crash.
gdb/testsuite/ChangeLog:
* gdb.arch/amd64-disp-step-avx.S: Add '_start' label.
(done): Call '_exit' not 'exit' to avoid atexit handlers.
* gdb.arch/amd64-disp-step-avx.exp: Pass -static, and
-nostartfiles when compiling the test. Confirm that all registers
xmm0 to xmm15 are initially 0, and that xmm1 to xmm15 are 0 after.
A small number of tests incorrectly tried to pass -Wa,-g through to
GCC as an extra compile time flag, either to gdb_compile or
prepare_for_testing.
The problem is that the syntax used for passing the flags was
incorrect, and as a result these extra flags were being ignored.
Luckily, the 'debug' flag was being passed in each case anyway, which
means that the '-g' flag would already be added.
Given that all these tests pass 'debug', and the invalid flag has been
ignored for some time, I'm just removing the flags in this commit.
I've also changed the tests from using gdb_compile to
prepare_for_testing, which allows some extra code to be removed from a
couple of tests scripts.
There should be no change in the test results after this commit.
gdb/testsuite/ChangeLog:
* gdb.arch/amd64-disp-step-avx.exp: Remove unneeded assembler flag
option, syntax was wrong anyway.
* gdb.arch/arm-disp-step.exp: Likewise.
* gdb.arch/sparc64-regs.exp: Likewise.
* gdb.arch/amd64-disp-step.exp: Remove unneeded assembler flag
option, syntax was wrong anyway, switch to use
prepare_for_testing.
* gdb.arch/i386-disp-step.exp: Likewise.
Currently "info proc cmdline" on GNU/Linux does not show the full command
line, but only argument 0. And even a warning is shown if there are more.
This was discussed in 2014 already:
https://sourceware.org/ml/gdb-patches/2014-04/msg00212.html
Follow the advice there and avoid target_fileio_read_stralloc. Instead,
use target_fileio_read_alloc to read the whole command line and then
replace NUL characters by spaces. Also add an appropriate test case.
Note that gdbserver already handles this correctly.
gdb/ChangeLog:
* linux-tdep.c (linux_info_proc): For "info proc cmdline", print
command line args instead of emitting a warning.
gdb/testsuite/ChangeLog:
* gdb.base/info-proc.exp: Add test for "info proc cmdline".
This patch addresses slowness when setting breakpoints, especially in
heavily templatized code. Profiling showed that find_pc_sect_line in
symtab.c was the performance bottleneck. The original logic performed a
linear search over ordered data. This patch uses a binary search, as
suggested by comments around the function. There are no behavioural
changes, but gdb is now faster at setting breakpoints in template code.
Tested using on make check on an x86 target. The optimisation speeds up
the included template-breakpoints.py performance test by a factor of 7
on my machine.
ChangeLog:
2018-03-20 Stephen Roberts <stephen.roberts@arm.com>
* gdb/symtab.c (find_pc_sect_line): now uses binary search.
gdb/testsuite/
* gdb.perf/template-breakpoints.cc: New file.
* gdb.perf/template-breakpoints.exp: New file.
* gdb.perf/template-breakpoints.py: New file.
In Rust one can initialize a struct member from an identically-named
local variable by simply mentioning the member name in the
initializer, like:
let x = 0;
let y = Struct { x };
This initializes "Struct::x" from "x".
This patch adds this form of initializer to the Rust expression parser
and adds a test.
Tested on x86-64 Fedora 26 using rustc 1.23.
2018-03-19 Tom Tromey <tom@tromey.com>
* rust-exp.y (struct_expr_tail, struct_expr_list): Add plain
"IDENT" production.
2018-03-19 Tom Tromey <tom@tromey.com>
* gdb.rust/simple.rs (main): Add local variables field1, field2,
y0.
* gdb.rust/simple.exp: Test bare identifier form of struct
initializer.
This converts observers from using a special source-generating script
to be plain C++. This version of the patch takes advantage of C++11
by using std::function and variadic templates; incorporates Pedro's
patches; and renames the header file to "observable.h" (this change
eliminates the need for a clean rebuild).
Note that Pedro's patches used a template lambda in tui-hooks.c, but
this failed to compile on some buildbot instances (presumably due to
differing C++ versions); I replaced this with an ordinary template
function.
Regression tested on the buildbot.
gdb/ChangeLog
2018-03-19 Pedro Alves <palves@redhat.com>
Tom Tromey <tom@tromey.com>
* unittests/observable-selftests.c: New file.
* common/observable.h: New file.
* observable.h: New file.
* ada-lang.c, ada-tasks.c, agent.c, aix-thread.c, annotate.c,
arm-tdep.c, auto-load.c, auxv.c, break-catch-syscall.c,
breakpoint.c, bsd-uthread.c, cli/cli-interp.c, cli/cli-setshow.c,
corefile.c, dummy-frame.c, event-loop.c, event-top.c, exec.c,
extension.c, frame.c, gdbarch.c, guile/scm-breakpoint.c,
infcall.c, infcmd.c, inferior.c, inflow.c, infrun.c, jit.c,
linux-tdep.c, linux-thread-db.c, m68klinux-tdep.c,
mi/mi-cmd-break.c, mi/mi-interp.c, mi/mi-main.c, objfiles.c,
ppc-linux-nat.c, ppc-linux-tdep.c, printcmd.c, procfs.c,
python/py-breakpoint.c, python/py-finishbreakpoint.c,
python/py-inferior.c, python/py-unwind.c, ravenscar-thread.c,
record-btrace.c, record-full.c, record.c, regcache.c, remote.c,
riscv-tdep.c, sol-thread.c, solib-aix.c, solib-spu.c, solib.c,
spu-multiarch.c, spu-tdep.c, stack.c, symfile-mem.c, symfile.c,
symtab.c, thread.c, top.c, tracepoint.c, tui/tui-hooks.c,
tui/tui-interp.c, valops.c: Update all users.
* tui/tui-hooks.c (tui_bp_created_observer)
(tui_bp_deleted_observer, tui_bp_modified_observer)
(tui_inferior_exit_observer, tui_before_prompt_observer)
(tui_normal_stop_observer, tui_register_changed_observer):
Remove.
(tui_observers_token): New global.
(attach_or_detach, tui_attach_detach_observers): New functions.
(tui_install_hooks, tui_remove_hooks): Use
tui_attach_detach_observers.
* record-btrace.c (record_btrace_thread_observer): Remove.
(record_btrace_thread_observer_token): New global.
* observer.sh: Remove.
* observer.c: Rename to observable.c.
* observable.c (namespace gdb_observers): Define new objects.
(observer_debug): Move into gdb_observers namespace.
(struct observer, struct observer_list, xalloc_observer_list_node)
(xfree_observer_list_node, generic_observer_attach)
(generic_observer_detach, generic_observer_notify): Remove.
(_initialize_observer): Update.
Don't include observer.inc.
* Makefile.in (generated_files): Remove observer.h, observer.inc.
(clean mostlyclean): Likewise.
(observer.h, observer.inc): Remove targets.
(SUBDIR_UNITTESTS_SRCS): Add observable-selftests.c.
(COMMON_SFILES): Use observable.c, not observer.c.
* .gitignore: Remove observer.h.
gdb/doc/ChangeLog
2018-03-19 Tom Tromey <tom@tromey.com>
* observer.texi: Remove.
gdb/testsuite/ChangeLog
2018-03-19 Tom Tromey <tom@tromey.com>
* gdb.gdb/observer.exp: Remove.
Some of GDB's trace test cases define a function end() and place a
breakpoint there with "break end". However, when libinproctrace is linked
to the binary, there are multiple methods named "end", such as
std::string::end() from the C++ library or format_pieces::end() from
common/format.h. GDB then creates multiple breakpoints instead of just a
single one, and some FAILs result, such as these:
FAIL: gdb.trace/trace-mt.exp: ftrace on: break end
FAIL: gdb.trace/trace-mt.exp: ftrace off: break end
Fix this by adding the "-qualified" option to the break commands. For
consistency, change all occurrences of "break end" (and similar) in all
trace test cases, even if the current behavior does not cause problems.
Also, consequently use the gdb_breakpoint convenience proc.
gdb/testsuite/ChangeLog:
* gdb.trace/actions-changed.exp: Call gdb_breakpoint with the
"qualified" option when setting breakpoints.
* gdb.trace/backtrace.exp: Likewise.
* gdb.trace/circ.exp: Likewise.
* gdb.trace/collection.exp: Likewise.
* gdb.trace/disconnected-tracing.exp: Likewise.
* gdb.trace/ftrace-lock.exp: Likewise.
* gdb.trace/ftrace.exp: Likewise.
* gdb.trace/infotrace.exp: Likewise.
* gdb.trace/packetlen.exp: Likewise.
* gdb.trace/passc-dyn.exp: Likewise.
* gdb.trace/qtro.exp: Likewise.
* gdb.trace/read-memory.exp: Likewise.
* gdb.trace/report.exp: Likewise.
* gdb.trace/signal.exp: Likewise.
* gdb.trace/status-stop.exp: Likewise.
* gdb.trace/strace.exp: Likewise.
* gdb.trace/tfind.exp: Likewise.
* gdb.trace/trace-break.exp: Likewise.
* gdb.trace/trace-condition.exp: Likewise.
* gdb.trace/trace-mt.exp: Likewise.
* gdb.trace/tstatus.exp: Likewise.
* gdb.trace/tsv.exp: Likewise.
* gdb.trace/unavailable-dwarf-piece.exp: Likewise.
* gdb.trace/unavailable.exp: Likewise.
* gdb.trace/while-dyn.exp: Likewise.
The tspeed test case does not execute correctly because libinproctrace.so
is not copied to the target. This is fixed.
gdb/testsuite/ChangeLog:
* gdb.trace/tspeed.exp: Add invocation of gdb_load_shlib to ensure
that libinproctrace is copied to the target.
This changes the printf command's %s and %ls formats to special-case
NULL, and print "(null)" for these. This is PR cli/14977. This
behavior seems a bit friendlier; I was undecided on whether other
invalid pointers should be handled specially somehow, so for the time
being I've left those out.
gdb/ChangeLog
2018-03-14 Tom Tromey <tom@tromey.com>
PR cli/14977:
* printcmd.c (printf_c_string, printf_wide_c_string): Special case
for NULL.
gdb/gdbserver/ChangeLog
2018-03-14 Tom Tromey <tom@tromey.com>
PR cli/14977:
* ax.c (ax_printf): Special case for NULL.
gdb/testsuite/ChangeLog
2018-03-14 Tom Tromey <tom@tromey.com>
PR cli/14977:
* gdb.base/printcmds.exp (test_printf): Add printf test of %s with
a null pointer.
* gdb.base/wchar.exp: Likewise.
PR cli/19918 points out that a printf format like "%-5p" will cause a
gdb crash. The bug is problem is that printf_pointer doesn't take the
"-" flag into account.
gdb/ChangeLog
2018-03-14 Tom Tromey <tom@tromey.com>
PR cli/19918:
* printcmd.c (printf_pointer): Allow "-" in format.
gdb/testsuite/ChangeLog
2018-03-14 Tom Tromey <tom@tromey.com>
PR cli/19918:
* gdb.base/printcmds.exp (test_printf): Add printf test using '-'
flag.
As described here
https://sourceware.org/bugzilla/show_bug.cgi?id=22841
there seems to be situations where the remote-stdio-gdbserver board
fails to delete the uploaded binary file. Passing "target" fixes the
issue for Christian who reported the bug.
I did not experience this problem, but passing "target" to remote_exec
still works for me, so I'm fine with changing it.
Any objection?
gdb/testsuite/ChangeLog:
PR gdb/22841
* boards/remote-stdio-gdbserver.exp (${board}_file): Pass
"target" to remote_exec.
Before patch
Make native gdbserver boards no longer be "remote" (in DejaGnu terms)
739b3f1d8f
the local gdbserver boards (except native-extended-gdbserver...) were
considered as remote by DejaGNU. To avoid DejaGNU trying to use ssh/scp
to download the files to the target (which is actually local), the
gdbserver-base.exp file defined some _download, _upload and _file board
operations to override the default behavior, and instead just use local
operations.
The same patch also changed remote-stdio-gdbserver.exp to make it
inherit from gdbserver-base.exp. Since then, this board (which is
actually remote) uses the overrides with local file operations. As a
result, files are never actually copied to the target.
I think we can simply remove the overrides from gdbserver-base.exp.
Because all boards should be properly considered local or remote by
DejaGNU, it should by default use the right method for transferring
files.
gdb/testsuite/ChangeLog:
PR gdb/22841
* boards/gdbserver-base.exp (${board}_file, ${board}_download,
${board}_upload): Remove.
Some of the watchpoint logic depends on the fact that the head of the
value chain represents the user-specified value to watch. Thus no
additional values should be added to the value chain after that. However,
if a watchpoint is defined for a C++ structure/class object, then run-time
type information (RTTI) may be present. Thus, while constructing the
value chain for the watchpoint, the dynamic type is fetched by
gnuv3_rrti_type, which invokes value_addr, which then adds a new value to
the head of the value chain. This new value represents the pointer to the
structure instead of the structure itself.
With such a "polluted" value chain the watchpoint logic does not recognize
when the user intended to watch a struct, and can_use_hardware_watchpoint
returns zero. Instead of a hardware watchpoint, a software watchpoint
will then be set for no apparent reason.
This is fixed by adding an early exit to gnuv3_rtti_type when the input
value is not a dynamic class object.
gdb/testsuite/ChangeLog:
* gdb.cp/watch-cp.cc: New test.
* gdb.cp/watch-cp.exp: New file.
gdb/ChangeLog:
* gnu-v3-abi.c (gnuv3_rtti_type): Add early exit if the given
value is not a dynamic class object.
This commit introduces basic support for baremetal RiscV as a GDB
target. This target is currently only tested against the RiscV software
simulator, which is not included as part of this commit. The target has
been tested against the following RiscV variants: rv32im, rv32imc,
rv32imf, rv32imfc, rv64im, rv64imc, rv64imfd, rv64imfdc.
Across these variants we pass on average 34858 tests, and fail 272
tests, which is ~0.8%.
The RiscV has a feature of its ABI where structures with a single
floating point field, a single complex float field, or one float and
one integer field are treated differently for argument passing. The
new test gdb.base/infcall-nested-structs.exp is added to cover this
feature. As passing these structures should work on all targets then
I've made the test as a generic one, even though, for most targets,
there's probably nothing special about any of these cases.
gdb/ChangeLog:
* Makefile.in (ALL_TARGET_OBS): Add riscv-tdep.o
(HFILES_NO_SRCDIR): Add riscv-tdep.h.
(ALLDEPFILES): Add riscv-tdep.c
* configure.tgt: Add riscv support.
* riscv-tdep.c: New file.
* riscv-tdep.h: New file.
* NEWS: Mention new target.
* MAINTAINERS: Add entry for riscv.
gdb/testsuite/ChangeLog:
* gdb.base/infcall-nested-structs.exp: New file.
* gdb.base/infcall-nested-structs.c: New file.
* gdb.base/float.exp: Add riscv support.
While using @progbits in .pushsection work on some targets, it does not
work on arm target where this introduces a comment. This patch replaces
its use in gdb.dlang/watch-loc.c and gdb.mi/dw2-ref-missing-frame-func.c
by %progbits which should work on all targets since it is used in
target-independent elf/section7.s GAS test.
2018-03-02 Thomas Preud'homme <thomas.preudhomme@arm.com>
gdb/testsuite/
* gdb.dlang/watch-loc.c: Use %progbits instead of @progbits.
* gdb.mi/dw2-ref-missing-frame-func.c: Likewise.
Simon mentioned on IRC that, after the startup-with-shell feature has
been implemented on gdbserver, it is not possible to specify a
filename-only binary, like:
$ gdbserver :1234 a.out
/bin/bash: line 0: exec: a.out: not found
During startup program exited with code 127.
Exiting
This happens on systems where the current directory "." is not listed
in the PATH environment variable. Although including "." in the PATH
variable is a possible workaround, this can be considered a regression
because before startup-with-shell it was possible to use only the
filename (due to reason that gdbserver used "exec*" directly).
The idea of the patch is to verify if the program path provided by the
user (or by the remote protocol) contains a directory separator
character. If it doesn't, it means we're dealing with a filename-only
binary, so we call "gdb_abspath" to properly expand it and transform
it into a full path. Otherwise, we leave the program path untouched.
This mimicks the behaviour seen on GDB (look at "openp" and
"attach_inferior", for example).
I am also submitting a testcase which exercises the scenario described
above. This test requires gdbserver to be executed in a different CWD
than the original, so I also created a helper function, "with_cwd" (on
testsuite/lib/gdb.exp), which takes care of cd'ing into and out of the
specified dir.
Built and regtested on BuildBot, without regressions.
gdb/ChangeLog:
2018-02-28 Sergio Durigan Junior <sergiodj@redhat.com>
Simon Marchi <simon.marchi@polymtl.ca>
* common/common-utils.c: Include "sys/stat.h".
(is_regular_file): Move here from "source.c"; change return
type to "bool".
* common/common-utils.h (is_regular_file): New prototype.
* common/pathstuff.c (contains_dir_separator): New function.
* common/pathstuff.h (contains_dir_separator): New prototype.
* source.c: Don't include "sys/stat.h".
(is_regular_file): Move to "common/common-utils.c".
gdb/gdbserver/ChangeLog:
2018-02-28 Sergio Durigan Junior <sergiodj@redhat.com>
* server.c: Include "filenames.h" and "pathstuff.h".
(program_name): Delete variable.
(program_path): New anonymous class.
(get_exec_wrapper): Use "program_path" instead of
"program_name".
(handle_v_run): Likewise.
(captured_main): Likewise.
(process_serial_event): Likewise.
gdb/testsuite/ChangeLog:
2018-02-28 Sergio Durigan Junior <sergiodj@redhat.com>
* gdb.server/abspath.exp: New file.
* lib/gdb.exp (with_cwd): New procedure.