Commit Graph

106283 Commits

Author SHA1 Message Date
Mike Frysinger
e106fc358c sim: cgen: invert sim_state storage for cgen ports 2021-05-17 00:46:32 -04:00
Mike Frysinger
85d93de3d8 sim: bfin: invert sim_state storage 2021-05-17 00:43:45 -04:00
Mike Frysinger
383861bd08 sim: invert sim_state storage
Currently all ports have to declare sim_state themselves in their
sim-main.h and then embed the common sim_state_base & sim_cpu in it.
This dynamic makes it impossible to share common object code among
multiple ports because the core data structure is always different.

Let's invert this relationship: common code declares sim_state, and
if the port actually needs state on a per-instance basis, it can use
the new arch_data field for it.  Most ports don't actually use it,
so they don't need to declare anything at all.

This is the first in a series of changes: it adds a define to select
between the old & new layouts, then converts all the ports that don't
need custom state over to the new layout.
2021-05-17 00:42:55 -04:00
Mike Frysinger
92bc001e1f sim: install library header files
We install libsim.a for people to link against, but haven't been
installing the header files to for its API.  Export them!
2021-05-16 22:42:02 -04:00
Mike Frysinger
6df01ab8ab sim: switch config.h usage to defs.h
The defs.h header will take care of including the various config.h
headers.  For now, it's just config.h, but we'll add more when we
integrate gnulib in.

This header should be used instead of config.h, and should be the
first include in every .c file.  We won't rely on the old behavior
where we expected files to include the port's sim-main.h which then
includes the common sim-basics.h which then includes config.h.  We
have a ton of code that includes things before sim-main.h, and it
sometimes needs to be that way.  Creating a dedicated header avoids
the ordering mess and implicit inclusion that shows up otherwise.
2021-05-16 22:38:41 -04:00
GDB Administrator
681eb80f12 Automatic date update in version.in 2021-05-17 00:00:35 +00:00
Weimin Pan
ea11a98dbd CTF: handle forward reference type
The problems can be illustrated, with any program, below:

(gdb) print main
$1 = {main} 0x0

The return type was incorrectly set in read_func_kind_type, with
the name of the function, which leads c_type_print_base_1 to print
it. In addition, the address of a new function needs to be set with
that info in its minimal symtab entry, when the new function is added.

After the fix:

(gdb) print main
$1 = {int ()} 0x4004b7 <main>

A new test, gdb.ctf/funcreturn.exp, is added to the testsuite.

gdb/ChangeLog:
        * ctfread.c (new_symbol): Set function address.
        (read_func_kind_type): Remove incorrect type name setting.
        Don't copy name returned from ctf_type_ame_raw throughout file.

gdb/testsuite/ChangeLog:
        * gdb.ctf/funcreturn.exp: New file.
        * gdb.ctf/whatis.c: Copy from gdb.base.
2021-05-16 18:24:14 -04:00
Mike Frysinger
79633c125e sim: riscv: move __int128 check to configure 2021-05-16 00:04:17 -04:00
GDB Administrator
246ee38501 Automatic date update in version.in 2021-05-16 00:00:34 +00:00
Mike Frysinger
be2bc30f9c sim: ppc: clean up various warnings
A random grab bag of minor fixes to enable -Werror for this port.

Cast address vars to long when the format was using %l.
Use %zu with sizeof operations.
Add const to a bunch of strings.
Trim unused variables.
Fix sizeof call to calculate target storage and not the pointer itself.
2021-05-15 11:00:00 -04:00
Mike Frysinger
c5a2e0123b sim: switch to libiberty environ.h
Drop our compat code and assume environ exists to simplify.
2021-05-15 10:59:19 -04:00
Alan Modra
b9c0d70312 process_cu_tu_index
* dwarf.c (process_cu_tu_index): Avoid pointer UB.  Use _mul_overflow.
	Delete dead code.
2021-05-15 15:40:51 +09:30
Alan Modra
bb19bf1269 display_gdb_index
* dwarf.c (display_gdb_index): Avoid pointer UB and overflow in
	length calculations.
2021-05-15 15:38:58 +09:30
Alan Modra
d7870f6304 display_debug_names
* dwarf.c (display_debug_names): Complain when header length is
	too small.  Avoid pointer UB.  Sanity check augmentation string,
	CU table, TU table and foreign TU table sizes.
