Commit Graph

107648 Commits

Author SHA1 Message Date
Tom Tromey
3456e70c9d Use unique_xmalloc_ptr<char> when demangling
I noticed that some methods in language_defn could use
unique_xmalloc_ptr<char> rather than a plain 'char *'.  This patch
implements this change, fixing up the fallout and changing
gdb_demangle to also return this type.  In one spot, std::string is
used to simplify some related code, and in another, an auto_obstack is
used to avoid manual management.

Regression tested on x86-64 Fedora 34.
2021-10-04 13:45:38 -06:00
Tom Tromey
e133de4984 Minor boolean fix in windows-nat.c
I noticed a spot in windows-nat.c that used '1' rather than the more
appropriate 'true'.  This patch fixes it.
2021-10-04 13:14:49 -06:00
Tom de Vries
77252bf26e [gdb/build] Add CXX_DIALECT to CXX
Say we use a gcc version that (while supporting c++11) does not support c++11
by default, and needs an -std setting to enable it.

If gdb would use the default AX_CXX_COMPILE_STDCXX from autoconf-archive, then
we'd have:
...
CXX="g++ -std=gnu++11"
...

That mechanism however has the following problem (quoting from commit
0bcda68539):
...
the top level Makefile passes CXX down to subdirs, and that overrides whatever
gdb/Makefile may set CXX to.  The result would be that a make invocation from
the build/gdb/ directory would use "g++ -std=gnu++11" as expected, while a
make invocation at the top level would not.
...

Commit 0bcda68539 fixes this by using a custom AX_CXX_COMPILE_STDCXX which
does:
...
CXX=g++
CXX_DIALECT=-std=gnu++11
...

The problem reported in PR28318 is that using the custom instead of the
default AX_CXX_COMPILE_STDCXX makes the configure test for std::thread
support fail.

We could simply add $CXX_DIALECT to the test for std::thread support, but
that would have to be repeated for each added c++ support test.

Instead, fix this by doing:
...
CXX="g++ -std=gnu++11"
CXX_DIALECT=-std=gnu++11
...

This is somewhat awkward, since it results in -std=gnu++11 occuring twice in
some situations:
...
$ touch src/gdb/dwarf2/read.c
$ ( cd build/gdb; make V=1 dwarf2/read.o )
g++-4.8 -std=gnu++11 -x c++ -std=gnu++11 ...
...

However, both settings are needed:
 - the switch in CXX for the std::thread tests (and other tests)
 - the switch in CXX_DIALECT so it can be appended in Makefiles, to
   counteract the fact that the top-level Makefile overrides CXX

The code added in gdb/ax_cxx_compile_stdcxx.m4 is copied from the default
AX_CXX_COMPILE_STDCXX from autoconf-archive.

Tested on x86_64-linux.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28318
2021-10-04 18:51:09 +02:00
Simon Marchi
b0b8879e29 [gdb/symtab] Use unrelocated addresses in call_site
Consider test-case gdb.trace/entry-values.exp with target board
unix/-fPIE/-pie.

Using this command we have an abbreviated version, and can see the correct
@entry values for foo:
...
$ gdb -q -batch outputs/gdb.trace/entry-values/entry-values \
  -ex start \
  -ex "break foo" \
  -ex "set print entry-values both" \
  -ex continue
Temporary breakpoint 1 at 0x679

Temporary breakpoint 1, 0x0000555555554679 in main ()
Breakpoint 2 at 0x55555555463e

Breakpoint 2, 0x000055555555463e in foo (i=0, i@entry=2, j=2, j@entry=3)
...

Now, let's try the same again, but run directly to foo rather than stopping at
main:
...
$ gdb -q -batch outputs/gdb.trace/entry-values/entry-values \
  -ex "break foo" \
  -ex "set print entry-values both" \
  -ex run
Breakpoint 1 at 0x63e

Breakpoint 1, 0x000055555555463e in foo (i=0, i@entry=<optimized out>, \
  j=2, j@entry=<optimized out>)
...

So, what explains the difference?  Noteworthy, this is a dwarf assembly
test-case, with debug info for foo and bar, but not for main.

In the first case:
- we run to main
- this does not trigger expanding debug info, because there's none for main
- we set a breakpoint at foo
- this triggers expanding debug info.  Relocated addresses are used in
  call_site info (because the exec is started)
- we continue to foo, and manage to find the call_site info

In the second case:
- we set a breakpoint at foo
- this triggers expanding debug info.  Unrelocated addresses are used in
  call_site info (because the exec is not started)
- we run to foo
- this triggers objfile_relocate1, but it doesn't update the call_site
  info addresses
- we don't manage to find the call_site info

We could fix this by adding the missing call_site relocation in
objfile_relocate1.

