2
0
mirror of https://sourceware.org/git/binutils-gdb.git synced 2025-04-12 14:33:06 +08:00

188 Commits

Author SHA1 Message Date
Tom de Vries
99d0bac09b [gdb/unittests] Ignore spellcheck warning in rsp-low-selftests.c
Ignore the following spellcheck warning:
...
$ codespell --config gdb/contrib/setup.cfg gdb/unittests
gdb/unittests/rsp-low-selftests.c:54: fo ==> of, for, to, do, go
...
and add gdb/unittests to the pre-commit codespell configuration.

Approved-By: Tom Tromey <tom@tromey.com>
2025-04-10 18:42:06 +02:00
Tom Tromey
d01e823438 Update copyright dates to include 2025
This updates the copyright headers to include 2025.  I did this by
running gdb/copyright.py and then manually modifying a few files as
noted by the script.

Approved-By: Eli Zaretskii <eliz@gnu.org>
2025-04-08 10:54:39 -06:00
Tom Tromey
4d5ced441a Use gdb unordered set and map in unit tests
This changes some unit test code to use gdb:unordered_set and
gdb::unordered_map.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2025-03-18 05:32:04 -06:00
Tom Tromey
caf7719651 Handle ">>" in cp-name-parser.y
I noticed that a certain name didn't work correctly when trying to
remove the parameters.  I put this into lookup_name_info-selftests.c.

I tracked this down to the fact that cp-name-parser.y doesn't handle
">>" to end templates.  This patch fixes this in a simple way --
accepting the "RSH" token where appropriate and then un-pushing a ">".
2025-03-07 08:09:29 -07:00
Tom de Vries
664c80701d [gdb] Fix typos in some selftests
Fix typos:
...
figured on out -> figured one out
fpr -> for
hopefuly -> hopefully
...
2025-03-06 11:34:41 +01:00
Simon Marchi
b6fb76ec6e gdb, gdbserver, gdbsupport: fix some namespace comment formatting
I noticed a

  // namespace selftests

comment, which doesn't follow our comment formatting convention.  I did
a find & replace to fix all the offenders.

Change-Id: Idf8fe9833caf1c3d99e15330db000e4bab4ec66c
2025-02-27 21:35:38 -05:00
Simon Marchi
9044044c27 gdbsupport: add gdb::make_array_view overload to create from an array
I think this overload will be useful for the following reasons.
Consider a templated function like this:

    template <typename T>
    void func(gdb::array_view<T> view) {}

Trying to pass an array to this function doesn't work, as template
argument deduction fails:

    test.c:698:8: error: no matching function for call to ‘func(int [12])’
      698 |   func (array);
          |   ~~~~~^~~~~~~
    test.c:686:6: note: candidate: ‘template<class T> void func(gdb::array_view<U>)’
      686 | void func(gdb::array_view<T> view) {}
          |      ^~~~
    test.c:686:6: note:   template argument deduction/substitution failed:
    test.c:698:8: note:   mismatched types ‘gdb::array_view<U>’ and ‘int*’
      698 |   func (array);
          |   ~~~~~^~~~~~~

Similarly, trying to compare a view with an array doesn't work.  This:

  int array[12];
  gdb::array_view<int> view;

  if (view == array) {}

... fails with:

    test.c:698:8: error: no matching function for call to ‘func(int [12])’
      698 |   func (array);
          |   ~~~~~^~~~~~~
    test.c:686:6: note: candidate: ‘template<class T> void func(gdb::array_view<U>)’
      686 | void func(gdb::array_view<T> view) {}
          |      ^~~~
    test.c:686:6: note:   template argument deduction/substitution failed:
    test.c:698:8: note:   mismatched types ‘gdb::array_view<U>’ and ‘int*’
      698 |   func (array);
          |   ~~~~~^~~~~~~

With this new overload, we can do:

    func (gdb::make_array_view (array));

and

    if (view == gdb::make_array_view (array)) {}

This is not ideal, I wish that omitting `gdb::make_array_view` would
just work, but at least it allows creating an array view and have the
element type automatically deduced from the array type.

If someone knows how to make these cases "just work", I would be happy
to know how.

