Age | Commit message (Collapse) | Author | Files | Lines |
|
In commit:
commit f069ea46a03ae868581d1c852da28e979ea1245a
Date: Sat Jul 3 16:29:08 2021 -0700
Rename gdb/ChangeLog to gdb/ChangeLog-2021
The gdb/ChangeLog file was renamed, but all of the other ChangeLog
files relating to gdb were left in place.
As I understand things, the no ChangeLogs policy applies to all the
GDB related directories, so this commit renames all of the remaining
GDB related ChangeLog files.
As with the original commit, the intention behind this commit is to
hopefully stop people merging ChangeLog entries by mistake.
The renames carried out in this commit are:
gdb/doc/ChangeLog -> gdb/doc/ChangeLog-1991-2021
gdb/stubs/ChangeLog -> gdb/stubs/ChangeLog-2012-2020
gdb/testsuite/ChangeLog -> gdb/testsuite/ChangeLog-2014-2021
gdbserver/ChangeLog -> gdbserver/ChangeLog-2002-2021
gdbsupport/ChangeLog -> gdbsupport/ChangeLog-2020-2021
|
|
At the moment some check-read1 timeouts are handled like this in
gdb.base/info-macros.exp:
...
gdb_test_multiple_with_read1_timeout_factor 10 "$test" $testname {
-re "$r1$r2$r3" {
pass $testname
}
-re ".*#define TWO.*\r\n$gdb_prompt" {
fail $testname
}
-re ".*#define THREE.*\r\n$gdb_prompt" {
fail $testname
}
-re ".*#define FOUR.*\r\n$gdb_prompt" {
fail $testname
}
}
...
which is not ideal.
We could use gdb_test_lines, but it currently doesn't support verifying
the absence of regexps, which is done using the clauses above calling fail.
Fix this by using gdb_test_lines and adding a -re-not syntax to
gdb_test_lines, such that we can do:
...
gdb_test_lines $test $testname $r1.*$r2 \
-re-not "#define TWO" \
-re-not "#define THREE" \
-re-not "#define FOUR"
...
Tested on x86_64-linux, whith make targets check and check-read1.
Also observed that check-read1 execution time is reduced from 6m35s to 13s.
gdb/testsuite/ChangeLog:
2021-07-06 Tom de Vries <tdevries@suse.de>
* gdb.base/info-macros.exp: Replace use of
gdb_test_multiple_with_read1_timeout_factor with gdb_test_lines.
(gdb_test_multiple_with_read1_timeout_factor): Remove.
* lib/gdb.exp (gdb_test_lines): Add handling or -re-not <regexp>.
|
|
Since commit 05b85772061 "gdb/fortran: Add type info of formal parameter for
clang" I see:
...
(gdb) ptype say_string^M
type = void (character*(*), integer(kind=4))^M
(gdb) FAIL: gdb.fortran/ptype-on-functions.exp: ptype say_string
...
The part of the commit causing the fail is:
...
gdb_test "ptype say_string" \
- "type = void \\(character\\*\\(\\*\\), integer\\(kind=\\d+\\)\\)"
+ "type = void \\(character\[^,\]+, $integer8\\)"
...
which fails to take into account that for gcc-7 and before, the type for
string length of a string argument is int, not size_t.
Fix this by allowing both $integer8 and $integer4.
Tested on x86_64-linux, with gcc-7 and gcc-10.
gdb/testsuite/ChangeLog:
2021-07-05 Tom de Vries <tdevries@suse.de>
* gdb.fortran/ptype-on-functions.exp: Allow both $integer8 and
$integer4 for size of string length.
|
|
Now that the GDB 11 branch has been created, we can
bump the version number.
gdb/ChangeLog:
GDB 11 branch created (4b51505e33441c6165e7789fa2b6d21930242927):
* version.in: Bump version to 12.0.50.DATE-git.
gdb/testsuite/ChangeLog:
* gdb.base/default.exp: Change $_gdb_major to 12.
|
|
Currently, on GNU/Linux, if you try to access memory and you have a
running thread selected, GDB fails the memory accesses, like:
(gdb) c&
Continuing.
(gdb) p global_var
Cannot access memory at address 0x555555558010
Or:
(gdb) b main
Breakpoint 2 at 0x55555555524d: file access-mem-running.c, line 59.
Warning:
Cannot insert breakpoint 2.
Cannot access memory at address 0x55555555524d
This patch removes this limitation. It teaches the native Linux
target to read/write memory even if the target is running. And it
does this without temporarily stopping threads. We now get:
(gdb) c&
Continuing.
(gdb) p global_var
$1 = 123
(gdb) b main
Breakpoint 2 at 0x555555555259: file access-mem-running.c, line 62.
(The scenarios above work correctly with current GDBserver, because
GDBserver temporarily stops all threads in the process whenever GDB
wants to access memory (see prepare_to_access_memory /
done_accessing_memory). Freezing the whole process makes sense when
we need to be sure that we have a consistent view of memory and don't
race with the inferior changing it at the same time as GDB is
accessing it. But I think that's a too-heavy hammer for the default
behavior. I think that ideally, whether to stop all threads or not
should be policy decided by gdb core, probably best implemented by
exposing something like gdbserver's prepare_to_access_memory /
done_accessing_memory to gdb core.)
Currently, if we're accessing (reading/writing) just a few bytes, then
the Linux native backend does not try accessing memory via
/proc/<pid>/mem and goes straight to ptrace
PTRACE_PEEKTEXT/PTRACE_POKETEXT. However, ptrace always fails when
the ptracee is running. So the first step is to prefer
/proc/<pid>/mem even for small accesses. Without further changes
however, that may cause a performance regression, due to constantly
opening and closing /proc/<pid>/mem for each memory access. So the
next step is to keep the /proc/<pid>/mem file open across memory
accesses. If we have this, then it doesn't make sense anymore to even
have the ptrace fallback, so the patch disables it.
I've made it such that GDB only ever has one /proc/<pid>/mem file open
at any time. As long as a memory access hits the same inferior
process as the previous access, then we reuse the previously open
file. If however, we access memory of a different process, then we
close the previous file and open a new one for the new process.
If we wanted, we could keep one /proc/<pid>/mem file open per
inferior, and never close them (unless the inferior exits or execs).
However, having seen bfd patches recently about hitting too many open
file descriptors, I kept the logic to have only one file open tops.
Also, we need to handle memory accesses for processes for which we
don't have an inferior object, for when we need to detach a
fork-child, and we'd probaly want to handle caching the open file for
that scenario (no inferior for process) too, which would probably end
up meaning caching for last non-inferior process, which is very much
what I'm proposing anyhow. So always having one file open likely ends
up a smaller patch.
The next step is handling the case of GDB reading/writing memory
through a thread that is running and exits. The access should not
result in a user-visible failure if the inferior/process is still
alive.
Once we manage to open a /proc/<lwpid>/mem file, then that file is
usable for memory accesses even if the corresponding lwp exits and is
reaped. I double checked that trying to open the same
/proc/<lwpid>/mem path again fails because the lwp is really gone so
there's no /proc/<lwpid>/ entry on the filesystem anymore, but the
previously open file remains usable. It's only when the whole process
execs that we need to reopen a new file.
When the kernel destroys the whole address space, i.e., when the
process exits or execs, the reads/writes fail with 0 aka EOF, in which
case there's nothing else to do than returning a memory access
failure. Note this means that when we get an exec event, we need to
reopen the file, to access the process's new address space.
If we need to open (or reopen) the /proc/<pid>/mem file, and the LWP
we're opening it for exits before we open it and before we reap the
LWP (i.e., the LWP is zombie), the open fails with EACCES. The patch
handles this by just looking for another thread until it finds one
that we can open a /proc/<pid>/mem successfully for.
If we need to open (or reopen) the /proc/<pid>/mem file, and the LWP
we're opening has exited and we already reaped it, which is the case
if the selected thread is in THREAD_EXIT state, the open fails with
ENOENT. The patch handles this the same way as a zombie race
(EACCES), instead of checking upfront whether we're accessing a
known-exited thread, because that would result in more complicated
code, because we also need to handle accessing lwps that are not
listed in the core thread list, and it's the core thread list that
records the THREAD_EXIT state.
The patch includes two testcases:
#1 - gdb.base/access-mem-running.exp
This is the conceptually simplest - it is single-threaded, and has
GDB read and write memory while the program is running. It also
tests setting a breakpoint while the program is running, and checks
that the breakpoint is hit immediately.
#2 - gdb.threads/access-mem-running-thread-exit.exp
This one is more elaborate, as it continuously spawns short-lived
threads in order to exercise accessing memory just while threads are
exiting. It also spawns two different processes and alternates
accessing memory between the two processes to exercise the reopening
the /proc file frequently. This also ends up exercising GDB reading
from an exited thread frequently. I confirmed by putting abort()
calls in the EACCES/ENOENT paths added by the patch that we do hit
all of them frequently with the testcase. It also exits the
process's main thread (i.e., the main thread becomes zombie), to
make sure accessing memory in such a corner-case scenario works now
and in the future.
The tests fail on GNU/Linux native before the code changes, and pass
after. They pass against current GDBserver, again because GDBserver
supports memory access even if all threads are running, by
transparently pausing the whole process.
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <pedro@palves.net>
PR mi/15729
PR gdb/13463
* linux-nat.c (linux_nat_target::detach): Close the
/proc/<pid>/mem file if it was open for this process.
(linux_handle_extended_wait) <PTRACE_EVENT_EXEC>: Close the
/proc/<pid>/mem file if it was open for this process.
(linux_nat_target::mourn_inferior): Close the /proc/<pid>/mem file
if it was open for this process.
(linux_nat_target::xfer_partial): Adjust. Do not fall back to
inf_ptrace_target::xfer_partial for memory accesses.
(last_proc_mem_file): New.
(maybe_close_proc_mem_file): New.
(linux_proc_xfer_memory_partial_pid): New, with bits factored out
from linux_proc_xfer_partial.
(linux_proc_xfer_partial): Delete.
(linux_proc_xfer_memory_partial): New.
gdb/testsuite/ChangeLog
yyyy-mm-dd Pedro Alves <pedro@palves.net>
PR mi/15729
PR gdb/13463
* gdb.base/access-mem-running.c: New.
* gdb.base/access-mem-running.exp: New.
* gdb.threads/access-mem-running-thread-exit.c: New.
* gdb.threads/access-mem-running-thread-exit.exp: New.
Change-Id: Ib3c082528872662a3fc0ca9b31c34d4876c874c9
|
|
Introduce frame_debug_printf, to convert the "frame" debug messages to
the new system. Replace fprint_frame with a frame_info::to_string
method that returns a string, like what was done with
frame_id::to_string. This makes it easier to use with
frame_debug_printf.
gdb/ChangeLog:
* frame.h (frame_debug_printf): New.
* frame.c: Use frame_debug_printf throughout when printing frame
debug messages.
* amd64-windows-tdep.c: Likewise.
* value.c: Likewise.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/dw2-reg-undefined.exp: Update regexp.
Change-Id: I3c230b0814ea81c23af3e1aca1aac8d4ba91d726
|
|
Currently the 'info sources' command lists all of the known source
files together, regardless of their source, e.g. here is a session
debugging a test application that makes use of a shared library:
(gdb) info sources
Source files for which symbols have been read in:
/tmp/info-sources/test.c, /usr/include/stdc-predef.h,
/tmp/info-sources/header.h, /tmp/info-sources/helper.c
Source files for which symbols will be read in on demand:
(gdb)
In this commit I change the format of the 'info sources' results so
that the results are grouped by the object file that uses that source
file. Here's the same session with the new output format:
(gdb) info sources
/tmp/info-sources/test.x:
/tmp/info-sources/test.c, /usr/include/stdc-predef.h,
/tmp/info-sources/header.h
/lib64/ld-linux-x86-64.so.2:
(Objfile has no debug information.)
system-supplied DSO at 0x7ffff7fcf000:
(Objfile has no debug information.)
/tmp/info-sources/libhelper.so:
/tmp/info-sources/helper.c, /usr/include/stdc-predef.h,
/tmp/info-sources/header.h
/lib64/libc.so.6:
(Objfile has no debug information.)
(gdb)
Notice that in the new output some source files are repeated,
e.g. /tmp/info-sources/header.h, as multiple objfiles use this source
file.
Further, some object files are tagged with the message '(Objfile has
no debug information.)', it is also possible to see the message '(Full
debug information has not yet been read for this file.)', which is
printed when some symtabs within an objfile have not yet been
expanded.
All of the existing regular expression based filtering still works.
An original version of this patch added the new format as an option to
'info sources', however, it was felt that the new layout was so much
better than the old style that GDB should just switch to the new
result format completely.
gdb/ChangeLog:
* NEWS: Mention changes to 'info sources'.
* symtab.c (info_sources_filter::print): Delete.
(struct output_source_filename_data) <print_header>: Delete
declaration. <printed_filename_p>: New member function.
(output_source_filename_data::print_header): Delete.
(info_sources_worker): Update group-by-objfile style output to
make it CLI suitable, simplify non-group-by-objfile now this is
only used from the MI.
(info_sources_command): Make group-by-objfile be the default for
CLI info sources command.
* symtab.h (struct info_sources_filter) <print>: Delete.
gdb/doc/ChangeLog:
* gdb.texinfo (Symbols): Document new output format for 'info
sources'.
gdb/testsuite/ChangeLog:
* gdb.base/info_sources_2-header.h: New file.
* gdb.base/info_sources_2-lib.c: New file.
* gdb.base/info_sources_2-test.c: New file.
* gdb.base/info_sources_2.exp: New file.
|
|
This commit adds a new option '--group-by-objfile' to the MI command
-file-list-exec-source-files. With this option the output format is
changed; instead of a single list of source files the results are now
a list of objfiles. For each objfile all of the source files
associated with that objfile are listed.
Here is an example of the new output format taken from the
documentation (the newlines are added just for readability):
-file-list-exec-source-files --group-by-objfile
^done,files=[{filename="/tmp/info-sources/test.x",
debug-info="fully-read",
sources=[{file="test.c",
fullname="/tmp/info-sources/test.c",
debug-fully-read="true"},
{file="/usr/include/stdc-predef.h",
fullname="/usr/include/stdc-predef.h",
debug-fully-read="true"},
{file="header.h",
fullname="/tmp/info-sources/header.h",
debug-fully-read="true"}]},
{filename="/lib64/ld-linux-x86-64.so.2",
debug-info="none",
sources=[]},
{filename="system-supplied DSO at 0x7ffff7fcf000",
debug-info="none",
sources=[]},
{filename="/tmp/info-sources/libhelper.so",
debug-info="fully-read",
sources=[{file="helper.c",
fullname="/tmp/info-sources/helper.c",
debug-fully-read="true"},
{file="/usr/include/stdc-predef.h",
fullname="/usr/include/stdc-predef.h",
debug-fully-read="true"},
{file="header.h",
fullname="/tmp/info-sources/header.h",
debug-fully-read="true"}]},
{filename="/lib64/libc.so.6",
debug-info="none",
sources=[]}]
In the above output the 'debug-info' field associated with each
objfile will have one of the values 'none', 'partially-read', or
'fully-read'. For example, /lib64/libc.so.6 has the value 'none',
this indicates that this object file has no debug information
associated with it, unsurprisingly then, the sources list of this
object file is empty.
An object file that was compiled with debug, for example
/tmp/info-sources/libhelper.so, has the value 'fully-read' above
indicating that this object file does have debug information, and the
information is fully read into GDB. At different times this field
might have the value 'partially-read' indicating that that the object
file has debug information, but it has not been fully read into GDB
yet.
Source files can appear at most once for any single objfile, but can
appear multiple times in total, if the same source file is part of
multiple objfiles, for example /tmp/info-sources/header.h in the above
output.
The new output format is hidden behind a command option to ensure that
the default output is unchanged, this ensures backward compatibility.
The behaviour of the CLI "info sources" command is unchanged after
this commit.
gdb/ChangeLog:
* NEWS: Mention additions to -file-list-exec-source-files.
* mi/mi-cmd-file.c (mi_cmd_file_list_exec_source_files): Add
--group-by-objfile option.
* symtab.c (isrc_flag_option_def): Rename to...
(isrc_match_flag_option_def): ...this.
(info_sources_option_defs): Rename to...
(info_sources_match_option_defs): ...this, and update to rename of
isrc_flag_option_def.
(struct filename_grouping_opts): New struct.
(isrc_grouping_flag_option_def): New type.
(info_sources_grouping_option_defs): New static global.
(make_info_sources_options_def_group): Update to return two option
groups.
(info_sources_command_completer): Update for changes to
make_info_sources_options_def_group.
(info_sources_worker): Add extra parameter, use this to display
alternative output format.
(info_sources_command): Pass extra parameter to
info_sources_worker.
(_initialize_symtab): Update for changes to
make_info_sources_options_def_group.
* symtab.h (info_sources_worker): Add extra parameter.
gdb/doc/ChangeLog:
* gdb.texinfo (GDB/MI File Commands): Document --group-by-objfile
extension for -file-list-exec-source-files.
gdb/testsuite/ChangeLog:
* gdb.mi/mi-info-sources.exp: Add additional tests.
|
|
This commit extends the existing MI command
-file-list-exec-source-files to provide the same regular expression
based filtering that the equivalent CLI command "info sources"
provides.
The new command syntax is:
-file-list-exec-source-files [--basename | --dirname] [--] [REGEXP]
All options are optional, which ensures the command is backward
compatible.
As part of this work I have unified the CLI and MI code.
As a result of the unified code I now provide additional information
in the MI command output, there is now a new field 'debug-fully-read'
included with each source file. This field which has the values
'true' or 'false', indicates if the source file is from a compilation
unit that has had its debug information fully read. However, as this
is additional information, a well written front-end should just ignore
this field if it doesn't understand it, so things should still be
backward compatible.
gdb/ChangeLog:
* NEWS: Mention additions to -file-list-exec-source-files.
* mi/mi-cmd-file.c (print_partial_file_name): Delete.
(mi_cmd_file_list_exec_source_files): Rewrite to handle command
options, and make use of info_sources_worker.
* symtab.c (struct info_sources_filter): Moved to symtab.h.
(info_sources_filter::print): Take uiout argument, produce output
through uiout.
(struct output_source_filename_data)
<output_source_filename_data>: Take uiout argument, store into
m_uiout. <output>: Rewrite comment, add additional arguments to
declaration. <operator()>: Send more arguments to
output. <m_uiout>: New member variable.
(output_source_filename_data::output): Take extra arguments,
produce output through m_uiout, and structure for MI.
(output_source_filename_data::print_header): Produce output
through m_uiout.
(info_sources_worker): New function, the implementation is taken
from info_sources_command, but modified so produce output through
a ui_out.
(info_sources_command): The second half of this function has gone
to become info_sources_worker.
* symtab.h (struct info_sources_filter): Moved from symtab.c, add
extra parameter to print member function.
(info_sources_worker): Declare.
gdb/doc/ChangeLog:
* gdb.texinfo (GDB/MI File Commands): Document extensions to
-file-list-exec-source-files.
gdb/testsuite/ChangeLog:
* gdb.dwarf2/dw2-filename.exp: Update expected results.
* gdb.mi/mi-file.exp: Likewise.
* gdb.mi/mi-info-sources-base.c: New file.
* gdb.mi/mi-info-sources.c: New file.
* gdb.mi/mi-info-sources.exp: New file.
|
|
In this commit:
commit 7022349d5c86bae74b49225515f42d2e221bd368
Date: Mon Sep 4 20:21:13 2017 +0100
Stop assuming no-debug-info functions return int
A new if case was added to call_function_by_hand_dummy to decide if a
function should be considered prototyped or not. Previously the code
was structured like this:
if (COND_1)
ACTION_1
else if (COND_2)
ACTION_2
else
ACTION_3
With the new block the code now looks like this:
if (COND_1)
ACTION_1
if (NEW_COND)
NEW_ACTION
else if (COND_2)
ACTION_2
else
ACTION_3
Notice the new block was added as and 'if' not 'else if'. I'm running
into a case where GDB executes ACTION_1 and then ACTION_2. Prior to
the above commit GDB would only have executed ACTION_1.
The actions in the code in question are trying to figure out if a
function should be considered prototyped or not. When a function is
not prototyped some arguments will be coerced, e.g. floats to doubles.
The COND_1 / ACTION_1 are a very broad, any member function should be
considered prototyped, however, after the above patch GDB is now
executing the later ACTION_2 which checks to see if the function's
type has the 'prototyped' flag set - this is not the case for the
member functions I'm testing, and so GDB treats the function as
unprototyped and casts the float argument to a double.
I believe that adding the new check as 'if' rather than 'else if' was
a mistake, and so in this commit I add in the missing 'else'.
gdb/ChangeLog:
* infcall.c (call_function_by_hand_dummy): Add missing 'else' when
setting prototyped flag.
gdb/testsuite/ChangeLog:
* gdb.cp/method-call-in-c.cc (struct foo_type): Add static member
function static_method.
(global_var): New global.
(main): Use new static_method to ensure it is compiled in.
* gdb.cp/method-call-in-c.exp: Test calls to static member
function.
|
|
After the previous commit, this commit updates the value_struct_elt
function to take an array_view rather than a NULL terminated array of
values.
The requirement for a NULL terminated array of values actually stems
from typecmp, so the change from an array to array_view needs to be
propagated through to this function.
While making this change I noticed that this fixes another bug, in
value_x_binop and value_x_unop GDB creates an array of values which
doesn't have a NULL at the end. An array_view of this array is passed
to value_user_defined_op, which then unpacks the array_view and passed
the raw array to value_struct_elt, but only if the language is not
C++.
As value_x_binop and value_x_unop can only request member functions
with the names of C++ operators, then most of the time, assuming the
inferior is not a C++ program, then GDB will not find a matching
member function with the call to value_struct_elt, and so typecmp will
never be called, and so, GDB will avoid undefined behaviour.
However, it is worth remembering that, when GDB's language is set to
"auto", the current language is selected based on the language of the
current compilation unit. As C++ programs usually link against libc,
which is written in C, then, if the inferior is stopped in libc GDB
will set the language to C. And so, it is possible that we will end
up using value_struct_elt to try and lookup, and match, a C++
operator. If this occurs then GDB will experience undefined
behaviour.
I have extended the test added in the previous commit to also cover
this case.
Finally, this commit changes the API from passing around a pointer to
an array to passing around a pointer to an array_view. The reason for
this is that we need to be able to distinguish between the cases where
we call value_struct_elt with no arguments, i.e. we are looking up a
struct member, but we either don't have the arguments we want to pass
yet, or we don't expect there to be any need for GDB to use the
argument types to resolve any overloading; and the second case where
we call value_struct_elt looking for a function that takes no
arguments, that is, the argument list is empty.
NOTE: While writing this I realise that if we pass an array_view at
all then it will always have at least one item in it, the `this'
pointer for the object we are planning to call the method on. So we
could, I guess, pass an empty array_view to indicate the case where we
don't know anything about the arguments, and when the array_view is
length 1 or more, it means we do have the arguments. However, though
we could do this, I don't think this would be better, the length 0 vs
length 1 difference seems a little too subtle, I think that there's a
better solution...
I think a better solution would be to wrap the array_view in a
gdb::optional, this would make the whole, do we have an array view or
not question explicit.
I haven't done this as part of this commit as making that change is
much more extensive, every user of value_struct_elt will need to be
updated, and as this commit already contains a bug fix, I wanted to
keep the large refactoring in a separate commit, so, check out the
next commit for the use of gdb::optional.
gdb/ChangeLog:
PR gdb/27994
* eval.c (structop_base_operation::evaluate_funcall): Pass
array_view instead of array to value_struct_elt.
* valarith.c (value_user_defined_op): Likewise.
* valops.c (typecmp): Change parameter type from array pointer to
array_view. Update header comment, and update body accordingly.
(search_struct_method): Likewise.
(value_struct_elt): Likewise.
* value.h (value_struct_elt): Update declaration.
gdb/testsuite/ChangeLog:
PR gdb/27994
* gdb.cp/method-call-in-c.cc (struct foo_type): Add operator+=,
change initial value of var member variable.
(main): Make use of foo_type's operator+=.
* gdb.cp/method-call-in-c.exp: Test use of operator+=.
|
|
This regression, as it is exposed by the test added in this commit,
first became noticable with this commit:
commit d182f2797922a305fbd1ef6a483cc39a56b43e02
Date: Mon Mar 8 07:27:57 2021 -0700
Convert c-exp.y to use operations
But, this commit only added converted the C expression parser to make
use of code that was added in this commit:
commit a00b7254fb614af557de7ae7cc0eb39a0ce0e408
Date: Mon Mar 8 07:27:57 2021 -0700
Implement function call operations
And it was this second commit that actually introduced the bugs (there
are two).
In structop_base_operation::evaluate_funcall we build up an argument
list in the vector vals. Later in this function the argument list
might be passed to value_struct_elt.
Prior to commit a00b7254fb614 the vals vector (or argvec as it used to
be called) stored the value for the function callee in the argvec at
index 0. This 'callee' value is what ends up being passed to
evaluate_subexp_do_call, and represents the function to be called, the
value contents are the address of the function, and the value type is
the function signature. The remaining items held in the argvec were
the values to pass to the function. For a non-static member function
the `this' pointer would be at index 1 in the array.
After commit a00b7254fb614 this callee value is now held in a separate
variable, not the vals array. So, for non-static member functions,
the `this' pointer is now at index 0, with any other arguments after
that.
What this means is that previous, when we called value_struct_elt we
would pass the address of argvec[1] as this was the first argument.
But now we should be passing the address of vals[0]. Unfortunately,
we are still passing vals[1], effectively skipping the first
argument.
The second issue is that, prior to commit a00b7254fb614, the argvec
array was NULL terminated. This is required as value_struct_elt
calls search_struct_method, which calls typecmp, and typecmp requires
that the array have a NULL at the end.
After commit a00b7254fb614 this NULL has been lost, and we are
therefore violating the API requirements of typecmp.
This commit fixes both of these regressions. I also extended the
header comments on search_struct_method and value_struct_elt to make
it clearer that the array required a NULL marker at the end.
You will notice in the test attached to this commit that I test
calling a non-static member function, but not calling a static member
function. The reason for this is that calling static member functions
is currently broken due to a different bug. That will be fixed in a
later patch in this series, at which time I'll add a test for calling
a static member function.
gdb/ChangeLog:
PR gdb/27994
* eval.c (structop_base_operation::evaluate_funcall): Add a
nullptr to the end of the args array, which should not be included
in the argument array_view. Pass all the arguments through to
value_struct_elt.
* valops.c (search_struct_method): Update header comment.
(value_struct_elt): Likewise.
gdb/testsuite/ChangeLog:
PR gdb/27994
* gdb.cp/method-call-in-c.cc: New file.
* gdb.cp/method-call-in-c.exp: New file.
|
|
When GCC emits .debug_aranges, it adds padding to align the contents
to two times the address size. GCC has done this for many years --
but there is nothing in the DWARF standard that says this should be
done, and LLVM does not seem to add this padding.
It's simple to detect if the padding exists, though: if the contents
of one .debug_aranges CU (excluding the header) are not a multiple of
the alignment that GCC uses, then anything extra must be padding.
This patch changes gdb to correctly read both styles. It removes the
requirement that the padding bytes be zero, as this seemed
unnecessarily pedantic to me.
gdb/ChangeLog
2021-06-25 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (create_addrmap_from_aranges): Change padding
logic.
gdb/testsuite/ChangeLog
2021-06-25 Tom Tromey <tom@tromey.com>
* lib/gdb.exp (add_gdb_index, ensure_gdb_index): Add "style"
parameter.
* gdb.rust/dwindex.exp: New file.
* gdb.rust/dwindex.rs: New file.
|
|
This commit adds initial support for catchpoints to the python
breakpoint API.
This commit adds a BP_CATCHPOINT constant which corresponds to
GDB's internal bp_catchpoint. The new constant is documented in the
manual.
The user can't create breakpoints with type BP_CATCHPOINT after this
commit, but breakpoints that already exist, obtained with the
`gdb.breakpoints` function, can now have this type. Additionally,
when a stop event is reported for hitting a catchpoint, GDB will now
report a BreakpointEvent with the attached breakpoint being of type
BP_CATCHPOINT - previously GDB would report a generic StopEvent in
this situation.
gdb/ChangeLog:
* NEWS: Mention Python BP_CATCHPOINT feature.
* python/py-breakpoint.c (pybp_codes): Add bp_catchpoint support.
(bppy_init): Likewise.
(gdbpy_breakpoint_created): Likewise.
gdb/doc/ChangeLog:
* python.texinfo (Breakpoints In Python): Add BP_CATCHPOINT
description.
gdb/testsuite/ChangeLog:
* gdb.python/py-breakpoint.c (do_throw): New function.
(main): Call do_throw.
* gdb.python/py-breakpoint.exp (test_catchpoints): New proc.
|
|
This commit adds initial support for catchpoints to the guile
breakpoint API.
This commit adds a BP_CATCHPOINT constant which corresponds to
GDB's internal bp_catchpoint. The new constant is documented in the
manual.
The user can't create breakpoints with type BP_CATCHPOINT after this
commit, but breakpoints that already exist, obtained with
the (breakpoints) function, can now have this type.
gdb/ChangeLog:
* guile/scm-breakpoint.c (bpscm_type_to_string): Handle
bp_catchpoint.
(bpscm_want_scm_wrapper_p): Likewise.
(gdbscm_make_breakpoint): Likewise.
(breakpoint_integer_constants): Likewise.
gdb/doc/ChangeLog:
* guile.texinfo (Breakpoints In Guile): Add BP_CATCHPOINT
description.
gdb/testsuite/ChangeLog:
* gdb.guile/scm-breakpoint.exp (test_catchpoints): New proc.
|
|
When creating a breakpoint using the guile API, if an invalid
breakpoint type number was used then the error would report the wrong
argument position, like this:
(gdb) guile (define wp2 (make-breakpoint "result" #:wp-class WP_WRITE #:type 999))
ERROR: In procedure make-breakpoint:
ERROR: In procedure gdbscm_make_breakpoint: Out of range: invalid breakpoint type in position 3: 999
Error while executing Scheme code.
(gdb)
The 'position 3' here is actually pointing at WP_WRITE, when it should
say 'position 5' and point to the 999. This commit fixes this.
However, you also get errors like this:
(gdb) guile (define wp2 (make-breakpoint "result" #:wp-class WP_WRITE #:type BP_NONE))
ERROR: In procedure make-breakpoint:
ERROR: In procedure gdbscm_make_breakpoint: Out of range: invalid breakpoint type in position 3: 0
Error while executing Scheme code.
The BP_NONE is a valid breakpoint type, it's just not valid for
creating breakpoints through the 'make-breakpoint' API. The use of
'0' in the error message (which is the value of BP_NONE) is not
great. This commit changes the error in this case to:
(gdb) guile (define wp2 (make-breakpoint "result" #:wp-class WP_WRITE #:type BP_NONE))
ERROR: In procedure make-breakpoint:
ERROR: In procedure gdbscm_make_breakpoint: unsupported breakpoint type in position 5: "BP_NONE"
Error while executing Scheme code.
Which seems better; we now use the name of the type, and report that
this type is unsupported.
gdb/ChangeLog:
* guile/scm-breakpoint.c (gdbscm_make_breakpoint): Split the error
for invalid breakpoint numbers, and unsupported breakpoint
numbers.
gdb/testsuite/ChangeLog:
* gdb.guile/scm-breakpoint.exp (test_watchpoints): Add new tests.
|
|
This patch adds a file with the ISA 3.1 check. The ISA 3.1 check is
added to the test to ensure the test is only run on ISA 3.1 or newer.
gdb/testsuite/ChangeLog
2021-06-25 Carl Love <cel@us.ibm.com>
* gdb.arch/powerpc-plxv-norel.exp: Add call to skip_power_isa_3_1_tests.
* lib/gdb.exp(skip_power_isa_3_1_tests): New gdb_caching_proc test.
|
|
GNAT emits encoded type names, but these aren't usually of interest to
users. The Ada language code in gdb hides this oddity -- but the
Python layer does not. This patch changes the Python code to use the
decoded Ada type name, when appropriate.
I looked at decoding Ada type names during construction, as that would
be cleaner. However, the Ada support in gdb relies on the encodings
at various points, so this isn't really doable right now.
2021-06-25 Tom Tromey <tromey@adacore.com>
* python/py-type.c (typy_get_name): Decode an Ada type name.
gdb/testsuite/ChangeLog
2021-06-25 Tom Tromey <tromey@adacore.com>
* gdb.ada/py_range.exp: Add type name test cases.
|
|
When running test-case gdb.base/info-macros.exp, I run into:
...
PASS: gdb.base/info-macros.exp: info macro --
PASS: gdb.base/info-macros.exp: info macro --
DUPLICATE: gdb.base/info-macros.exp: info macro --
PASS: gdb.base/info-macros.exp: info macro --
...
These messages come from gdb_test calls using the following commands:
- "info macro --"
- "info macro -- "
- "info macro -- ".
Apparantly the test names get stripped of trailing whitespace, and the first
two end up identical.
Fix this by explicitly specifying an <EOL> after the trailing whitespace in
the test name, such that we have:
...
PASS: gdb.base/info-macros.exp: info macro --
PASS: gdb.base/info-macros.exp: info macro -- <EOL>
PASS: gdb.base/info-macros.exp: info macro -- <EOL>
...
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-06-24 Tom de Vries <tdevries@suse.de>
* gdb.base/info-macros.exp: Add <EOL> after trailing whitespace in
test names.
|
|
I found the following duplicates in gdb.base/argv0-symlink.exp:
...
DUPLICATE: gdb.base/argv0-symlink.exp: set print repeats 10000
DUPLICATE: gdb.base/argv0-symlink.exp: set print elements 10000
...
Fix these by using with_test_prefix "file symlink" / "dir symlink".
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-06-24 Tom de Vries <tdevries@suse.de>
* gdb.base/argv0-symlink.exp: Use with_test_prefix.
|
|
On Ubuntu 20.04, when the debug info package for libc is not installed,
I get:
FAIL: gdb.base/info-types-c++.exp: info types
FAIL: gdb.base/info-types-c.exp: info types
The reason is that the output of info types is exactly:
(gdb) info types
All defined types:
File /home/smarchi/src/binutils-gdb/gdb/testsuite/gdb.base/info-types.c:
52: typedef enum {...} anon_enum_t;
45: typedef struct {...} anon_struct_t;
68: typedef union {...} anon_union_t;
28: typedef struct baz_t baz;
31: typedef struct baz_t * baz_ptr;
21: struct baz_t;
double
33: enum enum_t;
float
int
38: typedef enum enum_t my_enum_t;
17: typedef float my_float_t;
16: typedef int my_int_t;
54: typedef enum {...} nested_anon_enum_t;
47: typedef struct {...} nested_anon_struct_t;
70: typedef union {...} nested_anon_union_t;
30: typedef struct baz_t nested_baz;
29: typedef struct baz_t nested_baz_t;
39: typedef enum enum_t nested_enum_t;
19: typedef float nested_float_t;
18: typedef int nested_int_t;
62: typedef union union_t nested_union_t;
56: union union_t;
unsigned int
(gdb)
The lines we expect in the test contain an empty line at the end:
...
"62:\[\t \]+typedef union union_t nested_union_t;" \
"56:\[\t \]+union union_t;" \
"--optional" "\[\t \]+unsigned int" \
""]
This is written with the supposition that other files will be listed, so
an empty line will be included to separate the symbols from this file
from the next one. This empty line is not included when info-types.c is
the only file listed.
Fix this by rewriting gdb_test_lines to accept a single, plain tcl multiline
regexp, such that we can write:
...
"62:\[\t \]+typedef union union_t nested_union_t;" \
"56:\[\t \]+union union_t;(" \
"\[\t \]+unsigned int)?" \
"($|\r\n.*)"]
...
Tested affected test-cases:
- gdb.base/info-types-c.exp
- gdb.base/info-types-c++.exp
- gdb.base/info-macros.exp
- gdb.cp/cplusfuncs.exp
on x86_64-linux (openSUSE Leap 15.2), both with check and check-read1.
Also tested the first two with gcc-4.8.
Also tested on ubuntu 18.04.
gdb/testsuite/ChangeLog:
2021-06-23 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (gdb_test_lines): Rewrite to accept single
multiline tcl regexp.
* gdb.base/info-types.exp.tcl: Update. Make empty line at end of
regexp optional.
* gdb.base/info-macros.exp: Update.
* gdb.cp/cplusfuncs.exp: Update.
|
|
Without that it is impossible to debug on riscv64.
gdb/
PR symtab/27999
* dwarf2/loc.c (decode_debug_loclists_addresses): Support
DW_LLE_start_end.
gdb/testsuite/
PR symtab/27999
* lib/dwarf.exp (start_end): New proc inside loclists.
* gdb.dwarf2/loclists-start-end.exp: New file.
* gdb.dwarf2/loclists-start-end.c: New file.
|
|
This test-case is intended to excercise this code in process_imported_unit_die:
...
/* We're importing a C++ compilation unit with tag DW_TAG_compile_unit
into another compilation unit, at root level. Regard this as a hint,
and ignore it. */
if (die->parent && die->parent->parent == NULL
&& per_cu->unit_type == DW_UT_compile
&& per_cu->lang == language_cplus)
return;
...
in the sense that the test-case should fail if the
"per_cu->lang == language_cplus" clause is removed.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-06-22 Tom de Vries <tdevries@suse.de>
* gdb.dwarf2/imported-unit-c.exp: New file.
|
|
I randomly hit a situation where gdbserver crashed immediately before
I issued a 'stepi' to GDB, it turns out that this causes GDB itself to
crash.
What happens is that as part of the stepi we try to insert some
breakpoints into the inferior, so from insert_breakpoints we figure
out what we want to insert, then, eventually, try to send some packets
to the remote to get the breakpoints inserted.
It is only at this point that GDB realises that the target has gone
away. This causes GDB to then enter this call stack:
unpush_and_perror
remote_unpush_target
generic_mourn_inferior
breakpoint_init_inferior
delete_breakpoint
update_global_location_list
So, we realise the target is gone and so delete the breakpoints
associated with that target.
GDB then throws a TARGET_CLOSE_ERROR from unpush_and_error.
This error is caught in insert_breakpoints where we then try to print
a nice error saying something like:
Cannot insert breakpoint %d: some error text here...
To fill in the '%d' we try to read properties of the breakpoint
object.
Which was deleted due to the delete_breakpoint call above.
And so GDB dies...
My proposal in this commit is that, should we catch a
TARGET_CLOSE_ERROR in insert_breakpoints, then we just rethrow the
error.
This will cause the main event loop to print something like:
Remote connection closed
Which I think is fine, I don't think the user will care much which
particular breakpoint GDB was operating on when the connection closed,
just knowing that the connection closed should be enough I think.
I initially added a test to 'gdb.server/server-kill.exp' for this
issue, however, my first attempt was not good enough, the test was
passing even without my fix.
Turns out that the server-kill.exp test actually kills the PID of the
inferior, not the PID of the server. This means that gdbserver is
actually able to send a packet to GDB saying that the inferior has
exited prior to gdbserver itself shutting down. This extra
information was enough to prevent the bug I was seeing manifest.
So, I have extended server-kill.exp to run all of the tests twice, the
first time we still kill the inferior. On the second run we hard kill
the gdbserver itself, this prevents the server from sending anything
to GDB before it exits.
My new test is only expected to fail in this second mode of
operation (killing gdbserver itself), and without my fix, that is what
I see.
gdb/ChangeLog:
* breakpoint.c (insert_bp_location): If we catch a
TARGET_CLOSE_ERROR just rethrow it, the breakpoints might have
been deleted.
gdb/testsuite/ChangeLog:
* gdb.server/server-kill.exp: Introduce global kill_pid_of, and
make use of this in prepare to select which pid we should kill.
Run all the tests twice with a different kill_pid_of value.
(prepare): Make use of kill_pid_of.
(test_stepi): New proc.
|
|
Add new methods to the PendingFrame and Frame classes to obtain the
stack frame level for each object.
The use of 'level' as the method name is consistent with the existing
attribute RecordFunctionSegment.level (though this is an attribute
rather than a method).
For Frame/PendingFrame I went with methods as these classes currently
only use methods, including for simple data like architecture, so I
want to be consistent with this interface.
gdb/ChangeLog:
* NEWS: Mention the two new methods.
* python/py-frame.c (frapy_level): New function.
(frame_object_methods): Register 'level' method.
* python/py-unwind.c (pending_framepy_level): New function.
(pending_frame_object_methods): Register 'level' method.
gdb/doc/ChangeLog:
* python.texi (Unwinding Frames in Python): Mention
PendingFrame.level.
(Frames In Python): Mention Frame.level.
gdb/testsuite/ChangeLog:
* gdb.python/py-frame.exp: Add Frame.level tests.
* gdb.python/py-pending-frame-level.c: New file.
* gdb.python/py-pending-frame-level.exp: New file.
* gdb.python/py-pending-frame-level.py: New file.
|
|
This patch came about because I wanted to write a frame unwinder that
would corrupt the backtrace in a particular way. In order to achieve
what I wanted I ended up trying to write an unwinder like this:
class FrameId(object):
.... snip class definition ....
class TestUnwinder(Unwinder):
def __init__(self):
Unwinder.__init__(self, "some name")
def __call__(self, pending_frame):
pc_desc = pending_frame.architecture().registers().find("pc")
pc = pending_frame.read_register(pc_desc)
sp_desc = pending_frame.architecture().registers().find("sp")
sp = pending_frame.read_register(sp_desc)
# ... snip code to decide if this unwinder applies or not.
fid = FrameId(pc, sp)
unwinder = pending_frame.create_unwind_info(fid)
unwinder.add_saved_register(pc_desc, pc)
unwinder.add_saved_register(sp_desc, sp)
return unwinder
The important things here are the two calls:
unwinder.add_saved_register(pc_desc, pc)
unwinder.add_saved_register(sp_desc, sp)
On x86-64 these would fail with an assertion error:
gdb/regcache.c:168: internal-error: int register_size(gdbarch*, int): Assertion `regnum >= 0 && regnum < gdbarch_num_cooked_regs (gdbarch)' failed.
What happens is that in unwind_infopy_add_saved_register (py-unwind.c)
we call register_size, as register_size should only be called on
cooked (real or pseudo) registers, and 'pc' and 'sp' are implemented
as user registers (at least on x86-64), we trigger the assertion.
A simple fix would be to check in unwind_infopy_add_saved_register if
the register number we are handling is a cooked register or not, if
not we can throw a 'Bad register' error back to the Python code.
However, I think we can do better.
Consider that at the CLI we can do this:
(gdb) set $pc=0x1234
This works because GDB first evaluates '$pc' to get a register value,
then evaluates '0x1234' to create a value encapsulating the
immediate. The contents of the immediate value are then copied back
to the location of the register value representing '$pc'.
The value location for a user-register will (usually) be the location
of the real register that was accessed, so on x86-64 we'd expect this
to be $rip.
So, in this patch I propose that in the unwinder code, when
add_saved_register is called, if it is passed a
user-register (i.e. non-cooked) then we first fetch the register,
extract the real register number from the value's location, and use
that new register number when handling the add_saved_register call.
If either the value location that we get for the user-register is not
a cooked register then we can throw a 'Bad register' error back to the
Python code, but in most cases this will not happen.
gdb/ChangeLog:
* python/py-unwind.c (unwind_infopy_add_saved_register): Handle
saving user registers.
gdb/testsuite/ChangeLog:
* gdb.python/py-unwind-user-regs.c: New file.
* gdb.python/py-unwind-user-regs.exp: New file.
* gdb.python/py-unwind-user-regs.py: New file.
|
|
This patch updates the gdb test to use the new bgetar and bnstarl mnemonics
introduced in commit 5a4037661bccd156d65093f1f0cf2cd43f31e9d9. The test
previously used the bctar and bctarl mnemonics.
gdb/testsuite/ChangeLog
2021-06-17 Carl Love <cel@us.ibm.com>
* gdb.arch/powerpc-power8.exp(bctar, bctarl): Update mnemonics
to bgetar and bgetarl.
* gdb.arch/powerpc-power8.s((bctar, bctarl): Update comments
for mnemonics to bgetar and bnstarl.
|
|
This test tests passing arguments made of exactly two single-quotes
('') or a single newline character through the --args argument of GDB.
For some reason, GDB adds some extra single quotes when transmitting the
arguments to GDBserver. This produces some FAILs when testing with the
native-extended-gdbserver board:
FAIL: gdb.base/args.exp: argv[2] for one empty (with single quotes)
FAIL: gdb.base/args.exp: argv[2] for two empty (with single quotes)
FAIL: gdb.base/args.exp: argv[3] for two empty (with single quotes)
FAIL: gdb.base/args.exp: argv[2] for one newline
FAIL: gdb.base/args.exp: argv[2] for two newlines
FAIL: gdb.base/args.exp: argv[3] for two newlines
This is documented as PR 27989. Add some appropriate KFAILs.
gdb/testsuite/ChangeLog:
* gdb.base/args.exp: Check target, KFAIL if remote.
(args_test): Add parameter and use it.
Change-Id: I49225d1c7df7ebaba480ebdd596df80f8fbf62f0
|
|
Some test names end with a parenthesis, we don't want that:
https://sourceware.org/gdb/wiki/GDBTestcaseCookbook#Do_not_use_.22tail_parentheses.22_on_test_messages
Fix that.
gdb/testsuite/ChangeLog:
* gdb.base/args.exp: Remove trailing parenthesis in test names.
Change-Id: I0306ea202bae3a4ed5bf0bd65e0ab5ed5de52fe1
|
|
All tests in this file append to GDBFLAGS instead of overwriting it,
except the last two. I noticed because when testing with the
native-extended-remote board, it removes the "set sysroot" argument, and
it causes the test to be very long to run, due to big glibc debug info
being read through the remote target.
I think this oddity is due to a race condition between these two
commits:
[1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=c22261528c50f7760dd6a2e29314662b377eebb4
[2] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6b8ce727297b1e40738e50f83a75881b290fe6a6
The first one added the two tests. The second one changes the test to
append to GDBFLAGS instead of overwriting it. But the second one was
probably written before the first one was it, so missed the new tests.
Change those two tests to be like the others.
gdb/testsuite/ChangeLog:
* gdb.base/args.exp: Use $old_gdbflags in all tests.
Change-Id: I531276125ecb70e80f52adbd320ebb85b0c8eba0
|
|
Use save_vars instead of manually saving/restoring. This ensures that
if anything throws an error, GDBFLAGS will be correctly restored.
Remove the global GDBFLAGS declaration at the top, it's not necessary.
gdb/testsuite/ChangeLog:
* gdb.base/args.exp: Use save_vars.
Change-Id: I3a45e4fc1635ec0212de2415040f91eecaf4a057
|
|
This commit fixes a test coverage regression caused by:
commit b001de2320446ec803b4ee5e0b9710b025b84469
Author: Andrew Burgess <andrew.burgess@embecosm.com>
AuthorDate: Mon Nov 26 17:56:39 2018 +0000
Commit: Andrew Burgess <andrew.burgess@embecosm.com>
CommitDate: Wed Dec 12 17:33:52 2018 +0000
gdb: Update test pattern to deal with native-extended-gdbserver
While looking at a regression caused by a local patch I was working
on, I noticed this:
pre-prompt
(gdb)
prompt
PASS: gdb.base/annota1.exp: breakpoint info
PASS: gdb.base/annota1.exp: run until main breakpoint
run
post-prompt
Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/outputs/gdb.base/annota1/annota1
next
Note how above, we get the "run until main breakpoint" pass even
before "run" shows up in the log! The issue is that the test isn't
really testing anything, it always passes regardless of the gdb
output.
There are a few problems here, fixed by this commit:
- using {} to build the list for [join], when the strings we're
joining include variable names that must be expanded. Such list
need to be built with [list] instead.
- [join] joins strings with a space character by default. We need to
pass the empty string as second parameter so that it just concats
the strings.
- doing too much in a "-re" (calling procedures), which doesn't work
correctly. I've seen this before and never digged deeper into why.
Probably something to do with how gdb_test_multiple is implemented.
Regardless, easy and clear enough to build the pattern first into a
variable.
gdb/testsuite/ChangeLog:
yyyy-mm-dd Pedro Alves <pedro@palves.net>
* gdb.base/annota1.exp: Build list using [list] instead of {}.
Tell [join] to join with no character. Build expected pattern in
separate variable instead of in the -re expression directly.
Change-Id: Ib3c89290f0e9ae4a0a43422853fcd4a7a7e12b18
|
|
This ChangeLog entry is in the wrong file, fix that.
Change-Id: I43464e1bdb94d2f40d4c7dfaf425fc498851964c
|
|
Loading libc.so's symbols increased the amount of time needed for
114-symbol-info-function to fetch symbols, causing a timeout during my
testing. I enclosed the entire block with a "with_timeout_factor 4",
which fixes the problem for me. (Using 2 also fixed it for me, but it
might not be enough when running this test on slower machines.)
gdb/testsuite/ChangeLog:
* gdb.mi/mi-sym-info.exp (114-symbol-info-function test): Increase
timeout.
|
|
One consequence of changing libpthread_name_p() in solib.c to (also)
match libc is that the symbols for libc will now be loaded by
solib_add() in solib.c. I think this is mostly harmless because
we'll likely want these symbols to be loaded anyway, but it did cause
two failures in gdb.base/print-symbol-loading.exp.
Specifically...
1)
sharedlibrary .*
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib off: load shared-lib
now looks like this:
sharedlibrary .*
Symbols already loaded for /lib64/libc.so.6
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib off: load shared-lib
2)
sharedlibrary .*
Loading symbols for shared libraries: .*
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib brief: load shared-lib
now looks like this:
sharedlibrary .*
Loading symbols for shared libraries: .*
Symbols already loaded for /lib64/libc.so.6
(gdb) PASS: gdb.base/print-symbol-loading.exp: shlib brief: load shared-lib
Fixing case #2 ended up being easier than #1. #1 had been using
gdb_test_no_output to correctly match this no-output case. I
ended up replacing it with gdb_test_multiple, matching the exact
expected output for each of the two now acceptable cases.
For case #2, I simply added an optional non-capturing group
for the potential new output.
gdb/testsuite/ChangeLog:
* gdb.base/print-symbol-loading.exp (proc test_load_shlib):
Allow "Symbols already loaded for..." messages.
|
|
When using glibc-2.34, we now see messages related to the loading of
the thread library for non-thread programs. E.g. for the test case,
gdb.base/execl-update-breakpoints.exp, we will see the following when
starting the program:
(gdb) break -qualified main
Breakpoint 1 at 0x100118c: file /ironwood1/sourceware-git/f34-2-glibc244_fix/bld/../../worktree-glibc244_fix/gdb/testsuite/gdb.base/execl-update-breakpoints.c, line 34.
(gdb) run
Starting program: [...]/execl-update-breakpoints1
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
The two lines of output related to libthread_db are new; we didn't see
these in the past. This is a side effect of libc now containing the
pthread API - we can no longer tell whether the program is
multi-threaded by simply looking for libpthread.so. That said, I
think that we now want to load libthread_db anyway since it's used to
resolve TLS variables; i.e. we need it for correctly determining the
value of errno.
This commit adds the necessary regular expressions to match this
(optional) additional output in the two tests which were failing
without it.
gdb/testsuite/ChangeLog:
* gdb.base/execl-update-breakpoints.exp: Add regular
expression for optionally matching output related to
libthread_db.
* gdb.base/fork-print-inferior-events.exp: Likewise.
|
|
mi-var-child-f.exp uses array.f as the inferior, which uses an unnamed
main function. This causes false positive fails for Intel compilers, as
they emit the following DWARF:
~~~
0x0000002a: DW_TAG_subprogram
DW_AT_low_pc (0x0000000000404800)
DW_AT_high_pc (0x000000000040484c)
DW_AT_frame_base (DW_OP_reg6 RBP)
DW_AT_linkage_name ("MAIN__")
DW_AT_name ("_unnamed_main$$")
DW_AT_decl_file ("array.f")
DW_AT_decl_line (16)
DW_AT_external (true)
DW_AT_main_subprogram (true)
~~~
The testsuite for fortran uses test_compiler_info to determine a hardcoded
string which is used to run to main and as a testing regex:
~~~
proc fortran_main {} {
if {[test_compiler_info {gcc-4-[012]-*}]
|| [test_compiler_info {gcc-*}]
|| [test_compiler_info {icc-*}] {
return "MAIN__"
} elseif {[test_compiler_info {clang-*}]} {
return "MAIN_"
} else {
return "unknown"
}
}
~~~
GDB however uses DW_AT_name mostly in its output, which fails the regex.
To fix this testcase immediately, I modernized array.f and gave it a named
main. There was no specific reason it was unnamed anyway. Fixing
the testsuite properly is not straightforward. fortran_main and
test_compiler_info would need some changes, which has broader influences.
I might look at this later down the road.
gdb/testsuite/ChangeLog:
2021-06-11 Felix Willgerodt <felix.willgerodt@intel.com>
* gdb.mi/array.f: Convert into...
* gdb.mi/array.f90: ...this.
* gdb.mi/mi-var-child-f.exp: Use array.f90.
|
|
This patch implements Rust raw identifiers in the lexer in gdb. There
was an earlier patch to do this, but the contributor didn't reply to
my email asking whether he had sorted out his copyright assignment.
This is relatively straightforward, but a small test suite addition
was needd to ensure that the new test is skipped on older versions of
rustc -- ones that predate the introduction of raw identifiers.
gdb/ChangeLog
2021-06-11 Tom Tromey <tom@tromey.com>
PR rust/23427
* rust-parse.c (rust_parser::lex_identifier): Handle raw
identifiers.
(rust_lex_tests): Add raw identifier tests.
gdb/testsuite/ChangeLog
2021-06-11 Tom Tromey <tom@tromey.com>
PR rust/23427
* lib/rust-support.exp (rust_compiler_version): New caching proc.
* gdb.rust/rawids.exp: New file.
* gdb.rust/rawids.rs: New file.
|
|
When running test-case gdb.mi/user-selected-context-sync.exp with gcc-11, we
get:
...
continue^M
Continuing.^M
FAIL: gdb.mi/user-selected-context-sync.exp: mode=all-stop: test_setup: \
inferior 1: continue to breakpoint: continue thread 1.2 to infinite \
loop breakpoint (timeout)
...
This is a regression since commit aa33ea68330 "testsuite, mi: avoid a clang
bug in 'user-selected-context-sync.exp'", which fixes a similar hang when
using clang.
The source before the commit contains:
...
while (1);
...
and after the commit:
...
int spin = 1;
while (spin);
...
[ FWIW, I've filed a PR gcc/101011 - Inconsistent debug info for "while (1);"
to mention that gcc-11 has different behaviour for these two loops. ]
The problem is that:
- the test-case expects the behaviour that a breakpoint set
on the while line will trigger on every iteration, and
- that is not guaranteed by either version of the loop.
Fix this by using a while loop with a dummy body:
...
volatile int dummy = 0;
while (1)
dummy = !dummy;
...
and setting the breakpoint in the body.
Tested on x86_64-linux with clang 10.0.1, gcc-4.8, gcc 7.5.0 and gcc 11.1.1.
gdb/testsuite/ChangeLog:
2021-06-10 Tom de Vries <tdevries@suse.de>
* gdb.mi/user-selected-context-sync.c (child_sub_function, main):
Rewrite while (1) using dummy loop body.
|
|
After this clang backend patch(https://reviews.llvm.org/D91734), 8 test points
started to FAIL in this test case. As mentioned in this PR, "...this test is
trying to next over a function call; gcc attributes all parameter evaluation
to the function name, while clang will attribute each parameter to its own
location. And when the parameters span across multiple source lines, the
is_stmt heuristic kicks in, so we stop on each line with actual parameters...".
gdb.base/foll-exec.c test file snippet :
. . .
42 execlp (prog, /* tbreak-execlp */
43 prog,
44 "execlp arg1 from foll-exec",
45 (char *) 0);
46
47 printf ("foll-exec is about to execl(execd-prog)...\n");
. . .
Line table: (before clang backend patch for the above code snippet) :
0x000000b0: 84 address += 8, line += 2
0x000000000020196a 42 3 1 0 0
0x000000b1: 08 DW_LNS_const_add_pc (0x0000000000000011)
0x000000b2: 41 address += 3, line += 5
0x000000000020197e 47 3 1 0 0
Line table: (after clang backend patch for the above code snippet) :
0x000000b5: 84 address += 8, line += 2
0x0000000000201958 42 11 1 0 0
0x000000b6: 05 DW_LNS_set_column (4)
0x000000b8: 75 address += 7, line += 1
0x000000000020195f 43 4 1 0 0
0x000000b9: 05 DW_LNS_set_column (3)
0x000000bb: 73 address += 7, line += -1
0x0000000000201966 42 3 1 0 0
0x000000bc: 08 DW_LNS_const_add_pc (0x0000000000000011)
0x000000bd: 4f address += 4, line += 5
0x000000000020197b 47 3 1 0 0
Following 8 test points started to fail after the above clang backend patch.
FAIL: gdb.base/foll-exec.exp: step through execlp call
FAIL: gdb.base/foll-exec.exp: step after execlp call
FAIL: gdb.base/foll-exec.exp: print execd-program/global_i (after execlp)
FAIL: gdb.base/foll-exec.exp: print execd-program/local_j (after execlp)
FAIL: gdb.base/foll-exec.exp: print follow-exec/local_k (after execlp)
FAIL: gdb.base/foll-exec.exp: step through execl call
FAIL: gdb.base/foll-exec.exp: step after execl call
FAIL: gdb.base/foll-exec.exp: print execd-program/local_j (after execl)
As we can note, reason for these new test failures is due to additional
.debug_line entries getting created in case of clang compiler, hence to fix
this issue, test case required either additional next command during
these multi-line function call or combine these multi-line function call into
single line. This PR has taken the latter approach and converted the multi-line
function call into single line in foll-exec.c, thereby there is no change in
.debug_line entries now and test case works as expected.
|
|
With check-read1 I occasionally run into:
...
FAIL: gdb.cp/nested-types.exp: ptype S10 (limit = 7) \
// parse failed (timeout)
...
I can trigger this reliably by running check-read1 in conjunction with
stress -c 5.
Fix this by breaking up the regexp in cp_test_ptype_class.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-06-10 Tom de Vries <tdevries@suse.de>
* lib/cp-support.exp (cp_test_ptype_class): Break up regexp.
* gdb.cp/nested-types.exp: Remove usage of read1 timeout factor.
|
|
When running check-read1, we run into:
...
FAIL: gdb.cp/cplusfuncs.exp: info function for "operator=(" (timeout)
...
Fix this by using using gdb_test_lines in info_func_regexp.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-06-10 Tom de Vries <tdevries@suse.de>
* gdb.cp/cplusfuncs.exp (info_func_regexp): Use gdb_test_lines.
|
|
Tom de Vries noticed that the recent changes to the testsuite's
configury required an update to the README. This patch changes the
text to document the new reality.
2021-06-09 Tom Tromey <tromey@adacore.com>
* README (Example): Update read1 example.
|
|
I was diagnosing some problem with a TUI test case, which lead me to
improve the logging of _check_box a bit. It did help me, so I think it
would be nice to have it upstream.
gdb/testsuite/ChangeLog:
* lib/tuiterm.exp (Term) <_check_box>: Improve logging.
Change-Id: I887e83c02507d6c59c991e17f795c844ed63bacf
|
|
While reviewing a patch sent to the mailing list, I noticed there are few
places where python code checks if a variable is 'None' or not by using the
comparison operators '==' and '!='. PEP8[1], which is used as coding standard
in GDBÂ coding standards, recommends using 'is' / 'is not' when comparing to a
singleton such as 'None'.
This patch proposes to change the instances of '== None' by 'is None' and
'!= None' by 'is not None'.
[1] https://www.python.org/dev/peps/pep-0008/
gdb/doc/ChangeLog:
* python.texi (Writing a Pretty-Printer): Use 'is None' instead of
'== None'.
gdb/ChangeLog:
* python/lib/gdb/FrameDecorator.py (FrameDecorator): Use 'is None' instead of
'== None'.
(FrameVars): Use 'is not None' instead of '!= None'.
* python/lib/gdb/command/frame_filters.py (SetFrameFilterPriority): Use 'is None'
instead of '== None' and 'is not None' instead of '!= None'.
gdb/testsuite/ChangeLog:
* gdb.base/premature-dummy-frame-removal.py (TestUnwinder): Use
'is None' instead of '== None' and 'is not None' instead of
'!= None'.
* gdb.python/py-frame-args.py (lookup_function): Same.
* gdb.python/py-framefilter-invalidarg.py (Reverse_Function): Same.
* gdb.python/py-framefilter.py (Reverse_Function): Same.
* gdb.python/py-nested-maps.py (lookup_function): Same.
* gdb.python/py-objfile-script-gdb.py (lookup_function): Same.
* gdb.python/py-prettyprint.py (lookup_function): Same.
* gdb.python/py-section-script.py (lookup_function): Same.
* gdb.python/py-unwind-inline.py (dummy_unwinder): Same.
* gdb.python/python.exp: Same.
* gdb.rust/pp.py (lookup_function): Same.
|
|
It's a common mistake of mine to do:
...
set l [list "foo" "bar"]
set re [multi_line $l]
...
and to get "foo bar" while I was expecting "foo\r\nbar", which I get after
doing instead:
...
set re [multi_line {*}$l]
...
Detect this type of mistake by erroring out in multi_line when only one
argument is passed.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-06-08 Tom de Vries <tdevries@suse.de>
* lib/gdb.exp (multi_line): Require more than one argument.
* gdb.base/gdbinit-history.exp: Update multi_line call.
* gdb.base/jit-reader.exp: Remove multi_line call.
* gdb.fortran/dynamic-ptype-whatis.exp: Same.
|
|
With check-read1 we run into:
...
FAIL: gdb.base/info-macros.exp: info macros info-macros.c:42 (timeout)
...
Fix this by using gdb_test_lines from gdb.base/info-types.exp.tcl.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-06-08 Tom de Vries <tdevries@suse.de>
* gdb.base/info-types.exp.tcl (match_line, gdb_test_lines): Move ...
* lib/gdb.exp: ... here.
* gdb.base/info-macros.exp: Use gdb_test_lines.
|
|
After adding support for --any in match_line, we can simplify
gdb.base/info-types.exp.tcl further: we can add the "All defined types:"
regexp in the output_lines list:
...
set output_lines \
[list \
+ "All defined types:" \
+ "--any" \
$file_re \
...
Consequently, we can simplify the state machine to track a variable "found"
with values:
- 0 (unmatched)
- 1 (matched)
- -1 (mismatch).
This makes the code generic enough to factor out into a new proc
gdb_test_lines.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-06-08 Tom de Vries <tdevries@suse.de>
* gdb.base/info-types.exp.tcl (match_line): Handle --any.
(gdb_test_lines): Factor out of ...
(run_test): ... here.
|
|
With check-read1, I run into:
...
FAIL: gdb.base/batch-preserve-term-settings.exp: batch run: \
terminal settings preserved
...
This is caused by spawn_shell matching too little output, after which
things start to go out of sync.
More specifically, the regexp:
...
-re "PS1=\[^\r\n\]*\r\n.*$shell_prompt_re$" {
...
matches the first and part of the second line of this output:
...
PS1="gdb-subshell$ "^M
sh-4.4$ PS1="gdb-subshell$ "^M
gdb-subshell$
...
while it's supposed to match the entire output.
Fix this by splitting up the regexp into a part that skips the lines with PS1,
and one that reads the shell prompt.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-06-08 Tom de Vries <tdevries@suse.de>
* gdb.base/batch-preserve-term-settings.exp (spawn_shell): Fix
matching of initial prompt.
|
|
With a testsuite setup modified to make expect wait a little bit longer for
gdb output (see PR27957), I reliably run into:
...
PASS: gdb.threads/multi-create-ns-info-thr.exp: continue to breakpoint 1
FAIL: gdb.threads/multi-create-ns-info-thr.exp: continue to breakpoint 2 \
(timeout)
...
This is due to this regexp:
...
-re "Breakpoint $decimal,.*$srcfile:$bp_location1" {
...
consuming several lines using the ".*" part, while it's intended to match one
line looking like this:
...
Thread 1 "multi-create-ns" hit Breakpoint 2, create_function () \
at multi-create.c:45^M
...
Fix this by limiting the regexp to one line.
Tested on x86_64-linux.
gdb/testsuite/ChangeLog:
2021-06-08 Tom de Vries <tdevries@suse.de>
* gdb.threads/multi-create-ns-info-thr.exp: Limit breakpoint regexp to
one line.
|