This solution however is counter-trend in the sense that we're trying to
work towards the situation where when starting two instances of an executable,
we need only one instance of debug information, implying the use of
unrelocated addresses.

So, fix this instead by using unrelocated addresses in call_site info.

Tested on x86_64-linux.

This fixes all remaining unix/-fno-PIE/-no-pie vs unix/-fPIE/-pie
regressions, like f.i. PR24892.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=24892

Co-Authored-By: Tom de Vries <tdevries@suse.de>
2021-10-04 18:16:40 +02:00
Simon Marchi
b84aaadaf8 [gdb/symtab] C++-ify call_site
- add constructor
- add member function call_site::pc ()

Tested on x86_64-linux.

Co-Authored-By: Tom de Vries <tdevries@suse.de>
2021-10-04 18:16:40 +02:00
Tom de Vries
0dd8295da2 [gdb/symtab] Add call_site_eq and call_site_hash
In commit b4c919f752 "[gdb/symtab] Fix htab_find_slot call in
read_call_site_scope" , I removed the comment:
...
It must be the first field as we overload core_addr_hash and core_addr_eq for
it.
...
for field pc of struct call_site.

However, this was not tested, and when indeed moving field pc to the second
location, we run into a testsuite failure in gdb.trace/entry-values.exp.

This is caused by core_addr_eq (the eq_f function for the htab) being
called with a pointer to the pc field (as passed into htab_find_slot) and a
pointer to a hash table element.  Now that pc is no longer the first field,
the pointer to hash table element no longer points to the pc field.

This could be fixed by simply reinstating the comment, but we're trying to
get rid of this kind of tricks that make refactoring more difficult.

Instead, fix this by:
- reverting commit b4c919f752, apart from the comment removal, such that
  we're passing a pointer to element to htab_find_slot
- updating the htab_find_slot call in compunit_symtab::find_call_site
  in a similar manner
- adding a call_site_eq and call_site_hash, and using these in the hash table
  instead of core_addr_eq and core_addr_hash.

Tested on x86_64-linux, both with and without a trigger patch that moves pc to
the second location in struct call_site.
2021-10-04 18:16:40 +02:00
Tom Tromey
abe19f1119 Fix remote-sim.c compilation
The change "make string-like set show commands use std::string
variable" caused remote-sim.c to fail to build.  The issue is that the
code does:

  const std::string &sysroot = gdb_sysroot;
  if (is_target_filename (sysroot))
    sysroot += strlen (TARGET_SYSROOT_PREFIX);

... which isn't valid.

This patch changes this code to use a 'const char *' again, fixing the
build.
2021-10-04 09:14:26 -06:00
Bruno Larsen
6619a08b25 [gdb/testsuite] update analyze-racy-logs.py to python3
Since python 2 is no longer supported on most distributions, update the
script to run under python while while still being runnable under
python2.
2021-10-04 09:29:27 -03:00
Andrew Burgess
86c1ed137a gdbsupport: remove attempt to define TARGET_WORD_SIZE
In the gdbsupport configure.ac file, there is an attempt to define
TARGET_WORD_SIZE.  This is done by running grep on the file
../bfd/bfd-in3.h.

The problem with this is, the file bfd-in3.h is generated into the bfd
build directory when bfd is configured, and there is no dependency
between the gdbsupport module and the bfd module, so, for example, if
I do:

  $ ../src/configure
  $ make all-gdbsupport

Then bfd will neither be configured, or built.  In this case
TARGET_WORD_SIZE ends up being defined, but with no value because the
grep on bfd-in3.h fails.

However, it turns out that this doesn't matter; we don't actually use
TARGET_WORD_SIZE anywhere.

My proposal in this commit is to just remove the definition of
TARGET_WORD_SIZE, the alternative would be to add a dependency between
configure-gdbsupport and configure-bfd into Makefile.def, but adding a
dependency for something we don't need seems pretty pointless.
2021-10-04 10:52:35 +01:00
Mike Frysinger
adc82fdb71 sim: add --info-target for listing supported BFD targets
It can be difficult to guess the exact bfd name, so add an option to
list all the targets that the current build supports.  This aligns with
other simulator options like --info-architecture.
2021-10-04 02:19:58 -04:00
GDB Administrator
51911bd6e9 Automatic date update in version.in 2021-10-04 00:00:10 +00:00
Lancelot SIX
1a98bb552d gdb: Setting setter return a bool to tell if the value changed
GDB can notify observers when a parameter is changed.