Change-Id: I6a71919d2d5a385e6826801d53f5071b470fef5f
Approved-By: Tom Tromey <tom@tromey.com>
2025-02-10 11:17:23 -05:00
Andrei Pikas
6447969d0a Add an option with a color type.
Colors can be specified as "none" for terminal's default color, as a name of
one of the eight standard colors of ISO/IEC 6429 "black", "red", "green", etc.,
as an RGB hexadecimal tripplet #RRGGBB for 24-bit TrueColor, or as an
integer from 0 to 255.  Integers 0 to 7 are the synonyms for the standard
colors.  Integers 8-15 are used for the so-called bright colors from the
aixterm extended 16-color palette.  Integers 16-255 are the indexes into xterm
extended 256-color palette (usually 6x6x6 cube plus gray ramp).  In
general, 256-color palette is terminal dependent and sometimes can be
changed with OSC 4 sequences, e.g. "\033]4;1;rgb:00/FF/00\033\\".

It is the responsibility of the user to verify that the terminal supports
the specified colors.

PATCH v5 changes: documentation fixed.
PATCH v6 changes: documentation fixed.
PATCH v7 changes: rebase onto master and fixes after review.
PATCH v8 changes: fixes after review.
2025-01-12 13:30:43 -07:00
Carlos Galvez
4a0b2cb721 Fix -Wenum-constexpr-conversion in enum-flags.h
This fixes PR 31331:
https://sourceware.org/bugzilla/show_bug.cgi?id=31331

Currently, enum-flags.h is suppressing the warning
-Wenum-constexpr-conversion coming from recent versions of Clang.
This warning is intended to be made a compiler error
(non-downgradeable) in future versions of Clang:

https://github.com/llvm/llvm-project/issues/59036

The rationale is that casting a value of an integral type into an
enumeration is Undefined Behavior if the value does not fit in the
range of values of the enum:
https://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1766

Undefined Behavior is not allowed in constant expressions, leading to
an ill-formed program.

In this case, in enum-flags.h, we are casting the value -1 to an enum
of a positive range only, which is UB as per the Standard and thus not
allowed in a constexpr context.

The purpose of doing this instead of using std::underlying_type is
because, for C-style enums, std::underlying_type typically returns
"unsigned int". However, when operating with it arithmetically, the
enum is promoted to *signed* int, which is what we want to avoid.

This patch solves this issue as follows:

* Use std::underlying_type and remove the custom enum_underlying_type.

* Ensure that operator~ is called always on an unsigned integer. We do
  this by casting the input enum into std::size_t, which can fit any
  unsigned integer. We have the guarantee that the cast is safe,
  because we have checked that the underlying type is unsigned. If the
  enum had negative values, the underlying type would be signed.

  This solves the issue with C-style enums, but also solves a hidden
  issue: enums with underlying type of std::uint8_t or std::uint16_t are
  *also* promoted to signed int. Now they are all explicitly casted
  to the largest unsigned int type and operator~ is safe to use.

* There is one more thing that needs fix. Currently, operator~ is
  implemented as follows:

  return (enum_type) ~underlying(e);

  After applying ~underlying(e), the result is a very large value,
  which we then cast to "enum_type". This cast is Undefined Behavior
  if the large value does not fit in the range of the enum. For
  C++ enums (scoped and/or with explicit underlying type), the range
  of the enum is the entire range of the underlying type, so the cast
  is safe. However, for C-style enums, the range is the smallest
  bit-field that can hold all the values of the enumeration. So the
  range is a lot smaller and casting a large value to the enum would
  invoke Undefined Behavior.

  To solve this problem, we create a new trait
  EnumHasFixedUnderlyingType, to ensure operator~ may only be called
  on C++-style enums. This behavior is roughly the same as what we
  had on trunk, but relying on different properties of the enums.

* Once this is implemented, the following tests fail to compile:

  CHECK_VALID (true,  int,  true ? EF () : EF2 ())

  This is because it expects the enums to be promoted to signed int,
  instead of unsigned int (which is the true underlying type).

  I propose to remove these tests altogether, because:

  - The comment nearby say they are not very important.
  - Comparing 2 enums of different type like that is strange, relies
    on integer promotions and thus hurts readability. As per comments
    in the related PR, we likely don't want this type of code in gdb
    code anyway, so there's no point in testing it.
  - Most importantly, this type of comparison will be ill-formed in
    C++26 for regular enums, so enum_flags does not need to emulate
    that.

Since this is the only place where the warning was suppressed, remove
also the corresponding macro in include/diagnostics.h.