2021-05-15 15:36:53 +09:30
Alan Modra
5897a38984 display_debug_frames
* dwarf.c (display_debug_frames): Delete initial_length_size.
	Avoid pointer UB.  Constrain data reads to length given in header.
	Sanity check cie header length.  Only skip up to next FDE on
	finding augmentation data too long.
2021-05-15 15:29:36 +09:30
Alan Modra
c93c4a8540 read_cie
* dwarf.c (read_cie): Add more sanity checks to ensure data
	pointer is not bumped past end.
2021-05-15 15:23:53 +09:30
Alan Modra
b495154607 display_debug_ranges
* dwarf.c (display_debug_ranges): Delete initial_length_size.
	Correct fallback size calculated on finding a reloc.  Constrain
	data reads to length given in header.  Avoid pointer UB.
2021-05-15 15:22:25 +09:30
Alan Modra
669f463dbc display_debug_rnglists_list
* dwarf.c (display_debug_rnglists_list): Avoid pointer UB.
2021-05-15 15:17:46 +09:30
Alan Modra
5250d2f0a5 display_debug_str_offsets
* dwarf.c (display_debug_str_offsets): Constrain reads to length
	given in header.
2021-05-15 15:16:35 +09:30
Alan Modra
6ca0735017 display_debug_aranges
* dwarf.c (display_debug_aranges): Delete initial_length_size.
	Use end_ranges to constrain data reads to header length.  Avoid
	pointer UB.
2021-05-15 15:15:35 +09:30
Alan Modra
7848009791 display_loc_list
* dwarf.c (display_loc_list): Avoid pointer UB.  Correct check
	before reading uleb length.  Warn on excess length.
2021-05-15 15:13:45 +09:30
Alan Modra
b0d461ec37 display_debug_macro
* dwarf.c (display_debug_macro): Print strings that might not
	be zero terminated with %*s.  Don't bump curr if unterminated.
2021-05-15 15:10:29 +09:30
Alan Modra
46d1214d88 get_line_filename_and_dirname
* dwarf.c (get_line_filename_and_dirname): Delete initial_length_size.
	Simplify length sanity check, and check for too small lengths.
	Constrain data reads to header length.  Avoid pointer UB.
2021-05-15 15:09:01 +09:30
Alan Modra
c03df92247 display_debug_macinfo
The existing code went to the bother of using strnlen for scanning but
went wild when printing, and possibly incremented curr past end.

	* dwarf.c (display_debug_macinfo): Print strings that might not
	be zero terminated with %*s.  Don't bump curr if unterminated.
2021-05-15 15:05:29 +09:30
Alan Modra
35b2c89ec8 display_debug_pubnames_worker
* dwarf.c (display_debug_pubnames_worker): Delete initial_length_size.
	Simplify length check.  Constrain reads to length given by header.
2021-05-15 15:01:39 +09:30
Alan Modra
56051e28a3 display_debug_lines_decoded
The directory_table strnlen used the negative of the proper size.  After
fixing that I realised we don't need strnlen here.

	* dwarf.c (display_debug_lines_decoded): Don't use strnlen when
	we have already checked for NUL termination.
2021-05-15 14:57:38 +09:30
Alan Modra
37195e23e7 read_debug_line_header
This patch also better constrains the data read, and removes pointer UB.

	* dwarf.c (read_debug_line_header): Delete initial_length_size.
	Avoid pointer UB.  Keep within length specified by header.
	Delete dead code.
2021-05-15 14:54:05 +09:30
Alan Modra
edba4e4aba process_debug_info
This patch constrains process_debug_info to stay within the data
specified by the CU length rather than allowing access up to the end
of the section.

	* dwarf.c (process_debug_info): Always do the first CU length
	scan for sanity checks.  Remove initial_length_size var and
	instead calculate end_cu.  Use end_cu to limit data reads.
	Delete now dead code checking length.
2021-05-15 14:48:33 +09:30
Alan Modra
ebb1786492 SAFE_BYTE_GET_INTERNAL
We won't want this assert triggering in the next release.

	* dwarf.c (SAFE_BYTE_GET_INTERNAL): Assert only when ENABLE_CHECKING.
2021-05-15 14:38:42 +09:30
Alan Modra
fc5e0925d4 _mul_overflow and get_encoded_value
A sufficiently mad compiler optimiser can take undefined behaviour
according to the C standard as an opportunity to remove code.  Since
"data + size" might be seen to be past the end of an array,
calculating such an expression is UB.

_mul_overflow is infrastructure for later patches.

	* bucomm.h (_mul_overflow): Define.
	* dwarf.c (get_encoded_value): Avoid pointer UB.