To do that, do_set_command (in gdb/cli/cli-setshow.c) compares the new
value against the old one before updating it, and based on that notifies
observers.  This looks like something like:

    int valuechanged = 0;
    switch (cmd->var.type ())
    {
    case var_integer:
      {
        LONGEST new_val = parse_and_eval_long (arg)
        if (new_val != cmd->var.get<int> ())
        {
          cmd->var.get<int> (new_val);
          value_changes = 1;
        }
      }
    case var_uinteger:
    case var_zuinteger:
      {
        unsigned int val
          = parse_cli_var_uinteger (c->var->type (), &arg, true);
        if (c->var->get<unsigned int> () != val)
          {
            c->var->set<unsigned int> (val);
            option_changed = true;
          }
      }
    case...
      /* And so on for all possible var_types.  */
    }

This comparison is done for each possible var_type, which leads to
unnecessary logic duplication.

In this patch I propose to move all those checks in one place within the
setting setter method.  This limits the code duplication and simplifies
the do_set_command implementation.

This patch also changes slightly the way a value change is detected.
Instead of comparing the user provided value against the current value
of the setting, we compare the value of the setting before and after the
set operation.  This is meant to handle edge cases where trying to set
an unrecognized value would be equivalent to a noop (the actual value
remains unchanged).  Doing this requires that the original value needs
to be copied before the update, which can be non trivial for
std::string.

There should be no user visible change introduced by this commit.

Tested on x86_64 GNU/Linux.

[1] https://review.lttng.org/c/binutils-gdb/+/5831/41

Change-Id: If064b9cede3eb56275aacd2b286f74eceb1aed11
2021-10-03 17:53:16 +01:00
Lancelot SIX
702991711a gdb: Have setter and getter callbacks for settings
The main motivation behind this improvement is to help the
implementation of a patch Simon Marchi is preparing to fix a bug when
MI or Python try to access parameters that are inferior dependent (see
PR/28085).

This commit extends the previous ones, which introduces the setting
object to represent a static variable whose value can be set or shown
with the appropriate commands.  This patch proposes that a setting can
either contain a pointer to a static variable holding a setting, or
pointers to a pair of setter and getter callback functions.

The callbacks functions can be used to retrieve or change the value with
custom logic.  This is useful when the source of truth for a given
setting is not contained in the variable pointed to by the setting
instance.

Given that the callback function call is hidden within the setting
abstraction introduced earlier, none of the sites accessing the setting
needs to be updated.  The registered getter or setter is used whatever
the way to access it is (through MI, Python, Guile, the "with" command
and the $_gdb_setting / $_gdb_setting_str convenience functions).

All the add_setshow_*_cmd are given a new overload that will accept the
pair of function pointers (set / get functions) instead of the pointer
to a global variable.

Tested on GNU/Linux x86_64 with no regression observed.

Change-Id: Ieb81fef57550632ff66e6aa85f637372a226be8c
Co-authored-by: Simon Marchi <simon.marchi@polymtl.ca>
2021-10-03 17:53:16 +01:00
Simon Marchi
e0700ba44c gdb: make string-like set show commands use std::string variable
String-like settings (var_string, var_filename, var_optional_filename,
var_string_noescape) currently take a pointer to a `char *` storage
variable (typically global) that holds the setting's value.  I'd like to
"mordernize" this by changing them to use an std::string for storage.

An obvious reason is that string operations on std::string are often
easier to write than with C strings.  And they avoid having to do any
manual memory management.

Another interesting reason is that, with `char *`, nullptr and an empty
string often both have the same meaning of "no value".  String settings
are initially nullptr (unless initialized otherwise).  But when doing
"set foo" (where `foo` is a string setting), the setting now points to
an empty string.  For example, solib_search_path is nullptr at startup,
but points to an empty string after doing "set solib-search-path".  This
leads to some code that needs to check for both to check for "no value".
Or some code that converts back and forth between NULL and "" when
getting or setting the value.  I find this very error-prone, because it
is very easy to forget one or the other.  With std::string, we at least
know that the variable is not "NULL".  There is only one way of
representing an empty string setting, that is with an empty string.

I was wondering whether the distinction between NULL and "" would be
important for some setting, but it doesn't seem so.  If that ever
happens, it would be more C++-y and self-descriptive to use
optional<string> anyway.

Actually, there's one spot where this distinction mattered, it's in
init_history, for the test gdb.base/gdbinit-history.exp.  init_history
sets the history filename to the default ".gdb_history" if it sees that
the setting was never set - if history_filename is nullptr.  If
history_filename is an empty string, it means the setting was explicitly
cleared, so it leaves it as-is.  With the change to std::string, this
distinction doesn't exist anymore.  This can be fixed by moving the code
that chooses a good default value for history_filename to
_initialize_top.  This is ran before -ex commands are processed, so an
-ex command can then clear that value if needed (what
gdb.base/gdbinit-history.exp tests).