The change has been tested by running the entire gdb test suite
(make check) and comparing the results (testsuite/gdb.sum) against
trunk. No noticeable differences have been observed.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31331
Tested-by: Keith Seitz <keiths@redhat.com>
Approved-By: Tom Tromey <tom@tromey.com>
2024-12-22 10:48:58 -07:00
Tom Tromey
fba3b6d16c Ensure that help text fits in 80 columns
This patch adds a new unit test that ensures that all help text wraps
at 80 columns.
2024-11-11 07:45:02 -07:00
Tom de Vries
e686338105 [gdbsupport] Add gdb::array_view::{iterator,const_iterator}
While trying to substitute some std::vector type A in the code with a
gdb::array_view:
...
- using A = std::vector<T>
+ using A = gdb::array_view<T>
....
I ran into the problem that the code was using A::iterator while
gdb::array_view doesn't define such a type.

Fix this by:
- adding types gdb::array_view::iterator and gdb::array_view::const_iterator,
- using them in gdb::array_view::(c)begin and gdb::array_view::(c)end, as is
  usual, and
- using them explicitly in a unit test.

Tested on aarch64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-10-19 08:10:38 +02:00
Simon Marchi
8b8f98ad2b gdbsupport/intrusive-list: add owning_intrusive_list
It occured to me that `intrusive_list<solib>`, as returned by
`solib_ops::current_sos`, for instance, is not very safe.  The
current_sos method returns the ownership of the solib objects
(heap-allocated) to its caller, but the `intrusive_list<solib>` type
does not convey it.  If a function is building an
`intrusive_list<solib>` and something throws, the solibs won't
automatically be deleted.  Introduce owning_intrusive_list to fill this
gap.

Interface
---------

The interface of owning_intrusive_list is mostly equivalent to
intrusive_list, with the following differences:

 - When destroyed, owning_intrusive_list deletes all element objects.
   The clear method does so as well.

 - The erase method destroys the removed object.

 - The push_front, push_back and insert methods accept a `unique_ptr<T>`
   (compared to `T &` for intrusive_list), taking ownership of the
   object.

 - owning_intrusive_list has emplace_front, emplace_back and emplace
   methods, allowing to allocate and construct an object directly in the
   list.  This is really just a shorthand over std::make_unique and
   insert (or push_back / push_front if you don't care about the return
   value), but I think it is nicer to read:

     list.emplace (pos, "hello", 2);

   rather than

     list.insert (pos, std::make_unique<Foo> ("hello", 2));

   These methods are not `noexcept`, since the allocation or the
   constructor could throw.

 - owning_intrusive_list has a release method, allowing to remove an
   element without destroying it.  The release method returns a
   pair-like struct with an iterator to the next element in the list
   (like the erase method) and a unique pointer transferring the
   ownership of the released element to the caller.

 - owning_intrusive_list does not have a clear_and_dispose method, since
   that is typically used to manually free items.

Implementation
--------------

owning_intrusive_list privately inherits from intrusive_list, in order
to re-use the linked list machinery.  It adds ownership semantics around
it.

Testing
-------

Because of the subtle differences in the behavior in behavior and what
we want to test for each type of intrusive list, I didn't see how to
share the tests for the two implementations.  I chose to copy the
intrusive_list tests and adjust them for owning_intrusive_list.

The verify_items function was made common though, and it tries to
dereference the items in the list, to make sure they have not been
deleted by mistake (which would be caught by Valgrind / ASan).

Change-Id: Idbde09c1417b79992a0a9534d6907433e706f760
Co-Authored-By: Pedro Alves <pedro@palves.net>
Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-09-13 07:38:56 -04:00
Simon Marchi
d8ea57169c gdbsupport/intrusive-list: make insert return an iterator
Make the insert method return an iterator to the inserted element.  This
mimics what boost does [1] and what the standard library insert methods
generally do [2].

[1] https://www.boost.org/doc/libs/1_79_0/doc/html/boost/intrusive/list.html#idm33771-bb
[2] https://en.cppreference.com/w/cpp/container/vector/insert

Change-Id: I59082883492c60ee95e8bb29a18c9376283dd660
Reviewed-by: Keith Seitz <keiths@redhat.com>
2024-09-13 07:38:56 -04:00
Tom de Vries
50f8a39878 [gdb] Add const to catch gdb_exception
I did a review of lines containing "catch (gdb_exception" and found a few
where we can add const.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
2024-08-22 09:49:53 +02:00
Simon Marchi
ba96d2e697 gdb: change names of enumerations in enum flags selftest
When reading this test (in the context of PR 31331), I had trouble
understanding the tests, because of the abbreviated names.  I would
prefer if the names were a bit more explicit, like this.