2021-05-15 14:36:54 +09:30
Alan Modra
7c96e6120f [GOLD]: Re: Add -Bno-symbolic
PR 27834
	* options.cc (General_options::General_options): Init bsymbolic_.
2021-05-15 14:16:54 +09:30
Tom Tromey
887e71588b Fix Python pretty-printing bug in Rust
An upstream Rust bug notes notes that the Python pretty-printing
feature is broken for values that appear as members of certain types
in Rust.

The bug here is that some of the Rust value-printing code calls
value_print_inner, a method on rust_language.  This bypasses the
common code that calls into Python.

I'm checking this in.

gdb/ChangeLog
2021-05-14  Tom Tromey  <tom@tromey.com>

	* rust-lang.c (rust_language::val_print_struct)
	(rust_language::print_enum): Use common_val_print, not
	value_print_inner.

gdb/testsuite/ChangeLog
2021-05-14  Tom Tromey  <tom@tromey.com>

	* gdb.rust/pp.exp: New file.
	* gdb.rust/pp.py: New file.
	* gdb.rust/pp.rs: New file.
2021-05-14 20:01:12 -06:00
Mike Frysinger
2fbe9507bf sim: callback: convert FS interfaces to 64-bit
Rather than rely on off_t being the right size between the host &
target, have the interface always be 64-bit.  We can figure out if
we need to truncate when actually outputting it to the right target.
2021-05-14 21:16:40 -04:00
Mike Frysinger
00330cd18a sim: callback: convert time interface to 64-bit
PR sim/27705
Rather than rely on time_t being the right size between the host &
target, have the interface always be 64-bit.  We can figure out if
we need to truncate when actually outputting it to the right target.
2021-05-14 21:05:36 -04:00
GDB Administrator
fcf102ba7a Automatic date update in version.in 2021-05-15 00:00:34 +00:00
Fangrui Song
823241a27c gold: Add -Bno-symbolic
gold/
    PR 27834
    * options.h (General_options): Make -Bsymbolic and
    -Bsymbolic-functions special and adjust the help messages. Add
    enum Bsymbolic_kind and -Bno-symbolic.
    * options.cc (General_options): Define parse_Bno_symbolic,
    parse_Bsymbolic_functions, and parse_Bsymbolic.