Another small improvement, in my opinion is that we can now easily
give string parameters initial values, by simply initializing the global
variables, instead of xstrdup-ing it in the _initialize function.

In Python and Guile, when registering a string-like parameter, we
allocate (with new) an std::string that is owned by the param_smob (in
Guile) and the parmpy_object (in Python) objects.

This patch started by changing all relevant add_setshow_* commands to
take an `std::string *` instead of a `char **` and fixing everything
that failed to build.  That includes of course all string setting
variable and their uses.

string_option_def now uses an std::string also, because there's a
connection between options and settings (see
add_setshow_cmds_for_options).

The add_path function in source.c is really complex and twisted, I'd
rather not try to change it to work on an std::string right now.
Instead, I added an overload that copies the std:string to a `char *`
and back.  This means more copying, but this is not used in a hot path
at all, so I think it is acceptable.

Change-Id: I92c50a1bdd8307141cdbacb388248e4e4fc08c93
Co-authored-by: Lancelot SIX <lsix@lancelotsix.com>
2021-10-03 17:53:16 +01:00
Lancelot SIX
1d7fe7f01b gdb: Introduce setting construct within cmd_list_element
cmd_list_element can contain a pointer to data that can be set and / or
shown.  This is achieved with the void* VAR member which points to the
data that can be accessed, while the VAR_TYPE member (of type enum
var_types) indicates how to interpret the data pointed to.

With this pattern, the user of the cmd_list_element needs to know what
is the storage type associated with a given VAR_TYPES in order to do
the proper casting.  No automatic safeguard is available to prevent
miss-use of the pointer.  Client code typically looks something like:

	switch (c->var_type)
	{
	  case var_zuinteger:
	    unsigned int v = *(unsigned int*) c->var;
	    ...
	    break;
	  case var_boolean:
	    bool v = *(bool *) c->var;
	    ...
	    break;
	  ...
	}

This patch proposes to add an abstraction around the var_types and void*
pointer pair.  The abstraction is meant to prevent the user from having
to handle the cast and verify that the data is read or written as a type
that is coherent with the setting's var_type.  This is achieved by
introducing the struct setting which exposes a set of templated get /
set member functions.  The template parameter is the type of the
variable that holds the referred variable.

Using those accessors allows runtime checks to be inserted in order to
ensure that the data pointed to has the expected type.  For example,
instantiating the member functions with bool will yield something
similar to:

	const bool &get<bool> () const
	{
	  gdb_assert (m_var_type == var_boolean);
	  gdb_assert (m_var != nullptr);
	  return *static_cast<bool *> (m_var);
	}
	void set<bool> (const bool &var)
	{
	  gdb_assert (m_var_type == var_boolean);
	  gdb_assert (m_var != nullptr);
	  *static_cast<bool *> (m_var) = var;
	}

Using the new abstraction, our initial example becomes:

	switch (c->var_type)
	{
	  case var_zuinteger:
	    unsigned int v = c->var->get<unsigned int> ();
	    ...
	    break;
	  case var_boolean:
	    bool v = c->var->get<bool> ();
	    ...
	    break;
	  ...
	}

While the call site is still similar, the introduction of runtime checks
help ensure correct usage of the data.

In order to avoid turning the bulk of add_setshow_cmd_full into a
templated function, and following a suggestion from Pedro Alves, a
setting can be constructed from a pre validated type erased reference to
a variable.  This is what setting::erased_args is used for.

Introducing an opaque abstraction to describe a setting will also make
it possible to use callbacks to retrieve or set the value of the setting
on the fly instead of pointing to a static chunk of memory.  This will
be done added in a later commit.

Given that a cmd_list_element may or may not reference a setting, the
VAR and VAR_TYPES members of the struct are replaced with a
gdb::optional<setting> named VAR.

Few internal function signatures have been modified to take into account
this new abstraction:

-The functions value_from_setting, str_value_from_setting and
 get_setshow_command_value_string used to have a 'cmd_list_element *'
 parameter but only used it for the VAR and VAR_TYPE member. They now
 take a 'const setting &' parameter instead.
- Similarly, the 'void *' and a 'enum var_types' parameters of
  pascm_param_value and gdbpy_parameter_value have been replaced with a
  'const setting &' parameter.

No user visible change is expected after this patch.

Tested on GNU/Linux x86_64, with no regression noticed.

Co-authored-by: Simon Marchi <simon.marchi@polymtl.ca>
Change-Id: Ie1d08c3ceb8b30b3d7bf1efe036eb8acffcd2f34
2021-10-03 17:53:16 +01:00
Mike Frysinger
39d53d0435 sim: filter out SIGSTKSZ [PR sim/28302]
We map target signals to host signals so we can propagate signals
between the host & simulated worlds.  That means we need to know
the symbolic names & values of all signals that might be sent.