Change-Id: I85669b238a9d5dacf673a7bbfc1ca18f80d2b2cf
2024-08-12 10:58:49 -04:00
Simon Marchi
b050b744be gdb, gdbsupport: use using in enum flags code
I think that `using` is easier to read than `typedef`, and it's the
modern C++ thing anyway.

Change-Id: Iccb62dc3869cddfb6a684ef3023dcd5b799f3ab2
2024-08-12 10:58:49 -04:00
Simon Marchi
ef379f175a gdb/unittests/intrusive-list: remove unnecessary local objects
These objects are not used.

Change-Id: I90127f7b2d1543718c841b54173521d9ab3f652f
2024-07-22 14:11:44 -04:00
Simon Marchi
05d9d66d92 gdb: remove unused includes in utils.h
Remove some includes reported as unused by clangd.  Add some includes in
other files that were previously relying on the transitive include.

Change-Id: Ibdd0a998b04d21362a20d0ca8e5267e21e2e133e
2024-05-30 22:43:52 -04:00
Tom Tromey
be2a6a5803 Disallow trailing whitespace in docstrings
This patch changes the docstring self-test to verify that there is no
trailing whitespace at the end of lines.  A few existing docstrings
had to be updated.
2024-05-14 13:23:37 -06:00
Simon Marchi
ec45252592 gdb: move store/extract integer functions to extract-store-integer.{c,h}
Move the declarations out of defs.h, and the implementations out of
findvar.c.

I opted for a new file, because this functionality of converting
integers to bytes and vice-versa seems a bit to generic to live in
findvar.c.

Change-Id: I524858fca33901ee2150c582bac16042148d2251
Approved-By: John Baldwin <jhb@FreeBSD.org>
2024-04-22 21:34:19 -04:00
Simon Marchi
18d2988e5d gdb, gdbserver, gdbsupport: remove includes of early headers
Now that defs.h, server.h and common-defs.h are included via the
`-include` option, it is no longer necessary for source files to include
them.  Remove all the inclusions of these files I could find.  Update
the generation scripts where relevant.

Change-Id: Ia026cff269c1b7ae7386dd3619bc9bb6a5332837
Approved-By: Pedro Alves <pedro@palves.net>
2024-03-26 21:13:22 -04:00
Simon Marchi
23acbfee6a gdbsupport: assume that compiler supports std::{is_trivially_constructible,is_trivially_copyable}
This code was there to support g++ 4, which didn't support
std::is_trivially_constructible and std::is_trivially_copyable.  Since
we now require g++ >= 9, I think it's fair to assume that GDB will
always be compiled with a compiler that supports those.

Change-Id: Ie7c1649139a2f48bf662cac92d7f3e38fb1f1ba1
2024-02-21 13:30:19 -05:00
Simon Marchi
aca8a74923 gdb: remove some GCC version checks
Since we now require C++17, and therefore gcc >= 9, it's no longer
useful to have gcc version checks for older gcc version.

Change-Id: I3a87baa03c475f2b847b422b16b69c5ff7215b54
Reviewed-by: Kevin Buettner <kevinb@redhat.com>
Approved-By: Pedro Alves <pedro@palves.net>
2024-02-21 13:30:17 -05:00
Simon Marchi
8480a37e14 gdb: pass frames as const frame_info_ptr &
We currently pass frames to function by value, as `frame_info_ptr`.
This is somewhat expensive:

 - the size of `frame_info_ptr` is 64 bytes, which is a bit big to pass
   by value
 - the constructors and destructor link/unlink the object in the global
   `frame_info_ptr::frame_list` list.  This is an `intrusive_list`, so
   it's not so bad: it's just assigning a few points, there's no memory
   allocation as if it was `std::list`, but still it's useless to do
   that over and over.

As suggested by Tom Tromey, change many function signatures to accept
`const frame_info_ptr &` instead of `frame_info_ptr`.

Some functions reassign their `frame_info_ptr` parameter, like:

  void
  the_func (frame_info_ptr frame)
  {
    for (; frame != nullptr; frame = get_prev_frame (frame))
      {
        ...
      }
  }