2021-05-14 15:51:17 -07:00
Bernd Edlinger
f8eec398fb testsuite: Cleanup some temp dirs with gdb-index files
After the gdb test-suite runs there are some files
left in /tmp/tmp*/*.gdb-index, remove those files
and the directory at the end of the test case.

gdb/testsuite:
2021-05-14  Bernd Edlinger  <bernd.edlinger@hotmail.de>

	* gdb.base/index-cache.exp: Cleanup $cache_dir/*.gdb-index and
	remove the directory.
	* gdb.dwarf2/per-bfd-sharing.exp: Likewise.
2021-05-14 17:49:25 +02:00
Tankut Baris Aktemur
55789354fc gdb/python: add a 'connection_num' attribute to Inferior objects
Define a 'connection_num' attribute for Inferior objects.  The
read-only attribute is the ID of the connection of an inferior, as
printed by "info inferiors".  In GDB's internal terminology, that's
the process stratum target of the inferior.  If the inferior has no
target connection, the attribute is None.

gdb/ChangeLog:
2021-05-14  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* python/py-inferior.c (infpy_get_connection_num): New function.
	(inferior_object_getset): Add a new element for 'connection_num'.
	* NEWS: Mention the 'connection_num' attribute of Inferior objects.

gdb/doc/ChangeLog:
2021-05-14  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* python.texi (Inferiors In Python): Mention the 'connection_num'
	attribute.

gdb/testsuite/ChangeLog:
2021-05-14  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* gdb.python/py-inferior.exp: Add test cases for 'connection_num'.
2021-05-14 15:33:23 +02:00
Andrew Burgess
2f63ec5ccc gdb: some int to bool conversion in remote.c
Convert a couple of local variables from int to bool.  There should be
no user visible changes after this commit.

gdb/ChangeLog:

	* remote.c (check_pending_events_prevent_wildcard_vcont): Change
	argument type, update and re-wrap, header comment.
	(remote_target::commit_resumed): Convert any_process_wildcard and
	may_global_wildcard_vcont from int to bool.
2021-05-14 13:39:51 +01:00
Nelson Chu
75f03fa774 RISC-V: Check the overflow for %pcrel_lo addend more strictly.
The %pcrel_lo addend may causes the overflow, and need more than one
%pcrel_hi values.  But there may be only one auipc, shared by those
%pcrel_lo with addends.  However, the existing check method in the
riscv_resolve_pcrel_lo_relocs, may not be able to work for some
special/corner cases.

Consider the testcases pcrel-lo-addend-2b.  Before applying this patch,
I can compile it successfully.  But in fact the addend cause the value
of %pcrel_hi to be different.  This patch try to check the value of
%pcrel_hi directly, to make sure it won't be changed.  Otherwise, linker
will report the following errors,

(.text+0xa): dangerous relocation: %pcrel_lo overflow with an addend,
the value of %pcrel_hi is 0x1000 without any addend, but may be 0x2000
after adding the %pcrel_lo addend

The toolchain regressions, rv64gc-linux/rv64gc-elf/rv32gc-linux/rv32i-elf,
pass expectedly and looks fine.

bfd/
    * elfnn-riscv.c (riscv_resolve_pcrel_lo_relocs): Check the values
    of %pcrel_hi, before and after adding the addend.  Make sure the
    value won't be changed, otherwise, report dangerous error.
ld/
    * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated.
    * testsuite/ld-riscv-elf/pcrel-lo-addend-2a.d: Renamed from
    pcrel-lo-addend-2.
    * testsuite/ld-riscv-elf/pcrel-lo-addend-2a.s: Likewise.
    * testsuite/ld-riscv-elf/pcrel-lo-addend-2b.d: New testcase.
    * testsuite/ld-riscv-elf/pcrel-lo-addend-2b.s: Likewise.
2021-05-14 16:14:00 +08:00
Kent Cheung
ecf25064e8 gdb: fix pretty printing max depth behaviour
The 'print max-depth' feature incorrectly causes GDB to skip printing
the string representation of pretty printed variables if the variable
is stored at a nested depth corresponding to the set max-depth value.
This change ensures that it is always printed before checking whether
the maximum print depth has been reached.

Regression tested with GCC 7.3.0 on x86_64, ppc64le, aarch64.

gdb/ChangeLog:

	* cp-valprint.c (cp_print_value): Replaced duplicate code.
	* guile/scm-pretty-print.c (ppscm_print_children): Check max_depth
	just before printing child values.
	(gdbscm_apply_val_pretty_printer): Don't check max_depth before
	printing string representation.
	* python/py-prettyprint.c (print_children): Check max_depth just
	before printing child values.
	(gdbpy_apply_val_pretty_printer): Don't check max_depth before
	printing string representation.

gdb/testsuite/ChangeLog:

	* gdb.python/py-format-string.c: Added a variable to test.
	* gdb.python/py-format-string.exp: Check string representation is
	printed at appropriate max_depth settings.
	* gdb.python/py-nested-maps.exp: Likewise.
	* gdb.guile/scm-pretty-print.exp: Add additional tests.
2021-05-14 06:51:21 +01:00
Mike Frysinger
64654371d6 sim: callback: inline PTR define
We require C11 now, so no need for these pre-ANSI C hacks.
PTR is simply void*, so use that directly.
2021-05-14 01:23:06 -04:00
Mike Frysinger
7fb6dc36bb sim: callback: use ATTRIBUTE_NORETURN
This define is handled by ansidecl.h, so no need to duplicate effort.
2021-05-14 01:06:53 -04:00
Mike Frysinger
2e4885ee8f sim: callback: always include necessary headers
We use types from these headers, so always include them.
2021-05-14 00:53:56 -04:00
Mike Frysinger
df68e12b3b sim: create header namespace
The gdb/callback.h & gdb/remote-sim.h headers have nothing to do with
gdb and are really definitions for the libsim API under the sim/ tree.
While gdb uses those headers as a client, it's not specific to it.  So
create a new sim/ namespace and move the headers there.
2021-05-14 00:41:05 -04:00
Mike Frysinger
183aaaf72a gdb: lm32: drop unused sim headers
Looks like these were copied & pasted as nothing from them are used.
2021-05-14 00:27:54 -04:00
GDB Administrator
e218e27428 Automatic date update in version.in 2021-05-14 00:00:34 +00:00
Simon Marchi
737358ba1e gdb: maybe unpush target from old inferior in inf_child_target::follow_exec
I realized that with "follow-exec-mode == new", the process target
stayed pushed in the original inferior.  This can cause a small
incoherence:

    $ ./gdb -q -nx --data-directory=data-directory -ex "set follow-exec-mode new" --args execer args-for-execer
    Reading symbols from execer...
    (gdb) r
    Starting program: /home/smarchi/build/binutils-gdb/gdb/execer args-for-execer
    I am execer and my argv[1] is: args-for-execer
    process 3562426 is executing new program: /home/smarchi/build/binutils-gdb/gdb/execee
    [New inferior 2]
    [New process 3562426]
    I am execee and my argv[1] is: arg-for-execee
    [Inferior 2 (process 3562426) exited normally]
    (gdb) info inferiors
      Num  Description       Connection           Executable
      1    <null>            1 (native)           /home/smarchi/build/binutils-gdb/gdb/execer
    * 2    <null>                                 /home/smarchi/build/binutils-gdb/gdb/execee
    (gdb) maintenance print target-stack
    The current target stack is:
      - exec (Local exec file)
      - None (None)
    (gdb) inferior 1
    [Switching to inferior 1 [<null>] (/home/smarchi/build/binutils-gdb/gdb/execer)]
    (gdb) maintenance print target-stack
    The current target stack is:
      - native (Native process)
      - exec (Local exec file)
      - None (None)

On exec, when execution continues into inferior 2, the native target
isn't unpushed from inferior 1.  When inferior 2's execution finishes
normally, inf_child_target::mourn_inferior unpushes the native target,
because the native target has been implicitly opened.

I think that if the native target was implicitly opened, it should be
unpushed from inferior 1, just like it is unpushed from an inferior
whose execution terminate.  This patch implements that.

gdb/ChangeLog:

	* inf-child.h (inf_child_target) <follow_exec>: New.
	* inf-child.c (inf_child_target::follow_exec): New.

Change-Id: I782cc08d73d93a990f4e53611107f68b2cb58af1
2021-05-13 15:29:00 -04:00
Simon Marchi
294c36eb6a gdb: on exec, delegate pushing / unpushing target and adding thread to target_ops::follow_exec
On "exec", some targets need to unpush themselves from the inferior,
and do some bookkeeping, like forgetting the data associated to the
exec'ing inferior.

One such example is the thread-db target.  It does so in
a special case in thread_db_target::wait, just before returning the
TARGET_WAITKIND_EXECD event to its caller.

We have another such case in the context of rocm-gdb [1], where the
"rocm" target is pushed on top of the linux-nat target.  When an exec
happens, we want to unpush the rocm target from the exec'ing inferior to
close some file descriptors that refer to the pre-exec address space and
forget about that inferior.  We then want to push the target on the
inferior in which execution continues, to open the file descriptors for
the post-exec address space.

I think that a good way to address this cleanly is to do all this in the
target_ops::follow_exec implementations.  Make the
process_stratum_target::follow_exec implementation have the default
behavior of pushing itself to the new inferior's target stack (if
execution continues in a new inferior) and add the initial thread.

remote_target::follow_exec is an example of process target that wants to
do a bit more than the default behavior.  So it calls
process_stratum_target::follow_exec first and does the extra work
second.

linux-thread-db (a non-process target) implements follow_exec to do some
bookeeping (forget about that process' data), before handing down the
event down to the process target (which hits
process_stratum_target::follow_exec).

gdb/ChangeLog:

	* target.h (struct target_ops) <follow_exec>: Add ptid_t
	parameter.
	(target_follow_exec): Likewise.
	* target.c (target_follow_exec): Add ptid_t parameter.
	* infrun.c (follow_exec): Adjust call to target_follow_exec,
	don't push target nor create thread.
	* linux-thread-db.c (class thread_db_target) <follow_exec>: New.
	(thread_db_target::wait): Just return on TARGET_WAITKIND_EXECD.
	(thread_db_target::follow_exec): New.
	* remote.c (class remote_target) <follow_exec>: Add ptid_t parameter.
	(remote_target::follow_exec): Call
	process_stratum_target::follow_exec.
	* target-delegates.c: Re-generate.

Change-Id: I3f96d0ba3ea0dde6540b7e1b4d5cdb01635088c8
2021-05-13 15:29:00 -04:00
Simon Marchi
2af87c859f gdb: call target_follow_exec when "set follow-exec-mode" is "same"
target_follow_exec is currently only called in the "follow-exec-mode ==
new" branch of follow_exec, not the "follow-exec-mode == same" branch.
I think it would make sense to call it regardless of the mode to let
targets do some necessary handling.

This is needed in the context of rocm-gdb [1], where a target is pushed
on top of the linux-nat target.  On exec, it needs to do some
bookkeeping, close some file descriptors / handles that were related to
the process pre-exec and open some new ones for the process post-exec.

However, by looking at the only in-tree implementation of
target_ops::follow_exec, remote_target::follow_exec, I found that it
would be useful for the extended-remote target too, to align its
behavior with native debugging (although I think that behavior is not
very user-friendly, see PR 27745 [2]).

Using two programs, one (let's call it "execer") that execs the other
(let's call it "execee"), with native:

    $ ./gdb -q -nx --data-directory=data-directory ./execer
    Reading symbols from ./execer...
    (gdb) r
    Starting program: /home/simark/build/binutils-gdb/gdb/execer
    I am execer
    process 1495622 is executing new program: /home/simark/build/binutils-gdb/gdb/execee
    I am execee
    [Inferior 1 (process 1495622) exited normally]
    (gdb) r
    Starting program: /home/simark/build/binutils-gdb/gdb/execee
    I am execee
    [Inferior 1 (process 1495626) exited normally]

And now with gdbserver (some irrelevant output lines removed for brevity):

    $ ./gdbserver --once --multi :1234
    ...

    $ ./gdb -q -nx --data-directory=data-directory ./execer -ex "set remote exec-file /home/simark/build/binutils-gdb/gdb/execer" -ex "tar ext :1234"
    Reading symbols from ./execer...
    Remote debugging using :1234
    (gdb) r
    Starting program: /home/simark/build/binutils-gdb/gdb/execer
    process 1495724 is executing new program: /home/simark/build/binutils-gdb/gdb/execee
    [Inferior 1 (process 1495724) exited normally]
    (gdb) r
    `target:/home/simark/build/binutils-gdb/gdb/execee' has disappeared; keeping its symbols.
    Starting program: target:/home/simark/build/binutils-gdb/gdb/execee
    warning: Build ID mismatch between current exec-file target:/home/simark/build/binutils-gdb/gdb/execee
    and automatically determined exec-file target:/home/simark/build/binutils-gdb/gdb/execer
    exec-file-mismatch handling is currently "ask"
    Reading /home/simark/build/binutils-gdb/gdb/execer from remote target...
    Load new symbol table from "target:/home/simark/build/binutils-gdb/gdb/execer"? (y or n)

When handling the exec, GDB updates the exec-file of the inferior to be
the execee.  This means that a subsequent "run" will run the execee, not
the original executable (execer).

remote_target::follow_exec is meant to update the "remote exec-file",
which is the file on the remote system that will be executed if you
"run" the inferior, to the execee as well.  However, this is not called
when follow-exec-mode is same, because target_follow_exec is not called
in this branch.  As a result, GDB thinks the inferior is executing
execee but the remote side is really executing execer, hence the
mismatch message.

By calling target_follow_exec in the "same" branch of the follow_exec
function, we ensure that everybody agrees, and we get the same behavior
with the extended-remote target as we get with the native target, the
execee is executed on the second run:

    $ ./gdbserver --once --multi :1234
    ...

    $ ./gdb -q -nx --data-directory=data-directory ./execer -ex "set remote exec-file /home/simark/build/binutils-gdb/gdb/execer" -ex "tar ext :1234"
    Reading symbols from ./execer...
    Remote debugging using :1234
    (gdb) r
    Starting program: /home/simark/build/binutils-gdb/gdb/execer
    process 1501445 is executing new program: /home/simark/build/binutils-gdb/gdb/execee
    [Inferior 1 (process 1501445) exited normally]
    (gdb) r
    `target:/home/simark/build/binutils-gdb/gdb/execee' has disappeared; keeping its symbols.
    Starting program: target:/home/simark/build/binutils-gdb/gdb/execee
    [Inferior 1 (process 1501447) exited normally]
    (gdb)

This scenario is tested in gdb.base/foll-exec-mode.exp, and in fact this
patch fixes the test for me when using
--target_board=native-extended-gdbserver.

gdb/ChangeLog:

	* infrun.c (follow_exec): Call target_follow_fork when
	follow-exec-mode is same.
	* target.h (target_follow_fork): Improve doc.

[1] https://github.com/ROCm-Developer-Tools/ROCgdb
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=27745

Change-Id: I4ee84a875e39bf3f8eaf3e6789a4bfe23a2a430e
2021-05-13 15:29:00 -04:00