The tools that generate that list use signal.h and include all
symbols that start with "SIG" so as to automatically include any
new symbols that the C library might add.  Unfortunately, this
also picks up "SIGSTKSZ" which is not actually a signal itself,
but a signal related setting -- it's the size of the stack when
a signal is handled.

By itself this doesn't super matter as we will never see a signal
with that same value (since the range of valid signals tend to be
way less than 1024, and the size of the default signal stack will
never be that small).  But with recent glibc changes that make this
into a dynamic value instead of a compile-time constant, some users
see build failures when building the sim.

As suggested by Adam Sampson, update our scripts to ignore this
symbol to simplify everything and avoid the build failure.

Bug: https://sourceware.org/PR28302
2021-10-03 12:02:53 -04:00
Mike Frysinger
46039d3632 sim: ppc: fallback when ln is not available [PR sim/18864]
Not all systems have easy access to hard links or symlinks, so add
fallback logic to the run->psim build code to handle those.

Bug: https://sourceware.org/PR18864
2021-10-03 11:36:30 -04:00
Lancelot SIX
0a9bddab0f gdb: Fix comment in riscv_scan_prologue
I found an inaccurate comment in riscv_scan_prologue.  This commit fixes
it.
2021-10-03 15:01:21 +00:00
Lancelot SIX
2b014cc535 gdb: Support the c.mv insn in the riscv prologue scanner.
While working on other problems, I encountered situations where GDB
fails to properly unwind the stack because some functions use the C.MV
instruction in the prologue.  The prologue scanner stops when it hits
this instruction assuming its job is done at this point.  Unfortunately
the prologue is not necessarily finished yet, preventing GDB to properly
unwind.

This commit adds support for handling such instruction in
riscv_scan_prologue.

Note that C.MV is part of the compressed instruction set.  The MV
counterpart from the base ISA is a pseudo instruction that expands to
'ADDI RD,RS1,0' which is already supported.

Tested on riscv64-linux-gnu.

All feedback are welcome.
2021-10-03 14:00:58 +00:00
GDB Administrator
d4e8e096a5 Automatic date update in version.in 2021-10-03 00:00:09 +00:00
Simon Marchi
b625c7701d [gdb/symtab] Remove COMPUNIT_CALL_SITE_HTAB
Remove macro COMPUNIT_CALL_SITE_HTAB, and provide access to the htab using
member functions:
- compunit_symtab::find_call_site
- compunit_symtab::set_call_site_htab

Tested on x86_64-linux.

Co-Authored-By: Tom de Vries <tdevries@suse.de>
2021-10-02 17:38:05 +02:00
Simon Marchi
1e9983e730 gdb/python: fix a few flake8 warnings
Fix these rather obvious warnings reported by flake8:

    ./lib/gdb/FrameIterator.py:16:1: F401 'gdb' imported but unused
    ./lib/gdb/FrameIterator.py:17:1: F401 'itertools' imported but unused
    ./lib/gdb/command/prompt.py:55:26: E712 comparison to False should be 'if cond is False:' or 'if not cond:'
    ./lib/gdb/command/explore.py:526:9: F841 local variable 'has_explorable_fields' is assigned to but never used
    ./lib/gdb/command/explore.py:697:56: E712 comparison to False should be 'if cond is False:' or 'if not cond:'
    ./lib/gdb/command/explore.py:736:62: E712 comparison to False should be 'if cond is False:' or 'if not cond:'
    ./lib/gdb/command/explore.py:767:61: E712 comparison to False should be 'if cond is False:' or 'if not cond:'
    ./lib/gdb/command/frame_filters.py:21:1: F401 'copy' imported but unused
    ./lib/gdb/command/frame_filters.py:22:1: F401 'gdb.FrameIterator.FrameIterator' imported but unused
    ./lib/gdb/command/frame_filters.py:23:1: F401 'gdb.FrameDecorator.FrameDecorator' imported but unused
    ./lib/gdb/command/frame_filters.py:25:1: F401 'itertools' imported but unused
    ./lib/gdb/command/frame_filters.py:179:17: E712 comparison to True should be 'if cond is True:' or 'if cond:'

Change-Id: I4f49c0cb430359ee872222600c61d9c5283b09ab
2021-10-02 08:33:28 -04:00
GDB Administrator
223809519e Automatic date update in version.in 2021-10-02 00:00:08 +00:00
Luis Machado
beed8c1dbd Fix build failure for 32-bit targets
When building master GDB, I ran into the following:

binutils-gdb/gdb/bt-utils.c: In function 'int libbacktrace_print(void*, uintptr_t, const char*, int, const char*)':
binutils-gdb/gdb/bt-utils.c:93:44: error: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'uintptr_t {aka unsigned int}' [-Werror=format=]
   snprintf (buf, sizeof (buf), "0x%lx ", pc);

Fix this by using %PRIxPTR as opposed to %lx.
2021-10-01 13:31:55 -03:00
Nick Clifton
dd6f2df79d Fix mistake in RX assembler documentation (special section names) 2021-10-01 16:44:10 +01:00
Simon Marchi
b4c919f752 [gdb/symtab] Fix htab_find_slot call in read_call_site_scope
In read_call_site_scope we have:
...
  call_site_local.pc = pc;
  slot = htab_find_slot (cu->call_site_htab, &call_site_local, INSERT);
...

The call passes a call_site pointer as element.  OTOH, the hashtab is created
using hash_f == core_addr_hash and eq_f == core_addr_eq, so the element
will be accessed through a CORE_ADDR pointer.

This is not wrong (at least in C), given that pc is the first field in
call_site.

Nevertheless, as in call_site_for_pc, make the htab_find_slot call match the
used hash_f and eq_f by using &pc instead:
...
  slot = htab_find_slot (cu->call_site_htab, &pc, INSERT);
...

Tested on x86_64-linux.

Co-Authored-By: Tom de Vries <tdevries@suse.de>
2021-10-01 17:15:20 +02:00
Andrea Corallo
242fe37867 PATCH bfd: Fix linker warning for recently introduced arm attributes
2021-09-27  Andrea Corallo  <andrea.corallo@arm.com>

	* elf-bfd.h (NUM_KNOWN_OBJ_ATTRIBUTES): Update value to cover
	'Tag_BTI_use' and 'Tag_PACRET_use'.
2021-10-01 10:12:44 +02:00
Simon Marchi
46a5b75b37 gdb/testsuite/dwarf: use options for rnglists/loclists procs
Change how rnglists and loclists procs to align them with how procs for
aranges (and other things in the DWARF assembler) work.  Instead of
using "args" (variable number of parameters in TCL) and command-line
style option arguments, use one leading "option" parameters, used as a
kind of key/value dictionary of options parsed using `parse_options`.

Change-Id: I63e60d17ae16a020ce4d6de44baf3d152ea42a1a
2021-09-30 22:21:56 -04:00
Simon Marchi
c5dfcc2188 gdb/testsuite/dwarf: don't define nested procs for rnglists/loclists
When I wrote support for rnglists and loclists in the testsuite's DWARF
assembler, I made it with nested procs, for example proc "table" inside
proc "rnglists".  The intention was that this proc "table" could only be
used by the user while inside proc "rnglists"'s body.  I had chosen very
simple names, thinking there was no chance of name clashes.  I recently
learned that this is not how TCL works.  This ends up defining a proc
"table" in the current namespace ("Dwarf" in this case).

Things still work if you generate rnglists and loclists in the same
file, as each redefines its own procedures when executing.  But if a
user of the assembler happened to define a convenience "table" or
"start_end" procedure, for example, it would get overriden.

I'd like to change how this works to reduce the chances of a name clash.

 - Move the procs out of each other, so they are not defined in a nested
   fashion.
 - Prefix them with "_rnglists_" or "_loclists_".
 - While calling $body in the various procs, temporarily make the procs
   available under their "short" name.  For example, while in rngllists'
   body, make _rnglists_table available as just "table".  This allows
   existing code to keep working and keeps it not too verbose.
 - Modify with_override to allow the overriden proc to not exist.  In
   that case, the temporary proc is deleted on exit.

Note the non-conforming indentation when calling with_override in
_loclists_list.  This is on purpose: as we implement more loclists (and
rnglists) entry types, the indentation would otherwise get larger and
larger without much value for readability.  So I think it's reasonable
here to put them on the same level.

Change-Id: I7bb48d26fcb0dba1ae4dada05c0c837212424328
2021-09-30 22:21:52 -04:00
Simon Marchi
33d16dd987 gdb: remove TYPE_FIELD_NAME and FIELD_NAME macros
Remove the `TYPE_FIELD_NAME` and `FIELD_NAME` macros, changing all the
call sites to use field::name directly.

Change-Id: I6900ae4e1ffab1396e24fb3298e94bf123826ca6
2021-09-30 22:05:57 -04:00
Simon Marchi
d3fd12dfc5 gdb: add field::name / field::set_name
Add the `name` and `set_name` methods on `struct field`, in order to
remove `FIELD_NAME` and `TYPE_FIELD_NAME` macros.  In this patch, the
macros are changed to use `field::name`, so all the call sites that are
used to set the field's name are changed to use `field::set_name`.
The next patch will remove the macros completely.