I wondered what to do about them, do I leave them as-is or change them
(and need to introduce a separate local variable that can be
re-assigned).  I opted for the later for consistency.  It might not be
clear why some functions take `const frame_info_ptr &` while others take
`frame_info_ptr`.  Also, if a function took a `frame_info_ptr` because
it did re-assign its parameter, I doubt that we would think to change it
to `const frame_info_ptr &` should the implementation change such that
it doesn't need to take `frame_info_ptr` anymore.  It seems better to
have a simple rule and apply it everywhere.

Change-Id: I59d10addef687d157f82ccf4d54f5dde9a963fd0
Approved-By: Andrew Burgess <aburgess@redhat.com>
2024-02-20 10:42:25 -05:00
Andrew Burgess
1d506c26d9 Update copyright year range in header of all files managed by GDB
This commit is the result of the following actions:

  - Running gdb/copyright.py to update all of the copyright headers to
    include 2024,

  - Manually updating a few files the copyright.py script told me to
    update, these files had copyright headers embedded within the
    file,

  - Regenerating gdbsupport/Makefile.in to refresh it's copyright
    date,

  - Using grep to find other files that still mentioned 2023.  If
    these files were updated last year from 2022 to 2023 then I've
    updated them this year to 2024.

I'm sure I've probably missed some dates.  Feel free to fix them up as
you spot them.
2024-01-12 15:49:57 +00:00
Tom Tromey
afdd136635 Back out some parallel_for_each features
Now that the DWARF reader does not use parallel_for_each, we can
remove some of the features that were added just for it: return values
and task sizing.

The thread_pool typed tasks feature could also be removed, but I
haven't done so here.  This one seemed less intrusive and perhaps more
likely to be needed at some point.
2024-01-08 18:40:22 -07:00
Tom Tromey
69f6730df3 Remove gdb_static_assert
C++17 makes the second parameter to static_assert optional, so we can
remove gdb_static_assert now.
2023-11-29 14:29:44 -07:00
Lancelot Six
393be56421 gdbsupport: Remove gdb::string_view
Now that all places using gdb::string_view have been updated to use
std::string_view, this patch drops the gdb::string_view implementation
and the tests which came with it.

As this drops the unittests/string_view-selftests.c, this also
implicitly solves PR build/23676, as pointed-out by Tom Tromey.

Change-Id: Idf5479b09e0ac536917b3f0e13aca48424b90df0
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23676
2023-11-21 11:52:36 +00:00
Lancelot Six
42742fc581 gdbsupport: remove gdb::optional
The previous patch migrated all the uses of gdb::optional to use
std::optional instead,  so gdb::optional can be removed entirely
as well as the self-tests which came with it.

Change-Id: I96ecd67b850b01be10ef00eb85a78ac647d5adc7
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
2023-11-21 11:52:35 +00:00
Lancelot Six
6b09f1342c gdb: Replace gdb::optional with std::optional
Since GDB now requires C++17, we don't need the internally maintained
gdb::optional implementation.  This patch does the following replacing:
  - gdb::optional -> std::optional
  - gdb::in_place -> std::in_place
  - #include "gdbsupport/gdb_optional.h" -> #include <optional>

This change has mostly been done automatically.  One exception is
gdbsupport/thread-pool.* which did not use the gdb:: prefix as it
already lives in the gdb namespace.

Change-Id: I19a92fa03e89637bab136c72e34fd351524f65e9
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net>
2023-11-21 11:52:35 +00:00
Lancelot Six
6b62451ad0 gdb: Use C++17's std::make_unique instead of gdb::make_unique
gdb::make_unique is a wrapper around std::make_unique when compiled with
C++17.  Now that C++17 is required, use std::make_unique directly in the
codebase, and remove gdb::make_unique.

Change-Id: I80b615e46e4b7c097f09d78e579a9bdce00254ab
Approved-By: Tom Tromey <tom@tromey.com>
Approved-By: Pedro Alves <pedro@palves.net
2023-11-21 11:52:35 +00:00
Simon Marchi
27b1f19f8f gdb: add inferior::{arch, set_arch}
Make the inferior's gdbarch field private, and add getters and setters.
This helped me by allowing putting breakpoints on set_arch to know when
the inferior's arch was set.  A subsequent patch in this series also
adds more things in set_arch.

