Mike Frysinger [Sun, 27 Jun 2021 05:55:50 +0000 (01:55 -0400)]
opcodes: constify & scope microblaze opcodes
This is exporting the variable "opcodes" as a large writable blob.
This is not a namespace friendly name, so add a "microblaze" prefix,
and then sprinkle const over its definition & use.
Mike Frysinger [Sun, 27 Jun 2021 05:37:24 +0000 (01:37 -0400)]
opcodes: constify aarch64_opcode_tables
This table is huge (~350k), so stop putting it into writable .data
since it's only const data.
Nick Clifton [Thu, 1 Jul 2021 13:10:38 +0000 (14:10 +0100)]
Partially fix debuginfod tests in binutils testsuite.
PR 28029
* testsuite/binutils-all/debuginfod.exp: Replace -wK with -wk.
Pedro Alves [Fri, 11 Jun 2021 16:56:32 +0000 (17:56 +0100)]
Linux: Access memory even if threads are running
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
Andrei Homescu [Thu, 1 Jul 2021 11:01:55 +0000 (12:01 +0100)]
readelf: Reset file position to beginning for thin archive members
* readelf.c (process_archive): Reset file position to the
beginning when calling process_object for thin archive members.
* testsuite/binutils-all/readelf.exp: Add test.
* testsuite/binutils-all/readelf.h.thin: New file.
Richard Earnshaw [Thu, 1 Jul 2021 10:37:13 +0000 (11:37 +0100)]
arm: don't treat XScale features as part of the FPU [PR 28031]
Although the XScale and its iwMMX extensions are implemented in the
Arm co-processor space, they are not considered to be part of the FPU
specification. In particular, they cannot be enabled or disabled via
a .fpu directive. It's therefore incorrect to strip these properties
when a new .fpu directive is encountered.
Note that the legacy Maverick co-processor is considered to be a FPU
and it is possible to control this via the .fpu directive.
include:
PR gas/28031
* opcode/arm.h (FPU_ANY): Exclude XScale-related features.
GDB Administrator [Thu, 1 Jul 2021 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in
Mike Frysinger [Wed, 30 Jun 2021 02:06:30 +0000 (22:06 -0400)]
sim: ppc: unify (most) compiler warnings with common code
Copy most of the common build warning logic over from the common
code to help keep code behavior a bit consistent, and turn them
on by default. We disable a few flags for now until we can clean
the code up.
Mike Frysinger [Wed, 30 Jun 2021 17:01:17 +0000 (13:01 -0400)]
sim: cris/frv/iq2000/lm32: merge with common configure script
Now that the scache logic has been migrated into the common code,
there's nothing specific in these configure scripts, so merge them
into the common one.
The frv unique logic can be moved to a dedicated include and merged
in the common configure since the flag has been scoped to the arch.
Mike Frysinger [Tue, 29 Jun 2021 02:39:16 +0000 (22:39 -0400)]
sim: unify scache settings
The cgen scache module is enabled by every cgen port, and with the
same default value of 16k (which matches the common default value).
Let's pull this option out of the individual ports (via CPPFLAGS)
and into the common code (via config.h).
The object itself is compiled only for cgen ports atm, so that part
doesn't change. The scache code is initialized dynamically via the
modules.c logic. That's why the profile code needs an additional
CGEN_ARCH check.
This will allow us to collapse arch configure files more. Merging
the source files will require more future work, but integrating the
cgen & non-cgen worlds itself will take a lot.
Mike Frysinger [Tue, 29 Jun 2021 02:23:37 +0000 (22:23 -0400)]
sim: frv: scope the unique configure flag
This will make it possible to merge into the common configure by
making sure we never collide with other arches.
Mike Frysinger [Mon, 14 Jun 2021 02:45:02 +0000 (22:45 -0400)]
sim: move scache init to dynamic modules.c
Use the new modules.c framework to find & initialize this module.
Mike Frysinger [Mon, 14 Jun 2021 02:43:54 +0000 (22:43 -0400)]
sim: move profile init to dynamic modules.c
Use the new modules.c framework to find & initialize this module.
Mike Frysinger [Mon, 14 Jun 2021 02:42:49 +0000 (22:42 -0400)]
sim: move trace init to dynamic modules.c
Use the new modules.c framework to find & initialize this module.
Mike Frysinger [Mon, 14 Jun 2021 02:40:09 +0000 (22:40 -0400)]
sim: move engine init to dynamic modules.c
Use the new modules.c framework to find & initialize this module.
YunQiang Su [Wed, 30 Jun 2021 16:16:22 +0000 (17:16 +0100)]
Mark .gnu.debuglto_.debug_* as SHT_MIPS_DWARF
PR mips/28009
* bfd/elfxx-mips.c (_bfd_mips_elf_section_from_shdr,
_bfd_mips_elf_fake_sections): Mark LTO debug info as
SHT_MIPS_DWARF.
Nick Clifton [Wed, 30 Jun 2021 15:17:46 +0000 (16:17 +0100)]
Handle DW_FORM_implicit_const when displaying an attribute
* dwarf.c (read_and_display_attr_value): Handle
DW_FORM_implicit_const.
Richard Henderson [Wed, 30 Jun 2021 11:11:54 +0000 (12:11 +0100)]
Fix signedness of def_cfa_sf and def_cfa_offset_sf
* dwarf.c (display_debug_frames): Both DW_CFA_def_cfa_sf
and DW_CFA_def_cfa_offset_sf have a signed offset.
Mike Frysinger [Tue, 29 Jun 2021 02:11:30 +0000 (22:11 -0400)]
sim: bfin: merge with common configure script
Now that the model logic has been migrated into the runtime, there's
nothing specific in the bfin configure code, so merge it into the
common one.
Mike Frysinger [Tue, 29 Jun 2021 02:10:28 +0000 (22:10 -0400)]
sim: delete unused model settings
These were never fully migrated from the psim to common code, and since
we've finished moving the logic into the runtime sim state, we won't ever
need these. So punt them.
Mike Frysinger [Tue, 29 Jun 2021 02:07:44 +0000 (22:07 -0400)]
sim: move default model to the runtime sim state
This kills off another compile-time option by moving the setting to
the individual arch runtimes. This will allow dynamic selection by
the arch when doing a single build with multiple arches.
The sim_model_init rework is a little funky. In the past it was
disabled entirely if no default model was set. We maintain the
spirit of the logic by gating the fallback logic on whether the
port has defined any models.
Mike Frysinger [Tue, 29 Jun 2021 01:42:56 +0000 (21:42 -0400)]
sim: namespace sim_machs
We want to do a single build with all arches in one binary which means
we need to namespace sim_machs on a per-arch basis. Move it from a
global variable to the sim description structure so it can be setup at
runtime.
Changing the SIM_MODEL->num from an enum to an int is unfortunate, but
we specifically don't want to maintain a centralized list anymore, and
this was never used directly in common code, just passed to per-arch
callbacks.
Mike Frysinger [Wed, 30 Jun 2021 01:45:13 +0000 (21:45 -0400)]
sim: ppc: fix printf warnings
This code hits some format-zero-length warnings, so hack the code
like we did in the common layers.
Mike Frysinger [Wed, 30 Jun 2021 01:05:17 +0000 (21:05 -0400)]
sim: use -Wunused-but-set-parameter
The code is already clean, so sync this over from gdb warning.m4.
Also shuffle the order of the flags a bit to match the current gdb
warning.m4 code.
Mike Frysinger [Wed, 30 Jun 2021 00:44:55 +0000 (20:44 -0400)]
sim: fix arch Makefile regen when unified
The $(arch) variable is only setup for cgen ports, so calculate this
value dynamically. We also need to generate multiple inputs in order
to properly recreate the subdir Makefile, so list them all.
Mike Frysinger [Wed, 30 Jun 2021 00:33:14 +0000 (20:33 -0400)]
sim: use -Wno-error=maybe-uninitialized
We have some code tripping this warning, but it depends on the gcc
version & optimization levels. We've added some hints to the code
so some versions of gcc work better, but still not all. Let's just
disable the warning like gdb does.
Mike Frysinger [Tue, 29 Jun 2021 07:13:54 +0000 (03:13 -0400)]
sim: callback: add check for HAVE_KILL
Fix building on systems w/out a kill function (e.g. Windows).
Mike Frysinger [Tue, 29 Jun 2021 01:29:41 +0000 (21:29 -0400)]
sim: cris: remove cgen-ops.h include hack
This has been upstreamed into cgen itself.
Mike Frysinger [Sun, 27 Jun 2021 05:26:30 +0000 (01:26 -0400)]
sim: model: constify sim_machs storage
The array of pointers is never modified, so mark it const so it ends
up in the read-only data section.
GDB Administrator [Wed, 30 Jun 2021 00:00:09 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Tue, 29 Jun 2021 16:05:14 +0000 (12:05 -0400)]
gdb: introduce FRAME_SCOPED_DEBUG_ENTER_EXIT
Introduce FRAME_SCOPED_DEBUG_ENTER_EXIT and use it to print enter/exit
messages in important frame-related functions. I think this helps
understand which lower-level operations are done as part of which
higher-level operation. And it helps visually skip over a higher-level
operation you are not interested in.
Here's an example, combined with some py-unwind messages:
[frame] frame_unwind_find_by_frame: enter
[frame] frame_unwind_find_by_frame: this_frame=0
[frame] frame_unwind_try_unwinder: trying unwinder "dummy"
[frame] frame_unwind_try_unwinder: no
[frame] frame_unwind_try_unwinder: trying unwinder "dwarf2 tailcall"
[frame] frame_unwind_try_unwinder: no
[frame] frame_unwind_try_unwinder: trying unwinder "inline"
[frame] frame_unwind_try_unwinder: no
[frame] frame_unwind_try_unwinder: trying unwinder "jit"
[frame] frame_unwind_try_unwinder: no
[frame] frame_unwind_try_unwinder: trying unwinder "python"
[py-unwind] pyuw_sniffer: enter
[frame] frame_unwind_register_value: enter
[frame] frame_unwind_register_value: frame=-1, regnum=7(rsp)
[frame] frame_unwind_register_value: -> register=7 bytes=[
40ddffffff7f0000]
[frame] frame_unwind_register_value: exit
[py-unwind] pyuw_sniffer: frame=0, sp=0x7fffffffdd40, pc=0x5555555551ec
[frame] frame_id_p: l={stack=<sentinel>,!code,special=0x0000000000000000} -> 1
[frame] frame_id_p: l={stack=<sentinel>,!code,special=0x0000000000000000} -> 1
[frame] frame_id_eq: l={stack=<sentinel>,!code,special=0x0000000000000000}, r={stack=<sentinel>,!code,special=0x0000000000000000} -> 1
[frame] frame_unwind_register_value: enter
[frame] frame_unwind_register_value: frame=-1, regnum=6(rbp)
[frame] frame_unwind_register_value: -> register=6 bytes=[
50ddffffff7f0000]
[frame] frame_unwind_register_value: exit
[frame] frame_id_p: l={stack=<sentinel>,!code,special=0x0000000000000000} -> 1
[frame] frame_id_eq: l={stack=<sentinel>,!code,special=0x0000000000000000}, r={stack=<sentinel>,!code,special=0x0000000000000000} -> 1
[frame] get_prev_frame: enter
[frame] get_prev_frame_always_1: enter
[frame] get_prev_frame_always_1: this_frame=-1
[frame] get_prev_frame_always_1: -> {level=0,type=NORMAL_FRAME,unwind=0x5588ee3d17c0,pc=0x5555555551ec,id=<not computed>,func=<unknown>} // cached
[frame] get_prev_frame_always_1: exit
[frame] get_prev_frame: exit
[frame] value_fetch_lazy_register: (frame=0, regnum=6(rbp), ...) -> register=6 bytes=[
50ddffffff7f0000]
[frame] frame_id_p: l={stack=<sentinel>,!code,special=0x0000000000000000} -> 1
[frame] frame_id_p: l={stack=<sentinel>,!code,special=0x0000000000000000} -> 1
[frame] frame_id_eq: l={stack=<sentinel>,!code,special=0x0000000000000000}, r={stack=<sentinel>,!code,special=0x0000000000000000} -> 1
[frame] frame_unwind_register_value: enter
[frame] frame_unwind_register_value: frame=-1, regnum=7(rsp)
[frame] frame_unwind_register_value: -> register=7 bytes=[
40ddffffff7f0000]
[frame] frame_unwind_register_value: exit
[frame] frame_id_p: l={stack=<sentinel>,!code,special=0x0000000000000000} -> 1
[frame] frame_id_eq: l={stack=<sentinel>,!code,special=0x0000000000000000}, r={stack=<sentinel>,!code,special=0x0000000000000000} -> 1
[frame] get_prev_frame: enter
[frame] get_prev_frame_always_1: enter
[frame] get_prev_frame_always_1: this_frame=-1
[frame] get_prev_frame_always_1: -> {level=0,type=NORMAL_FRAME,unwind=0x5588ee3d1824,pc=0x5555555551ec,id=<not computed>,func=<unknown>} // cached
[frame] get_prev_frame_always_1: exit
[frame] get_prev_frame: exit
[frame] value_fetch_lazy_register: (frame=0, regnum=7(rsp), ...) -> register=7 bytes=[
40ddffffff7f0000]
[frame] frame_id_p: l={stack=<sentinel>,!code,special=0x0000000000000000} -> 1
[frame] frame_id_p: l={stack=<sentinel>,!code,special=0x0000000000000000} -> 1
[frame] frame_id_eq: l={stack=<sentinel>,!code,special=0x0000000000000000}, r={stack=<sentinel>,!code,special=0x0000000000000000} -> 1
[frame] frame_unwind_register_value: enter
[frame] frame_unwind_register_value: frame=-1, regnum=16(rip)
[frame] frame_unwind_register_value: -> register=16 bytes=[
ec51555555550000]
[frame] frame_unwind_register_value: exit
[frame] frame_id_p: l={stack=<sentinel>,!code,special=0x0000000000000000} -> 1
[frame] frame_id_eq: l={stack=<sentinel>,!code,special=0x0000000000000000}, r={stack=<sentinel>,!code,special=0x0000000000000000} -> 1
[frame] get_prev_frame: enter
[frame] get_prev_frame_always_1: enter
[frame] get_prev_frame_always_1: this_frame=-1
[frame] get_prev_frame_always_1: -> {level=0,type=NORMAL_FRAME,unwind=0x5588ee3d1888,pc=0x5555555551ec,id=<not computed>,func=<unknown>} // cached
[frame] get_prev_frame_always_1: exit
[frame] get_prev_frame: exit
[frame] value_fetch_lazy_register: (frame=0, regnum=16(rip), ...) -> register=16 bytes=[
ec51555555550000]
[py-unwind] pyuw_sniffer: frame claimed by unwinder test unwinder
[py-unwind] pyuw_sniffer: exit
[frame] frame_unwind_try_unwinder: yes
[frame] frame_unwind_find_by_frame: exit
gdb/ChangeLog:
* frame.h (FRAME_SCOPED_DEBUG_ENTER_EXIT): New.
* frame.c (compute_frame_id, get_prev_frame_always_1,
get_prev_frame): Use FRAME_SCOPED_DEBUG_ENTER_EXIT.
* frame-unwind.c (frame_unwind_find_by_frame): Likewise.
(frame_unwind_register_value): Likewise.
Change-Id: I45b69b4ed962e70572bc55b8adfb211483c1eeed
Simon Marchi [Tue, 29 Jun 2021 16:05:03 +0000 (12:05 -0400)]
gdb: add names to unwinders, add debug messages when looking for unwinder
I wrote this while debugging a problem where the expected unwinder for a
frame wasn't used. It adds messages to show which unwinders are
considered for a frame, why they are not selected (if an exception is
thrown), and finally which unwinder is selected in the end.
To be able to show a meaningful, human-readable name for the unwinders,
add a "name" field to struct frame_unwind, and update all instances to
include a name.
Here's an example of the output:
[frame] frame_unwind_find_by_frame: this_frame=0
[frame] frame_unwind_try_unwinder: trying unwinder "dummy"
[frame] frame_unwind_try_unwinder: no
[frame] frame_unwind_try_unwinder: trying unwinder "dwarf2 tailcall"
[frame] frame_unwind_try_unwinder: no
[frame] frame_unwind_try_unwinder: trying unwinder "inline"
[frame] frame_unwind_try_unwinder: no
[frame] frame_unwind_try_unwinder: trying unwinder "jit"
[frame] frame_unwind_try_unwinder: no
[frame] frame_unwind_try_unwinder: trying unwinder "python"
[frame] frame_unwind_try_unwinder: no
[frame] frame_unwind_try_unwinder: trying unwinder "amd64 epilogue"
[frame] frame_unwind_try_unwinder: no
[frame] frame_unwind_try_unwinder: trying unwinder "i386 epilogue"
[frame] frame_unwind_try_unwinder: no
[frame] frame_unwind_try_unwinder: trying unwinder "dwarf2"
[frame] frame_unwind_try_unwinder: yes
gdb/ChangeLog:
* frame-unwind.h (struct frame_unwind) <name>: New. Update
instances everywhere to include this field.
* frame-unwind.c (frame_unwind_try_unwinder,
frame_unwind_find_by_frame): Add debug messages.
Change-Id: I813f17777422425f0d08b22499817b23922e8ddb
Simon Marchi [Tue, 29 Jun 2021 16:03:50 +0000 (12:03 -0400)]
gdb: introduce frame_debug_printf
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
Simon Marchi [Tue, 29 Jun 2021 15:57:14 +0000 (11:57 -0400)]
gdb: make frame_debug a boolean
gdb/ChangeLog:
* frame.h (frame_debug): Change type to bool.
* frame.c (frame_debug): Change type to bool.
(_initialize_frame): Adjust.
Change-Id: I27b5359a25ad53ac42618b5708a025c348a1eeda
Nick Clifton [Tue, 29 Jun 2021 15:46:05 +0000 (16:46 +0100)]
Add the netbsdpe configuration to the list of obsolete targets.
* config.bfd (obsolete configurations): Add netbsdpe.
Tankut Baris Aktemur [Tue, 29 Jun 2021 06:26:06 +0000 (08:26 +0200)]
gdb: remove duplicate declaration of 'find_thread_ptid'
There are two declarations of 'find_thread_ptid' in gdbthread.h
with the same signature:
/* Find (non-exited) thread PTID of inferior INF. */
extern thread_info *find_thread_ptid (inferior *inf, ptid_t ptid);
and
/* Search function to lookup a (non-exited) thread by 'ptid'. Only
searches in threads of INF. */
extern struct thread_info *find_thread_ptid (inferior *inf, ptid_t ptid);
Retain the former, remove the latter. Tested by rebuilding.
gdb/ChangeLog:
2021-06-29 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com>
* gdbthread.h (find_thread_ptid): Remove the duplicate declaration.
Mike Frysinger [Mon, 28 Jun 2021 03:23:40 +0000 (23:23 -0400)]
sim: io: add printf attributes to vprintf funcs too
The compiler can still do basic format checks with vprintf style
funcs, so add the printf attribute to these.
Mike Frysinger [Mon, 28 Jun 2021 03:21:26 +0000 (23:21 -0400)]
sim: callback: add printf attributes
This helps these funcs get printf format checking coverage.
The sim-io.c hack as a result is a bit unfortunate, but the compiler
throws warnings when printing with empty strings. In this one case,
we actually want that due to the side-effect of the callback halting
execution for us.
Mike Frysinger [Mon, 28 Jun 2021 03:19:06 +0000 (23:19 -0400)]
sim: callback: drop unused printf helpers
These cover functions aren't used anywhere, so drop them. There was
one caller, but it's old DOS code that most likely hasn't been tested
in years, so just delete that too.
Mike Frysinger [Mon, 28 Jun 2021 01:36:03 +0000 (21:36 -0400)]
sim: cgen: require long long support
We require C11 now, so we can assume & require long long exists.
Drop this old code that hasn't been used for a long long time.
GDB Administrator [Tue, 29 Jun 2021 00:00:12 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Mon, 28 Jun 2021 19:28:49 +0000 (15:28 -0400)]
gdb: use gdb_bfd_count_sections in macho_symfile_offsets
When loading a mach-o (macOS) executable and trying to set a breakpoint,
a GDB built with ASan or -D_GLIBCXX_DEBUG will crash with an
out-of-bound vector access. This can be reproduced on Linux using the
repro files in bug 28017 [1]:
$ ./gdb -nx --data-directory=data-directory -q repro/test -ex "b main" -batch
/usr/include/c++/11.1.0/debug/vector:445:
In function:
std::__debug::vector<_Tp, _Allocator>::const_reference
std::__debug::vector<_Tp,
_Allocator>::operator[](std::__debug::vector<_Tp,
_Allocator>::size_type) const [with _Tp = long unsigned int; _Allocator
= std::allocator<long unsigned int>; std::__debug::vector<_Tp,
_Allocator>::const_reference = const long unsigned int&;
std::__debug::vector<_Tp, _Allocator>::size_type = long unsigned int]
Error: attempt to subscript container with out-of-bounds index 13, but
container only holds 13 elements.
Objects involved in the operation:
sequence "this" @ 0x0x61300000a590 {
type = std::__debug::vector<unsigned long, std::allocator<unsigned long> >;
}
The out-of-bound access happens here:
#0 0x00007ffff6405d22 in raise () from /usr/lib/libc.so.6
#1 0x00007ffff63ef862 in abort () from /usr/lib/libc.so.6
#2 0x00007ffff664e21e in __gnu_debug::_Error_formatter::_M_error() const [clone .cold] from /usr/lib/libstdc++.so.6
#3 0x000055555699e5ff in std::__debug::vector<unsigned long, std::allocator<unsigned long> >::operator[] (this=0x61300000a590, __n=13) at /usr/include/c++/11.1.0/debug/vector:445
#4 0x0000555556a58c17 in objfile::section_offset (this=0x61300000a4c0, section=0x55555bbe4ac0 <_bfd_std_section>) at /home/simark/src/binutils-gdb/gdb/objfiles.h:644
#5 0x0000555556a58cac in obj_section::offset (this=0x62100016d2a8) at /home/simark/src/binutils-gdb/gdb/objfiles.h:838
#6 0x0000555556a58cfa in obj_section::addr (this=0x62100016d2a8) at /home/simark/src/binutils-gdb/gdb/objfiles.h:850
#7 0x000055555779f5f7 in sort_cmp (sect1=0x62100016d2a8, sect2=0x62100016d170) at /home/simark/src/binutils-gdb/gdb/objfiles.c:902
#8 0x00005555577aae35 in __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(obj_section const*, obj_section const*)>::operator()<obj_section**, obj_section**> (this=0x7fffffffa9e0, __it1=0x60c000015970, __it2=0x60c000015940) at /usr/include/c++/11.1.0/bits/predefined_ops.h:158
#9 0x00005555577aa2b8 in std::__insertion_sort<obj_section**, __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(obj_section const*, obj_section const*)> > (__first=0x60c000015940, __last=0x60c0000159c0, __comp=...) at /usr/include/c++/11.1.0/bits/stl_algo.h:1826
#10 0x00005555577a8e26 in std::__final_insertion_sort<obj_section**, __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(obj_section const*, obj_section const*)> > (__first=0x60c000015940, __last=0x60c0000159c0, __comp=...) at /usr/include/c++/11.1.0/bits/stl_algo.h:1871
#11 0x00005555577a723c in std::__sort<obj_section**, __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(obj_section const*, obj_section const*)> > (__first=0x60c000015940, __last=0x60c0000159c0, __comp=...) at /usr/include/c++/11.1.0/bits/stl_algo.h:1957
#12 0x00005555577a50f4 in std::sort<obj_section**, bool (*)(obj_section const*, obj_section const*)> (__first=0x60c000015940, __last=0x60c0000159c0, __comp=0x55555779f4e7 <sort_cmp(obj_section const*, obj_section const*)>) at /usr/include/c++/11.1.0/bits/stl_algo.h:4875
#13 0x00005555577a147e in update_section_map (pspace=0x61200001d2c0, pmap=0x6030000d40b0, pmap_size=0x6030000d40b8) at /home/simark/src/binutils-gdb/gdb/objfiles.c:1165
#14 0x00005555577a19a0 in find_pc_section (pc=0x100003fa0) at /home/simark/src/binutils-gdb/gdb/objfiles.c:1212
#15 0x00005555576dd39e in lookup_minimal_symbol_by_pc_section (pc_in=0x100003fa0, section=0x0, prefer=lookup_msym_prefer::TEXT, previous=0x0) at /home/simark/src/binutils-gdb/gdb/minsyms.c:750
#16 0x00005555576de552 in lookup_minimal_symbol_by_pc (pc=0x100003fa0) at /home/simark/src/binutils-gdb/gdb/minsyms.c:986
#17 0x0000555557d44b54 in find_pc_sect_line (pc=0x100003fa0, section=0x62100016d170, notcurrent=0) at /home/simark/src/binutils-gdb/gdb/symtab.c:3163
#18 0x0000555557d489fa in find_function_start_sal_1 (func_addr=0x100003fa0, section=0x62100016d170, funfirstline=true) at /home/simark/src/binutils-gdb/gdb/symtab.c:3650
#19 0x0000555557d49015 in find_function_start_sal (sym=0x621000191670, funfirstline=true) at /home/simark/src/binutils-gdb/gdb/symtab.c:3706
#20 0x0000555557485283 in symbol_to_sal (result=0x7fffffffbb30, funfirstline=1, sym=0x621000191670) at /home/simark/src/binutils-gdb/gdb/linespec.c:4460
#21 0x00005555574728c2 in convert_linespec_to_sals (state=0x7fffffffc390, ls=0x7fffffffc3e0) at /home/simark/src/binutils-gdb/gdb/linespec.c:2335
#22 0x0000555557475a8e in parse_linespec (parser=0x7fffffffc360, arg=0x60200007a550 "main", match_type=symbol_name_match_type::WILD) at /home/simark/src/binutils-gdb/gdb/linespec.c:2716
#23 0x0000555557479027 in event_location_to_sals (parser=0x7fffffffc360, location=0x606000097be0) at /home/simark/src/binutils-gdb/gdb/linespec.c:3173
#24 0x00005555574798f7 in decode_line_full (location=0x606000097be0, flags=1, search_pspace=0x0, default_symtab=0x0, default_line=0, canonical=0x7fffffffcca0, select_mode=0x0, filter=0x0) at /home/simark/src/binutils-gdb/gdb/linespec.c:3253
#25 0x0000555556b4949f in parse_breakpoint_sals (location=0x606000097be0, canonical=0x7fffffffcca0) at /home/simark/src/binutils-gdb/gdb/breakpoint.c:9134
#26 0x0000555556b6ce95 in create_sals_from_location_default (location=0x606000097be0, canonical=0x7fffffffcca0, type_wanted=bp_breakpoint) at /home/simark/src/binutils-gdb/gdb/breakpoint.c:13819
#27 0x0000555556b645a6 in bkpt_create_sals_from_location (location=0x606000097be0, canonical=0x7fffffffcca0, type_wanted=bp_breakpoint) at /home/simark/src/binutils-gdb/gdb/breakpoint.c:12631
#28 0x0000555556b4badf in create_breakpoint (gdbarch=0x621000152d10, location=0x606000097be0, cond_string=0x0, thread=0, extra_string=0x0, force_condition=false, parse_extra=1, tempflag=0, type_wanted=bp_breakpoint, ignore_count=0, pending_break_support=AUTO_BOOLEAN_AUTO, ops=0x55555bd728a0 <bkpt_breakpoint_ops>, from_tty=0, enabled=1, internal=0, flags=0) at /home/simark/src/binutils-gdb/gdb/breakpoint.c:9410
#29 0x0000555556b4d3b1 in break_command_1 (arg=0x7fffffffe291 "", flag=0, from_tty=0) at /home/simark/src/binutils-gdb/gdb/breakpoint.c:9590
#30 0x0000555556b4dc1b in break_command (arg=0x7fffffffe28d "main", from_tty=0) at /home/simark/src/binutils-gdb/gdb/breakpoint.c:9660
#31 0x0000555556d24ca9 in do_const_cfunc (c=0x61100003a240, args=0x7fffffffe28d "main", from_tty=0) at /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:102
#32 0x0000555556d2fcd3 in cmd_func (cmd=0x61100003a240, args=0x7fffffffe28d "main", from_tty=0) at /home/simark/src/binutils-gdb/gdb/cli/cli-decode.c:2160
#33 0x0000555557e84e93 in execute_command (p=0x7fffffffe290 "n", from_tty=0) at /home/simark/src/binutils-gdb/gdb/top.c:674
#34 0x00005555575a9933 in catch_command_errors (command=0x555557e84043 <execute_command(char const*, int)>, arg=0x7fffffffe28b "b main", from_tty=0, do_bp_actions=true) at /home/simark/src/binutils-gdb/gdb/main.c:523
#35 0x00005555575a9fdb in execute_cmdargs (cmdarg_vec=0x7fffffffd910, file_type=CMDARG_FILE, cmd_type=CMDARG_COMMAND, ret=0x7fffffffd5b0) at /home/simark/src/binutils-gdb/gdb/main.c:618
#36 0x00005555575ad48a in captured_main_1 (context=0x7fffffffdd00) at /home/simark/src/binutils-gdb/gdb/main.c:1322
#37 0x00005555575ada9c in captured_main (data=0x7fffffffdd00) at /home/simark/src/binutils-gdb/gdb/main.c:1343
#38 0x00005555575adb31 in gdb_main (args=0x7fffffffdd00) at /home/simark/src/binutils-gdb/gdb/main.c:1368
#39 0x000055555681e179 in main (argc=8, argv=0x7fffffffde78) at /home/simark/src/binutils-gdb/gdb/gdb.c:32
The section being dealt with at that moment is the special *COM*
section:
(top-gdb) p section.name
$1 = 0x55555a1bbe60 "*COM*"
(top-gdb) p section
$2 = (bfd_section *) 0x55555bbe4ac0 <_bfd_std_section>
I'm not too sure what this section is for, but this is one of four
special BFD sections that GDB puts after the regular sections in the
objfile::sections and objfile::section_offsets lists. You can check
gdb_bfd_section_index to see how they are handled.
gdb_bfd_count_sections returns "+ 4" to account for those sections.
The problem is that macho_symfile_offsets uses bfd_count_sections
instead of gdb_bfd_count_sections when allocating the
objfile::section_offsets vector. The vector will therefore contain,
say, 13 elements instead of 17. When trying to access the section
offset of the *COM* section, the first after the regular sections, we
access section_offsets[13], which is out of bounds.
Fix that by using gdb_bfd_count_sections instead of bfd_count_sections.
I'm fairly confident that this is correct, as this is what
default_symfile_offsets does.
With this patch, the command shown above terminates normally:
$ ./gdb -nx --data-directory=data-directory -q repro/test -ex "b main" -batch
Breakpoint 1 at 0x100003fad: file test.c, line 2.
[1] https://sourceware.org/bugzilla/show_bug.cgi?id=28017
gdb/ChangeLog:
PR gdb/28017
* machoread.c (macho_symfile_offsets): Use
gdb_bfd_count_sections to allocate objfile::section_offsets.
Change-Id: Ic3a56f46f7232e9f24581f8255fc1ab981935450
Simon Marchi [Mon, 28 Jun 2021 19:28:26 +0000 (15:28 -0400)]
gdb: convert obj_section macros to methods
Convert these three macros to methods of obj_section. The problem fixed
by the following patch is caused by an out of bound access of the
objfile::section_offsets vector. Since this is deep in macros, we don't
get a clear backtrace and it's difficult to debug. Changing that to
methods means we can step in them and break on them.
Because their implementation requires knowing about struct objfile, move
struct obj_section below struct objfile in objfiles.h.
The obj_section_offset was used in one place as an lvalue to set
offsets, in machoread.c. Replace that with a set_offset method.
Add the objfile::section_offset and objfile::set_section_offset methods
to improve encapsulation (reduce other objects poking into struct
objfile's internals).
gdb/ChangeLog:
* objfiles.h (struct obj_section): Move down.
<offset, set_offset, addr, endaddr>: New.
(obj_section_offset, obj_section_addr, obj_section_endaddr),
replace all users to use obj_section methods.
(struct objfile) <section_offset, set_section_offset>: New.
Change-Id: I97e8fcae93ab2353fbdadcb4a5ec10d7949a7334
Simon Marchi [Mon, 28 Jun 2021 19:27:21 +0000 (15:27 -0400)]
gdb: add .flake8 file
Add a .flake8 file, which is used to set default options to the flake8
Python linter. Use it to disable these two kinds of diagnostics, which
we don't care about since formatting is handled by black. This reduces
the amount of noise when running flake8 on Python files.
./python/lib/gdb/function/caller_is.py:30:80: E501 line too long (81 > 79 characters)
./python/lib/gdb/command/frame_filters.py:468:17: W503 line break before binary operator
gdb/ChangeLog:
* .flake8: New.
Change-Id: I2b41379fdd1f6e8bf2a784d55a10b406e4d1c828
Luis Machado [Fri, 14 May 2021 14:34:06 +0000 (11:34 -0300)]
Sanitize the address before working with allocation tags
Remove the logical tag/top byte from the address whenever we have to work with
allocation tags.
gdb/ChangeLog:
2021-06-28 Luis Machado <luis.machado@linaro.org>
* aarch64-linux-tdep.c (aarch64_linux_memtag_matches_p): Remove the top
byte.
(aarch64_linux_set_memtags): Likewise.
(aarch64_linux_get_memtag): Likewise.
(aarch64_linux_report_signal_info): Likewise.
Luis Machado [Thu, 24 Jun 2021 16:06:20 +0000 (13:06 -0300)]
Fix FFR register size for core files.
The FFR register has a size of VL bits, not 32 bits.
This causes issues when writing core files with the gcore command and when
reading them. The FFR register sometimes shows up with garbage data.
gdb/ChangeLog:
2021-06-28 Luis Machado <luis.machado@linaro.org>
* aarch64-linux-tdep.c
(aarch64_linux_iterate_over_regset_sections): Fix FFR register size.
Luis Machado [Wed, 23 Jun 2021 17:27:14 +0000 (14:27 -0300)]
Fix tag_ctl register size in the core file.
This register should be 64 bits in size, but the current code only saves
32 bits. This is due to an early assumption that tag_ctl would be 32 bits
in size.
gdb/ChangeLog:
2021-06-28 Luis Machado <luis.machado@linaro.org>
* aarch64-linux-tdep.c
(aarch64_linux_iterate_over_regset_sections): Update tag_ctl register
size.
* aarch64-linux-tdep.h (AARCH64_LINUX_SIZEOF_MTE_REGSET): Set to
8 and update comments.
Simon Marchi [Mon, 28 Jun 2021 15:49:22 +0000 (11:49 -0400)]
gdb: remove gdbarch_info_init
While reviewing another patch, I realized that gdbarch_info_init could
easily be removed in favor of initializing gdbarch_info fields directly
in the struct declaration. The only odd part is the union. I don't
know if it's actually important for it to be zero-initialized, but I
presume it is. I added a constructor to gdbarch_info to take care of
that. A proper solution would be to use std::variant. Or, these could
also be separate fields, the little extra space required wouldn't
matter.
gdb/ChangeLog:
* gdbarch.sh (struct gdbarch_info): Initialize fields, add
constructor.
* gdbarch.h: Re-generate.
* arch-utils.h (gdbarch_info_init): Remove, delete all usages.
* arch-utils.c (gdbarch_info_init): Remove.
Change-Id: I7502e08fe0f278d84eef1667a072e8a97bda5ab5
Simon Marchi [Mon, 28 Jun 2021 15:49:22 +0000 (11:49 -0400)]
gdb: remove gdbarch_info::tdep_info
This field is not actually used, remove it.
gdb/ChangeLog:
* gdbarch.sh (struct gdbarch_info) <tdep_info>: Remove.
(gdbarch_find_by_info): Remove print.
* gdbarch.c, gdbarch.h: Re-generate.
Change-Id: I00af4681b8e1a27727441cbadc3827f5914bd8eb
Andrew Burgess [Mon, 7 Jun 2021 09:18:47 +0000 (10:18 +0100)]
gdb/remote: Use true/false instead of 1/0
The remote_state::starting_up member variable is already of type bool,
but in some places we still write to it using 1 and 0. This commit
just updates things to use true and false.
There should be no user visible change after this commit.
gdb/ChangeLog:
* remote.c (remote_target::start_remote): Set 'starting_up' using
boolean values instead of integers.
Mike Frysinger [Sun, 27 Jun 2021 03:29:17 +0000 (23:29 -0400)]
sim: bpf: enable -Werror usage
Now that all bpf warnings have been cleaned up, turn on -Werror.
Mike Frysinger [Mon, 28 Jun 2021 01:35:17 +0000 (21:35 -0400)]
sim: bpf: fix printf warnings on 32-bit systems
Use PRI macros to display 64-bit types instead of assuming long is
a 64-bit type itself.
Mike Frysinger [Sun, 27 Jun 2021 03:17:59 +0000 (23:17 -0400)]
sim: cgen: delete unused record_trace_results functions
Since there are no callers of this anywhere, nor is the function
implemented by anyone, drop it across the board to cleanup warnings.
Bhuvanendra Kumar N [Mon, 28 Jun 2021 05:21:57 +0000 (10:51 +0530)]
gdb/fortran: Add type info of formal parameter for clang.
Additional compiler generated formal parameter exist with clang and type
information for the same is added accordingly. Also few kind parameter
printing are removed which is not default for clang.
Note: More details about this kind parameter omission while printing can
be found with similar patch
commit
0a709cba00d36d490482d0e8673e323ac1e897a6
Author Alok Kumar Sharma (alokkumar.sharma@amd.com)
gdb/testsuite/ChangeLog:
* gdb.fortran/ptype-on-functions.exp: Add type info of formal
parameter for clang. Also removed the kind parameter for clang.
Mike Frysinger [Sun, 27 Jun 2021 04:05:10 +0000 (00:05 -0400)]
sim: frv: add missing const type
Mike Frysinger [Sun, 27 Jun 2021 04:03:32 +0000 (00:03 -0400)]
sim: frv: fix engine hook
This hook doesn't return a value, so don't define it to 0 to avoid
the compiler warning about it not being used.
Mike Frysinger [Sun, 27 Jun 2021 04:02:52 +0000 (00:02 -0400)]
sim: frv: fix up various missing prototype warnings
Some of these were missing includes, some were unused funcs we can
cleanup, and some were missing prototypes for use in other files.
Mike Frysinger [Sun, 27 Jun 2021 04:02:11 +0000 (00:02 -0400)]
sim: frv: fix some printf type mismatch warnings
The %p usage was a real bug that would probably cause a crash.
Mike Frysinger [Sun, 27 Jun 2021 04:01:39 +0000 (00:01 -0400)]
sim: frv: fix uninitialized variable warning
This variable isn't set anywhere, so pass down NULL_CIA to indicate
we don't have a pc to pass.
Mike Frysinger [Sun, 27 Jun 2021 04:00:57 +0000 (00:00 -0400)]
sim: frv: fix return type for post_wait_for funcs
These functions never return anything, so change the int return type
to void to fix a bunch of compiler warnings about missing return.
Mike Frysinger [Sun, 27 Jun 2021 03:59:03 +0000 (23:59 -0400)]
sim: frv: fix ambiguous else compiler warnings
Add explicit braces to if bodies when the body is another if/else
to fix a bunch of compiler warnings.
GDB Administrator [Mon, 28 Jun 2021 00:00:11 +0000 (00:00 +0000)]
Automatic date update in version.in
Mike Frysinger [Sun, 27 Jun 2021 03:28:25 +0000 (23:28 -0400)]
sim: bpf/cris: include cgen-mem in decoders
These arches use cgen memory functions, so make sure to include the
header in the modules.
Mike Frysinger [Sun, 27 Jun 2021 03:18:40 +0000 (23:18 -0400)]
sim: bpf: include more local headers & fix broken funcs
Various files were not including the relevant headers, or some funcs
were missing prototypes entirely, leading to mismatch between the
actual definition of the functions. Add includes to a few places and
fix the broken functions that are uncovered as a result. Fixing some
compile warnings (e.g. missing prototypes) often find real bugs.
Mike Frysinger [Sun, 27 Jun 2021 03:11:48 +0000 (23:11 -0400)]
sim: cgen: suppress trace non-literal printf warning
The cgen trace macros are a bit ugly in that they specify a series of
format strings & arguments in a single call. This means we pass a
non-literal string to printf and the compiler warns about it. Use
the diagnostic macros to suppress that in this one place.
Mike Frysinger [Sun, 27 Jun 2021 03:03:53 +0000 (23:03 -0400)]
sim: cgen: add asserts to fix unused engine warnings
If the user passed in values outside the range of [0, MAX_NR_PROCESSORS),
it would cause the code to access out-of-bind engine function pointers.
Add some asserts to catch that and to fix the related compiler warnings.
Mike Frysinger [Sun, 27 Jun 2021 03:02:53 +0000 (23:02 -0400)]
sim: cgen: add printf attributes in a few more calls
This helps the compiler process calls to these functions and emit
warnings about mismatched format arguments.
Mike Frysinger [Sun, 27 Jun 2021 02:55:53 +0000 (22:55 -0400)]
sim: cgen: constify trace strings
Shouldn't be any functional changes here.
Mike Frysinger [Sun, 27 Jun 2021 02:29:35 +0000 (22:29 -0400)]
sim: cgen: always leverage the mem prototypes
This fixes missing prototype warnings, and guarantees the prototypes
stay in sync with the function definitions. One of the macros had
fallen out by declaring the wrong return type.
Mike Frysinger [Sun, 27 Jun 2021 02:09:17 +0000 (22:09 -0400)]
sim: cgen: always leverage the ops prototypes
This fixes missing prototype warnings, and guarantees the prototypes
stay in sync with the function definitions.
Mike Frysinger [Sun, 27 Jun 2021 02:07:04 +0000 (22:07 -0400)]
sim: cgen: sync prototypes with implementation
These prototype blocks are not normally used, so they've fallen out
of sync with the actual function definitions. Resync them all.
Mike Frysinger [Sun, 27 Jun 2021 02:05:04 +0000 (22:05 -0400)]
sim: bpf: add explicit casts when using explicit formats
Since the value variable usually has an incompatible type for the wide
variety of types it is printed as, add explicit casts to them all.
Mike Frysinger [Sun, 27 Jun 2021 02:03:14 +0000 (22:03 -0400)]
sim: bpf: fix mixed decls & code warnings (and style)
Mike Frysinger [Sat, 26 Jun 2021 14:49:32 +0000 (10:49 -0400)]
sim: erc32: merge with common configure script
Move the unique library tests to the common code so we can delete
the erc32 configure logic entirely.
Mike Frysinger [Sat, 26 Jun 2021 14:43:27 +0000 (10:43 -0400)]
sim: bfin: move pkg-config & SDL checks to common code
This reduces the unique logic in bfin/configure to make it easier to
(eventually) unify it entirely.
GDB Administrator [Sun, 27 Jun 2021 00:00:13 +0000 (00:00 +0000)]
Automatic date update in version.in
Simon Marchi [Sat, 26 Jun 2021 01:38:20 +0000 (21:38 -0400)]
gdb/guile: use return values of add_setshow functions in add_setshow_generic
Use the set_show_commands objects returned by the add_setshow functions
in add_setshow_generic. This lets us avoid looking up the commands
after creating them, instead using the return objects directly.
Make add_setshow_generic return a set_show_commands object, which is a
bit nicer than returning both commands by parameter.
Finally, store using that object in param_smob.
Equivalent of
7bd22f56a3cf ("gdb/python: use return values of
add_setshow functions in add_setshow_generic"), but for guile.
gdb/ChangeLog:
* guile/scm-param.c (struct param_smob) <set_command,
show_command>: Remove.
<commands>: New.
(pascm_is_valid): Adjust.
(add_setshow_generic): Use return values of add_setshow
functions, return a set_show_commands.
(gdbscm_register_parameter_x): Adjust.
Change-Id: I18ed9e7dd5646529491c86749a5cb20763acd1f0
Simon Marchi [Sat, 26 Jun 2021 01:38:25 +0000 (21:38 -0400)]
gdb: remove context parameter from add_setshow_enum_cmd
I propose removing the context parameter from add_setshow_enum_cmd. It
was useful before add_setshow_enum_cmd returned both created commands,
as the caller couldn't easily set the context itself. But now, I think
it's fine to just let the caller do it.
gdb/ChangeLog:
* command.h (add_setshow_enum_cmd): Remove context parameter.
* cli/cli-decode.c (add_setshow_enum_cmd): Likewise, and don't
set context.
* cli/cli-style.c (cli_style_option::add_setshow_commands): Set
context here.
Change-Id: I377c4e6820ec9d5069492ed28f4cba342ce1336e
Simon Marchi [Sat, 26 Jun 2021 01:38:51 +0000 (21:38 -0400)]
gdb: add assert in cmd_list_element::set_context
If something tries to set a context pointer on a cmd_list_element and
m_context is not nullptr, it's likely that two parts of the code are
trying to set different contexts, and one will overwrite the other.
This is almost guaranteed to lead to bad behavior or a crash, as one of
the spots will not be using the data it expects. This happened to me
during development, so I think having this assert would be useful to
catch this problem earlier.
gdb/ChangeLog:
* cli/cli-decode.h (struct cmd_list_element) <set_context>: Add
assert.
Change-Id: I1f2e9fda1bf2bec1b732c9b90e7d7910a97f2ac6
Simon Marchi [Sat, 26 Jun 2021 01:35:40 +0000 (21:35 -0400)]
gdb: add context getter/setter to cmd_list_element
Straightforward replacement of get_cmd_context / set_cmd_context with
cmd_list_element methods.
gdb/ChangeLog:
* cli/cli-decode.h (struct cmd_list_element) <set_context,
context>: New.
<context>: Rename to...
<m_context>: ... this.
* cli/cli-decode.c (set_cmd_context, get_cmd_context): Remove.
* command.h (set_cmd_context, get_cmd_context): Remove, use
cmd_list_element::set_context and cmd_list_element::context
everywhere instead.
Change-Id: I5016b0079014e3f17d1aa449ada7954473bf2b5d
GDB Administrator [Sat, 26 Jun 2021 00:00:10 +0000 (00:00 +0000)]
Automatic date update in version.in
Andrew Burgess [Tue, 18 May 2021 13:27:25 +0000 (14:27 +0100)]
gdb: change info sources to group results by objfile
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.
Andrew Burgess [Tue, 18 May 2021 13:18:22 +0000 (14:18 +0100)]
gdb/mi: add new --group-by-objfile flag for -file-list-exec-source-files
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.
Andrew Burgess [Tue, 18 May 2021 12:46:19 +0000 (13:46 +0100)]
gdb/mi: add regexp filtering to -file-list-exec-source-files
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.
Andrew Burgess [Thu, 1 Apr 2021 13:51:24 +0000 (14:51 +0100)]
gdb: make struct output_source_filename_data more C++ like
In a future commit I'm going to be making some changes to the 'info
sources' command. While looking at the code I noticed that things
could be improved by making struct output_source_filename_data more
C++ like (private member variables, and more member functions).
That's what this commit does.
The 'info sources' filename filtering is split out into a separate
class in this commit. In a future commit this new filter
class (info_sources_filter) will move into the header file and be used
from the MI code.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* symtab.c (struct info_sources_filter): New.
(info_sources_filter::info_sources_filter): New function.
(info_sources_filter::matches): New function.
(info_sources_filter::print): New function.
(struct filename_partial_match_opts): Moved to later in the file
and update the comment.
(struct output_source_filename_data)
<output_source_filename_data>: New constructor. <regexp>: Delete,
this is now in info_sources_filter. <c_regexp>: Delete, this is
now in info_sources_filter. <reset_output>: New member function.
<filename_seen_cache>: Rename to m_filename_seen_cache, change
from being a pointer, to being an actual object. <first>: Rename
to m_first. <print_header>: New member function. <partial_match>:
Delete.
(output_source_filename_data::output): Update now
m_filename_seen_cache is no longer a pointer, and for other member
variable name changes. Add a header comment.
(print_info_sources_header): Renamed to...
(output_source_filename_data::print_header): ...this. Update now
it's a member function and to take account of member variable
renaming.
(info_sources_command): Add a header comment, delete stack local
filename_seen_cache, initialization of output_source_filename_data
is now done by the constructor. Call print_header member function
instead of print_info_sources_header, call reset_output member
function instead of manually performing the reset.
Andrew Burgess [Thu, 15 Apr 2021 10:29:55 +0000 (11:29 +0100)]
gdb: add new function quick_symbol_functions::has_unexpanded_symbols
Adds a new function to the quick_symbol_functions API to let us know
if there are any unexpanded symbols. This functionality is required
by a later commit. After this commit the functionality is unused, and
untested.
The new function objfile::has_unexpanded_symtabs is added to the
symfile-debug.c file which is a little strange, but this
is (currently) where many of the other objfile::* functions (that call
onto the quick_symbol_functions) are defined, so I'm reluctant to
break this pattern.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* dwarf2/read.c (struct dwarf2_base_index_functions)
<has_unexpanded_symtabs>: Declare.
(dwarf2_base_index_functions::has_unexpanded_symtabs): Define new
function.
* objfiles.h (struct objfile) <has_unexpanded_symtabs>: Declare.
* psympriv.h (struct psymbol_functions) <has_unexpanded_symtabs>:
Declare.
* psymtab.c (psymbol_functions::has_unexpanded_symtabs): Define
new function.
* quick-symbol.h (struct quick_symbol_functions)
<has_unexpanded_symtabs>: Declare.
* symfile-debug.c (objfile::has_unexpanded_symtabs): Define new
function.
Andrew Burgess [Wed, 23 Jun 2021 21:55:16 +0000 (22:55 +0100)]
gdb: fix invalid arg coercion when calling static member functions
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.
Andrew Burgess [Tue, 22 Jun 2021 18:27:53 +0000 (19:27 +0100)]
gdb: use gdb::optional instead of passing a pointer to gdb::array_view
Following on from the previous commit, this commit changes the API of
value_struct_elt to take gdb::optional<gdb::array_view<value *>>
instead of a pointer to the gdb::array_view.
This makes the optional nature of the array_view parameter explicit.
This commit is purely a refactoring commit, there should be no user
visible change after this commit.
I have deliberately kept this refactor separate from the previous two
commits as this is a more extensive change, and I'm not 100% sure that
using gdb::optional for the parameter type, instead of a pointer, is
going to be to everyone's taste. If there's push back on this patch
then this one can be dropped from the series.
gdb/ChangeLog:
* ada-lang.c (desc_bounds): Use '{}' instead of NULL to indicate
an empty gdb::optional when calling value_struct_elt.
(desc_data): Likewise.
(desc_one_bound): Likewise.
* eval.c (structop_base_operation::evaluate_funcall): Pass
gdb::array_view, not a gdb::array_view* to value_struct_elt.
(eval_op_structop_struct): Use '{}' instead of NULL to indicate
an empty gdb::optional when calling value_struct_elt.
(eval_op_structop_ptr): Likewise.
* f-lang.c (fortran_structop_operation::evaluate): Likewise.
* guile/scm-value.c (gdbscm_value_field): Likewise.
* m2-lang.c (eval_op_m2_high): Likewise.
(eval_op_m2_subscript): Likewise.
* opencl-lang.c (opencl_structop_operation::evaluate): Likewise.
* python/py-value.c (valpy_getitem): Likewise.
* rust-lang.c (rust_val_print_str): Likewise.
(rust_range): Likewise.
(rust_subscript): Likewise.
(eval_op_rust_structop): Likewise.
(rust_aggregate_operation::evaluate): Likewise.
* valarith.c (value_user_defined_op): Likewise.
* valops.c (search_struct_method): Change parameter type, update
function body accordingly, and update header comment.
(value_struct_elt): Change parameter type, update function body
accordingly.
* value.h (value_struct_elt): Update declaration.
Andrew Burgess [Tue, 22 Jun 2021 09:17:53 +0000 (10:17 +0100)]
gdb: replace NULL terminated array with array_view
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+=.
Andrew Burgess [Mon, 21 Jun 2021 22:33:11 +0000 (23:33 +0100)]
gdb: fix regression in evaluate_funcall for non C++ like cases
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.
Tom Tromey [Fri, 25 Jun 2021 18:34:41 +0000 (12:34 -0600)]
Change how .debug_aranges padding is skipped
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.
Tom Tromey [Fri, 25 Jun 2021 18:23:04 +0000 (12:23 -0600)]
Remove dwarf2_cu::language
dwarf2_cu has a 'language' value, but dwarf2_per_cu_data also holds a
value of this same type. There doesn't seem to be any reason to keep
two copies of this value. This patch removes the field from
dwarf2_cu, and arranges to set the value in the per-CU object instead.
Note that the value must still be set when expanding the full CU.
This is needed because the CUs will not be scanned when a DWARF index
is in use.
gdb/ChangeLog
2021-06-25 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (process_psymtab_comp_unit): Don't set 'lang'.
(scan_partial_symbols, partial_die_parent_scope)
(add_partial_symbol, add_partial_subprogram)
(compute_delayed_physnames, rust_union_quirks)
(process_full_comp_unit, process_full_type_unit)
(process_imported_unit_die, process_die, dw2_linkage_name)
(dwarf2_compute_name, dwarf2_physname, read_import_statement)
(read_file_scope, queue_and_load_dwo_tu, read_func_scope)
(read_variable, dwarf2_get_subprogram_pc_bounds)
(dwarf2_attach_fields_to_type, dwarf2_add_member_fn)
(dwarf2_attach_fn_fields_to_type)
(quirk_ada_thick_pointer_struct, read_structure_type)
(handle_struct_member_die, process_structure_scope)
(read_array_type, read_array_order, prototyped_function_p)
(read_subroutine_type, dwarf2_init_complex_target_type)
(read_base_type, read_subrange_type, read_unspecified_type)
(load_partial_dies, partial_die_info::fixup, set_cu_language)
(new_symbol, need_gnat_info, determine_prefix, typename_concat)
(dwarf2_canonicalize_name, follow_die_offset)
(prepare_one_comp_unit): Update.
* dwarf2/cu.c (dwarf2_cu::start_symtab): Update.
Tom Tromey [Fri, 25 Jun 2021 18:23:04 +0000 (12:23 -0600)]
Consolidate CU language setting
The DWARF reader currently sets the CU's language in two different
spots. It is primarily done in prepare_one_comp_unit, but
read_file_scope also checks the producer and may change the language
based on the result.
This patch consolidates all language-setting into
prepare_one_comp_unit. set_cu_language is renamed and changed not to
set language_defn; instead that is done in prepare_one_comp_unit after
the correct language enum value is chosen.
This fixes a minor latent bug, which is that read_file_scope could set
the language enum value to language_opencl, but then neglected to
reset language_defn in this case.
gdb/ChangeLog
2021-06-25 Tom Tromey <tom@tromey.com>
* dwarf2/read.c (read_file_scope): Don't call set_cu_language.
(dwarf_lang_to_enum_language): Rename from set_cu_language. Don't
set language_defn. Handle DW_LANG_OpenCL.
(prepare_one_comp_unit): Check producer and set language_defn.
Andrew Burgess [Wed, 5 May 2021 14:26:28 +0000 (15:26 +0100)]
gdb/python: allow for catchpoint type breakpoints in python
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.
Andrew Burgess [Wed, 5 May 2021 15:53:09 +0000 (16:53 +0100)]
gdb/guile: allow for catchpoint type breakpoints in guile
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.
Andrew Burgess [Mon, 10 May 2021 08:53:52 +0000 (09:53 +0100)]
gdb/guile: improve the errors when creating breakpoints
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.
Carl Love [Wed, 16 Jun 2021 17:07:39 +0000 (12:07 -0500)]
Add ISA 3.1 check to powerpc-plxv-norel.exp
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.
Tom Tromey [Fri, 25 Jun 2021 14:40:37 +0000 (08:40 -0600)]
Use gdb::function_view in addrmap_foreach
While working on the DWARF psymtab replacement, I needed
addrmap_foreach to accept a gdb::function_view. This seemed like a
worthwhile change on its own, so I've written it separately for
submission.
Regression tested on x86-64 Fedora 32.
gdb/ChangeLog
2021-06-25 Tom Tromey <tom@tromey.com>
* dwarf2/index-write.c (struct addrmap_index_data): Add
initializers.
<operator()>: Declare.
(addrmap_index_data::operator()): Rename from
add_address_entry_worker. Remove 'datap' parameter.
(write_address_map): Update.
* psymtab.c (struct dump_psymtab_addrmap_data): Remove
(dump_psymtab_addrmap_1): Remove 'data' parameter, add other
parameters.
(dump_psymtab_addrmap): Update.
* addrmap.c (struct addrmap_funcs) <foreach>: Remove 'data'
parameter.
(addrmap_foreach, addrmap_fixed_foreach): Likewise.
(struct mutable_foreach_data): Remove.
(addrmap_mutable_foreach_worker): Update.
(addrmap_mutable_foreach): Remove 'data' parameter.
* addrmap.h (addrmap_foreach_fn): Use gdb::function_view.
(addrmap_foreach): Remove 'data' parameter.
Tom Tromey [Fri, 25 Jun 2021 14:01:15 +0000 (08:01 -0600)]
Decode Ada types in Python layer
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.
Tom Tromey [Fri, 25 Jun 2021 14:01:15 +0000 (08:01 -0600)]
Add non-wrapping mode to ada_decode
When ada_decode encounters a name that it cannot decode, it simply
wraps it in <...>, which is used elsewhere in the Ada code to indicate
that a verbatim match should be done.
A subequent patch needed the ability to suppress this wrapping, so
this patch adds a new mode to ada_decode.
2021-06-25 Tom Tromey <tromey@adacore.com>
* ada-lang.c (ada_decode): Add wrap parameter.
* ada-lang.h (ada_decode): Add wrap parameter.