Note that because of the name clash between the existing field named
`name` and the new method, I renamed the field `m_name`.  It is not
private per-se, because we can't make `struct field` a non-POD yet, but
it should be considered private anyway (not accessed outside `struct
field`).

Change-Id: If16ddbca4e0c39d0ff9da420bb5cdebe5b9b0896
2021-09-30 22:05:46 -04:00
GDB Administrator
cdfbeec413 Automatic date update in version.in 2021-10-01 00:00:10 +00:00
Sergio Durigan Junior
906e2b7664 [PR gdb/28369] Use get_shell on gdb/ser-pipe.c
PR gdb/28369 reports that gdb/ser-pipe.c has an 'execl' function call
with a hard-coded "/bin/sh" as its argument.  We've had 'get_shell'
for a while now, which is conscious about the SHELL environment and a
better alternative to always calling "/bin/sh".

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28369
2021-09-30 18:19:10 -04:00
Tom de Vries
e4860c08f9 [gdb/testsuite] Add untested for missing xml support in gdb.base/valgrind*.exp
Add untested in case missing xml support is detected in test-cases
gdb.base/valgrind*.exp.

Tested on x86_64-linux.
2021-09-30 23:46:32 +02:00
Przemyslaw Wirkus
80cfde76a7 arm: enable Cortex-R52+ CPU
Patch is adding Cortex-R52+ as 'cortex-r52plus' command line
flag for -mcpu option.

bfd/

	* cpu-arm.c: New Cortex-R52+ CPU.

gas/

	* NEWS: Update docs.
	* config/tc-arm.c: New Cortex-R52+ CPU.
	* doc/c-arm.texi: Update docs.
	* testsuite/gas/arm/cpu-cortex-r52plus.d: New test.
2021-09-30 21:16:58 +01:00
Przemyslaw Wirkus
50aaf5e6ee aarch64: Enable Cortex-X2 CPU
This patch is adding support for Cortex-X2 CPU.

gas:

	* NEWS: Update docs.
	* config/tc-aarch64.c: Add Cortex-X2.
	* doc/c-aarch64.texi: Update docs.
2021-09-30 21:01:34 +01:00
Przemyslaw Wirkus
db67a8d594 aarch64: Enable Cortex-A710 CPU
This patch is adding support for Cortex-A710 CPU.

gas/

        * NEWS: Update docs.
        * config/tc-aarch64.c: Add Cortex-A710.
        * doc/c-aarch64.texi: Update docs.
2021-09-30 20:56:18 +01:00
Przemyslaw Wirkus
98ab23ab20 aarch64: Enable Cortex-A510 CPU
This patch is adding support for Cortex-A510 CPU.

gas/

	* NEWS: Update docs.
	* config/tc-aarch64.c: Add Cortex-A510.
	* doc/c-aarch64.texi: Update docs.
2021-09-30 20:50:37 +01:00
Przemyslaw Wirkus
b18be12aea aarch64: Update AArch64 features command line options docs 2/2
Patch is only sorting by 'Extension` column 'Architecture Extension'
table.

gas/

	* doc/c-aarch64.texi: Update docs.
2021-09-30 20:49:09 +01:00
Przemyslaw Wirkus
7645513a26 aarch64: Update AArch64 features command line options docs 1/2
Patch is improving entries in "Architecture extensions" table in GAS
documentation.

gas/

	* doc/c-aarch64.texi: Update docs.
2021-09-30 20:48:54 +01:00
Przemyslaw Wirkus
d5007f0280 aarch64: add armv9-a architecture to -march
Patch is adding new 'armv9-a` command line flag to -march for AArch64.

gas/

	* config/tc-aarch64.c: Add 'armv9-a' command line flag.
	* docs/c-aarch64.text: Update docs.
	* NEWS: Update docs.

include/

	* opcode/aarch64.h (AARCH64_FEATURE_V9): New define.
	(AARCH64_ARCH_V9): New define.
2021-09-30 20:44:17 +01:00
Simon Marchi
4dfef5be68 gdb/testsuite: make runto_main not pass no-message to runto
As follow-up to this discussion:

  https://sourceware.org/pipermail/gdb-patches/2020-August/171385.html

... make runto_main not pass no-message to runto.  This means that if we
fail to run to main, for some reason, we'll emit a FAIL.  This is the
behavior we want the majority of (if not all) the time.

Without this, we rely on tests logging a failure if runto_main fails,
otherwise.  They do so in a very inconsisteny mannet, sometimes using
"fail", "unsupported" or "untested".  The messages also vary widly.
This patch removes all these messages as well.