Change-Id: I0005bd1ef4cd6b612af501201cec44e457998eec
Reviewed-By: John Baldwin <jhb@FreeBSD.org>
Approved-By: Andrew Burgess <aburgess@redhat.com>
2023-10-10 10:44:35 -04:00
Andrew Burgess
0b72cde372 gdb: add gdb::make_unique function
While GDB is still C++11, lets add a gdb::make_unique template
function that can be used to create std::unique_ptr objects, just like
the C++14 std::make_unique.

If GDB is being compiled with a C++14 compiler then the new
gdb::make_unique function will delegate to the std::make_unique.  I
checked with gcc, and at -O1 and above gdb::make_unique will be
optimised away completely in this case.

If C++14 (or later) becomes our minimum, then it will be easy enough
to go through the code and replace gdb::make_unique with
std::make_unique later on.

I've make use of this function in all the places I think this can
easily be used, though I'm sure I've probably missed some.

Should be no user visible changes after this commit.

Approved-By: Tom Tromey <tom@tromey.com>
2023-08-23 09:50:30 +01:00
Tom de Vries
84c9951ebd [gdb/build, c++20] Stop using deprecated is_pod
When building gdb with clang 15 and -std=c++20, I run into:
...
gdbsupport/poison.h:52:11: error: 'is_pod<timeval>' is deprecated: use \
  is_standard_layout && is_trivial instead [-Werror,-Wdeprecated-declarations]
            std::is_pod<T>>
                 ^
...

Fix this by following the suggestion.

Likewise in gdb/unittests/ptid-selftests.c.

Tested on x86_64-linux.
2023-08-17 10:41:34 +02:00
Tom Tromey
23e46b680f Revert "Simplify auto_load_expand_dir_vars and remove substitute_path_component"
This reverts commit 02601231fdd91a7bd4837ce202906ea2ce661489.

This commit was a refactoring to remove an xrealloc and simplify
utils.[ch].  However, it has a flaw -- it mishandles a substitution
like "$datadir/subdir".

I am backing out the patch in the interests of fixing the regression
before GDB 14.  It can be reinstated (with modifications) later if we
like.

Regression tested on x86-64 Fedora 36.
2023-07-14 10:35:49 -06:00
Tom de Vries
33b5899fc0 [gdb] Fix typos
Fix a few typos:
- implemention -> implementation
- convertion(s) -> conversion(s)
- backlashes -> backslashes
- signoring -> ignoring
- (un)ambigious -> (un)ambiguous
- occured -> occurred
- hidding -> hiding
- temporarilly -> temporarily
- immediatelly -> immediately
- sillyness -> silliness
- similiar -> similar
- porkuser -> pokeuser
- thats -> that
- alway -> always
- supercede -> supersede
- accomodate -> accommodate
- aquire -> acquire
- priveleged -> privileged
- priviliged -> privileged
- priviledges -> privileges
- privilige -> privilege
- recieve -> receive
- (p)refered -> (p)referred
- succesfully -> successfully
- successfuly -> successfully
- responsability -> responsibility
- wether -> whether
- wich -> which
- disasbleable -> disableable
- descriminant -> discriminant
- construcstor -> constructor
- underlaying -> underlying
- underyling -> underlying
- structureal -> structural
- appearences -> appearances
- terciarily -> tertiarily
- resgisters -> registers
- reacheable -> reachable
- likelyhood -> likelihood
- intepreter -> interpreter
- disassemly -> disassembly
- covnersion -> conversion
- conviently -> conveniently
- atttribute -> attribute
- struction -> struct
- resonable -> reasonable
- popupated -> populated
- namespaxe -> namespace
- intialize -> initialize
- identifer(s) -> identifier(s)
- expection -> exception
- exectuted -> executed
- dungerous -> dangerous
- dissapear -> disappear
- completly -> completely
- (inter)changable -> (inter)changeable
- beakpoint -> breakpoint
- automativ -> automatic
- alocating -> allocating
- agressive -> aggressive
- writting -> writing
- reguires -> requires
- registed -> registered
- recuding -> reducing
- opeartor -> operator
- ommitted -> omitted
- modifing -> modifying
- intances -> instances
- imbedded -> embedded
- gdbaarch -> gdbarch
- exection -> execution
- direcive -> directive
- demanged -> demangled
- decidely -> decidedly
- argments -> arguments
- agrument -> argument
- amespace -> namespace
- targtet -> target
- supress(ed) -> suppress(ed)
- startum -> stratum
- squence -> sequence
- prompty -> prompt
- overlow -> overflow
- memember -> member
- languge -> language
- geneate -> generate
- funcion -> function
- exising -> existing
- dinking -> syncing
- destroh -> destroy
- clenaed -> cleaned
- changep -> changedp (name of variable)
- arround -> around
- aproach -> approach
- whould -> would
- symobl -> symbol
- recuse -> recurse
- outter -> outer
- freeds -> frees
- contex -> context