Also, remove a few "fail" where we call runto (and not runto_main).  by
default (without an explicit no-message argument), runto prints a
failure already.  In two places, gdb.multi/multi-re-run.exp and
gdb.python/py-pp-registration.exp, remove "message" passed to runto.
This removes a few PASSes that we don't care about (but FAILs will still
be printed if we fail to run to where we want to).  This aligns their
behavior with the rest of the testsuite.

Change-Id: Ib763c98c5f4fb6898886b635210d7c34bd4b9023
2021-09-30 15:27:39 -04:00
Simon Marchi
2fed9db40b gdbsupport: make gdb_mkostemp_cloexec return a scoped_fd
This encourages the callers to use automatic file descriptor management.

Change-Id: I137a81df6f3607b457e28c35aafde8ed6f3a3344
2021-09-30 15:21:48 -04:00
Simon Marchi
13084383e8 gdbsupport: make gdb_open_cloexec return scoped_fd
Make gdb_open_cloexec return a scoped_fd, to encourage using automatic
management of the file descriptor closing.  Except in the most trivial
cases, I changed the callers to just release the fd, which retains their
existing behavior.  That will allow the transition to using scoped_fd
more to go gradually, one caller at a time.

Change-Id: Ife022b403f96e71d5ebb4f1056ef6251b30fe554
2021-09-30 15:21:48 -04:00
Simon Marchi
e6e51c9c4b gdbsupport: move gdb_file_up to its own file
The following patches wants to change gdb_fopen_cloexec and
gdb_mkostemp_cloexec to return a scoped_fd.  Doing this causes a cyclic
include between scoped_fd.h and filestuff.h, that both want to include
each other.  scoped_fd.h includes filestuff.h because of the
scoped_fd::to_file method's return value.  filestuff.h would then
include scoped_fd.h for gdb_fopen_cloexec's and gdb_mkostemp_cloexec's
return values.

To fix that, move gdb_file_up to its own file, gdb_file.h.

Change-Id: Ic82a48914b2aacee8f14af535b7469245f88b93d
2021-09-30 15:21:48 -04:00
Dimitar Dimitrov
5109a7bd9b ld: pru: Fix resource_table output section alignment
My commit 261980de18 added alignment for the resource table symbol.
But it is wrong.  The Linux remoteproc driver loads and interprets the
contents of the .resource_table ELF section, not of a table symbol.

Without this patch, if the linker happens to output padding for symbol
alignment, then the resource table contents as viewed by the kernel
loader would "shift" and look corrupted.

ld/ChangeLog:

	* scripttempl/pru.sc  (.resource_table): Align the output
	section, not the first symbol.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2021-09-30 22:15:50 +03:00
Tom Tromey
9279eb5c2c Fix Windows crash from stop_pc change
The "make thread_suspend_state::stop_pc optional" patch caused a
regression on Windows when using shared libraries.  I tracked this
down to an unguarded use of stop_pc() in the TARGET_WAITKIND_LOADED
case of handle_inferior_event.  This patch fixes the bug by ensuring
that the stop PC is set at this point.
2021-09-30 11:17:09 -06:00
Tom de Vries
7264ba8331 [gdb/testsuite] Use untested in gdb.debuginfod/fetch_src_and_symbols.exp
With running test-case gdb.debuginfod/fetch_src_and_symbols.exp with target
board unix/-bad, I get:
...
gcc: error: unrecognized command line option '-bad'^M
compiler exited with status 1
gdb compile failed, gcc: error: unrecognized command line option '-bad'
FAIL: gdb.debuginfod/fetch_src_and_symbols.exp: compile
...

Replace the FAIL with the usual:
...
UNTESTED: gdb.debuginfod/fetch_src_and_symbols.exp: failed to compile
...

Tested on x86_64-linux.
2021-09-30 19:07:48 +02:00
Tom de Vries
243c0950e2 [gdb/testsuite] Remove redundant FAIL in gdb.base/info-os.exp
When running test-case gdb.base/info-os.exp with target board unix/-bad, I run
into:
...
gdb compile failed, gcc: error: unrecognized command line option '-bad'
UNTESTED: gdb.base/info-os.exp: failed to prepare
FAIL: gdb.base/info-os.exp: cannot compile test program
...

Remove the redundant FAIL.

Tested on x86_64-linux.
2021-09-30 19:07:48 +02:00
Tom de Vries
50f9e7d853 [gdb/testsuite] Fix DUPLICATE in gdb.base/info-os.exp
When running test-case gdb.base/info-os.exp, I run into:
...
PASS: gdb.base/info-os.exp: get threads
PASS: gdb.base/info-os.exp: get threads
DUPLICATE: gdb.base/info-os.exp: get threads
...

Fix this not doing pass followed by exp_continue in gdb_test_multiple.

Tested on x86_64-linux.
2021-09-30 19:07:48 +02:00