Tested on x86_64-linux.

Reviewed-By: Tom Tromey <tom@tromey.com>
2023-06-03 22:43:57 +02:00
Tom Tromey
02601231fd Simplify auto_load_expand_dir_vars and remove substitute_path_component
This simplifies auto_load_expand_dir_vars to first split the string,
then do any needed substitutions.  This was suggested by Simon, and is
much simpler than the current approach.

Then this patch also removes substitute_path_component, as it is no
longer called.  This is nice because it helps with the long term goal
of removing utils.h.

Regression tested on x86-64 Fedora 36.
2023-05-05 07:49:43 -06:00
Tom Tromey
fade906daa Use SELF_CHECK in all unit tests
I noticed a few unit tests are using gdb_assert.  I think this was an
older style, before SELF_CHECK was added.  This patch switches them
over.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
2023-04-12 14:13:25 -06:00
Tom Tromey
7607de9431 Add operators and methods to gdb_mpq
This adds some operators and methods to gdb_mpq, in preparation for
making its implementation private.

This only adds the operators currently needed by gdb.  More could be
added as necessary.
2023-03-14 08:16:39 -06:00
Tom Tromey
302273ca84 Add methods and operators to gdb_mpz
This adds various methods and operators to gdb_mpz, as a step toward
hiding the implementation.

This only adds the operators that were needed.  Many more could be
added as required.
2023-03-14 08:16:39 -06:00
Tom Tromey
c8a67010d1 Clean up gmp-utils.h includes
gmp-utils.h includes "defs.h", but normally the rule in gdb is that
the .c files include this first.  This patch changes this code to
match the rest of gdb.
2023-03-14 08:16:39 -06:00
Simon Marchi
287de65625 gdb, gdbserver, gdbsupport: fix whitespace issues
Replace spaces with tabs in a bunch of places.

Change-Id: If0f87180f1d13028dc178e5a8af7882a067868b0
2023-03-09 16:32:00 -05:00
Simon Marchi
14ade91660 gdb: update some copyright years (2022 -> 2023)
The copyright years in the ROCm files (e.g. solib-rocm.c) are wrong,
they end in 2022 instead of 2023.  I suppose because I posted (or at
least prepared) the patches in 2022 but merged them in 2023, and forgot
to update the year.  I found a bunch of other files that are in the same
situation.  Fix them all up.

Change-Id: Ia55f5b563606c2ba6a89046f22bc0bf1c0ff2e10
Reviewed-By: Tom Tromey <tom@tromey.com>
2023-03-01 20:54:56 -05:00
Pedro Alves
8c4f70ffe7 enum_flags to_string
This commit introduces shared infrastructure that can be used to
implement enum_flags -> to_string functions.  With this, if we want to
support converting a given enum_flags specialization to string, we
just need to implement a function that provides the enumerator->string
mapping, like so:

 enum some_flag
   {
     SOME_FLAG1 = 1 << 0,
     SOME_FLAG2 = 1 << 1,
     SOME_FLAG3 = 1 << 2,
   };

 DEF_ENUM_FLAGS_TYPE (some_flag, some_flags);

 static std::string
 to_string (some_flags flags)
 {
   static constexpr some_flags::string_mapping mapping[] = {
     MAP_ENUM_FLAG (SOME_FLAG1),
     MAP_ENUM_FLAG (SOME_FLAG2),
     MAP_ENUM_FLAG (SOME_FLAG3),
   };
   return flags.to_string (mapping);
 }

.. and then to_string(SOME_FLAG2 | SOME_FLAG3) produces a string like
"0x6 [SOME_FLAG2 SOME_FLAG3]".

If we happen to forget to update the mapping array when we introduce a
new enumerator, then the string representation will pretty-print the
flags it knows about, and then the leftover flags in hex (one single
number).  For example, if we had missed mapping SOME_FLAG2 above, we'd
end up with:

  to_string(SOME_FLAG2 | SOME_FLAG3)  => "0x6 [SOME_FLAG2 0x4]");

Other than in the unit tests included, no actual usage of the
functionality is added in this commit.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
Change-Id: I835de43c33d13bc0c95132f42c3f97318b875779
2023-01-30 15:03:55 -05:00
Simon Marchi
908de5e671 gdb: make frame_info_ptr auto-reinflatable
This is the second step of making frame_info_ptr automatic, reinflate on
demand whenever trying to obtain the wrapper frame_info pointer, either
through the get method or operator->.  Make the reinflate method
private, it is used as a convenience method in those two.

Add an "is_null" method, because it is often needed to know whether the
frame_info_ptr wraps an frame_info or is empty.

Make m_ptr mutable, so that it's possible to reinflate const
frame_info_ptr objects.  Whether m_ptr is nullptr or not does not change
the logical state of the object, because we re-create it on demand.  I
believe this is the right use case for mutable.

Change-Id: Icb0552d0035e227f81eb3c121d8a9bb2f9d25794
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
2023-01-20 14:48:57 -05:00
Simon Marchi
93e39555dd gdb: make frame_info_ptr grab frame level and id on construction
This is the first step of making frame_info_ptr automatic.  Remove the
frame_info_ptr::prepare_reinflate method, move that code to the
constructor.

Change-Id: I85cdae3ab1c043c70e2702e7fb38e9a4a8a675d8
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
2023-01-20 14:48:57 -05:00
Simon Marchi
836a8d3710 gdb: make user-created frames reinflatable
This patch teaches frame_info_ptr to reinflate user-created frames
(frames created through create_new_frame, with the "select-frame view"
command).

Before this patch, frame_info_ptr doesn't support reinflating
user-created frames, because it currently reinflates by getting the
current target frame (for frame 0) or frame_find_by_id (for other
frames).  To reinflate a user-created frame, we need to call
create_new_frame, to make it lookup an existing user-created frame, or
otherwise create one.

So, in prepare_reinflate, get the frame id even if the frame has level
0, if it is user-created.  In reinflate, if the saved frame id is user
create it, call create_new_frame.

In order to test this, I initially enhanced the gdb.base/frame-view.exp
test added by the previous patch by setting a pretty-printer for the
type of the function parameters, in which we do an inferior call.  This
causes print_frame_args to not reinflate its frame (which is a
user-created one) properly.  On one machine (my Arch Linux one), it
properly catches the bug, as the frame is not correctly restored after
printing the first parameter, so it messes up the second parameter:

    frame
      baz (z1=hahaha, z2=<error reading variable: frame address is not available.>) at /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/frame-view.c:40
    40        return z1.m + z2.n;
    (gdb) FAIL: gdb.base/frame-view.exp: with_pretty_printer=true: frame
    frame
      baz (z1=hahaha, z2=<error reading variable: frame address is not available.>) at /home/simark/src/binutils-gdb/gdb/testsuite/gdb.base/frame-view.c:40
    40        return z1.m + z2.n;
    (gdb) FAIL: gdb.base/frame-view.exp: with_pretty_printer=true: frame again

However, on another machine (my Ubuntu 22.04 one), it just passes fine,
without the appropriate fix.  I then thought about writing a selftest
for that, it's more reliable.  I left the gdb.base/frame-view.exp pretty
printer test there, it's already written, and we never know, it might
catch some unrelated issue some day.

Change-Id: I5849baf77991fc67a15bfce4b5e865a97265b386
Reviewed-By: Bruno Larsen <blarsen@redhat.com>
2023-01-20 14:48:57 -05:00
Tom Tromey
63078a0498 Avoid submitting empty tasks in parallel_for_each
I found that parallel_for_each would submit empty tasks to the thread
pool.  For example, this can happen if the number of tasks is smaller
than the number of available threads.  In the DWARF reader, this
resulted in the cooked index containing empty sub-indices.  This patch
arranges to instead shrink the result vector and process the trailing
entries in the calling thread.
2023-01-17 07:03:26 -07:00
Joel Brobecker
213516ef31 Update copyright year range in header of all files managed by GDB
This commit is the result of running the gdb/copyright.py script,
which automated the update of the copyright year range for all
source files managed by the GDB project to be updated to include
year 2023.
2023-01-01 17:01:16 +04:00
Simon Marchi
de75275fe5 gdbsupport: change xml_escape_text_append's parameter from pointer to reference
The passed in string can't be nullptr, it makes more sense to pass in a
reference.

Change-Id: Idc8bd38abe1d6d9b44aa227d7856956848c233b3
2022-12-15 21:56:25 -05:00