Commit graph

48166 commits

Author SHA1 Message Date
Lancelot SIX
5bdd79dff9 gdb/testsuite: Remove duplicates from gdb.base/shlib-call.exp
When I run the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/shlib-call.exp ...
    DUPLICATE: gdb.base/shlib-call.exp: print g
    DUPLICATE: gdb.base/shlib-call.exp: set print sevenbit-strings
    DUPLICATE: gdb.base/shlib-call.exp: set print address off
    DUPLICATE: gdb.base/shlib-call.exp: set width 0
    DUPLICATE: gdb.base/shlib-call.exp: continue until exit

Fix by adjusting the test names when required, and by removing
un-necessary commands.

While at it, do some cleanup:
- Replace an explicit GDB restart sequence with a call to clean_restart.
- Remove trailing whitespaces.
- Use $gdb_test_name in gdb_test_multiple.

Tested on x86_64-linux.
2022-01-07 22:43:33 +00:00
Lancelot SIX
d95edb60be gdb/testsuite: Remove duplicates from gdb.base/set-cfd.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/set-cwd.exp ...
    DUPLICATE: gdb.base/set-cwd.exp: test_cwd_reset: continue to breakpoint: break-here

Fix by moving the tests after the 'runto_main' within the same
with_test_prefix scope.

While at it, I fix some indentation issues.

Tested on x86_64-linux.
2022-01-07 22:43:33 +00:00
Lancelot SIX
1868c0cb33 gdb/testsuite: Remove duplicates from gdb.base/exprs.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/exprs.exp ...
    DUPLICATE: gdb.base/exprs.exp: \$[0-9]* = red (setup)

Fix by using with_test_prefix where appropriate.

Tested on x86_64-linux.
2022-01-07 22:43:33 +00:00
Lancelot SIX
e88e167858 gdb/testsuite: Remove duplicates from gdb.base/readline.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/readline.exp ...
    DUPLICATE: gdb.base/readline.exp: Simple operate-and-get-next - final prompt

Fix by adjusting the prefix given to the second 'simple' call to
operate_and_get_next.

Tested on x86_64-linux.
2022-01-07 22:43:33 +00:00
Lancelot SIX
22dafa45d3 gdb/testsuite: Remove duplicates from gdb.base/pretty-array.exp
When I run the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/pretty-array.exp ...
    DUPLICATE: gdb.base/pretty-array.exp: print nums
    DUPLICATE: gdb.base/pretty-array.exp: print nums

Fix by giving a name to the test cases.

Tested on x86_64-linux.
2022-01-07 22:43:33 +00:00
Lancelot SIX
fdc3b97899 gdb/testsuite: Remove duplicates from gdb.base/ui-redirect.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/ui-redirect.exp ...
    DUPLICATE: gdb.base/ui-redirect.exp: redirect while already logging: set logging redirect off

Fix by moving the first 'set logging redirect off' to the end of the
previous [with_test_prefix] test block. The statement's purpose is to
clean the on flag set in this previous block, so moving it there makes
sense and does not change the sequence of commands in the test file.

Tested on x86_64-linux.
2022-01-07 22:43:33 +00:00
Lancelot SIX
86a8399998 gdb: completion-support.exp: improve leading whitespace support
There is a expect support library in the source tree designed to help
developers test the auto-completion capabilities of GDB.

One of the functions is test_gdb_complete_unique_re.  It is used
(usually indirectly via test_gdb_complete_unique) to test that a given
input line is completed as a given output line.  The test checks for two
ways to do the completion: using tab-completion, or using the
'complete' command.  To do this, calls to two dedicated functions are
performed.  If we omit few details, we can consider that a call to

    test_gdb_complete_unique $input $expected

is equivalent to the two following calls:

    test_gdb_complete_tab_unique $input $expected
    test_gdb_complete_cmd_unique $input $expected

When using the tab-completion, everything works as expected, but some
care must be taken when using the 'complete' command if the given input
has leading whitespaces.  In such situation, the output of the
'complete' command will drop the leading whitespaces.

The current approach is that in such situation, the input and expected
outputs are right trimmed (i.e. all leading whitespaces are removed)
when performing the command completion check.

This means that the following call:

    test_gdb_complete_unique "   $input" "   $expected"

is almost equivalent to (again, omitting few details and arguments):

    test_gdb_complete_tab_unique "   $input" "   $expected"
    test_gdb_complete_cmd_unique "$input" "$expected"

This approach comes with a problem that we encounter when running the
tests in complete-empty.exp.  When doing so, we have:

    Running .../gdb/testsuite/gdb.base/complete-empty.exp ...
    DUPLICATE: gdb.base/complete-empty.exp: empty-input-line: cmd complete ""

This is because the test file does something like:

    test_gdb_complete_unique "" "!" " " 1
    test_gdb_complete_unique "   " "   !" " " 1¬

which, if we do the substitution introduced above is equivalent to:

    test_gdb_complete_tab_unique "" "!"
    test_gdb_complete_cmd_unique "" "!"
    test_gdb_complete_tab_unique "   " "   !"
    test_gdb_complete_cmd_unique "" "!"

We see that the lines 2 and 4 are now the same, and for this reason the
testing framework complains about DUPLICATE test names.

To fix that, this commit proposes that instead of left trimming both
input and expected outputs, only the expected output is trimmed.

Care must be taken in the case the completion gives more possibilities
than allowed by the max-completions setting.  In this case, the input
will be repeated in the output in its left trimmed version.  This commit
also ensures that this is taken care of.

With this commit, the gdb.base/complete-empty.exp still passes all its
tests but does not report the DUPLICATE anymore.

Tested on x86_64-linux.
2022-01-07 22:43:33 +00:00
Lancelot SIX
0d3ca32797 gdb/testsuite: Remove duplicates from gdb.base/subst.exp
When I run the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/subst.ex ...
    DUPLICATE: gdb.base/subst.exp: unset substitute-path from, no rule entered yet

Fix by adjusting the problematic test name.

Tested on x86_64-linux.
2022-01-07 22:43:33 +00:00
Pedro Alves
ffd5d21ae2 gdb/testsuite: Remove duplicates from gdb.base/dfp-exprs.exp
When I run the testsuite, I have:

    Running ../gdb/testsuite/gdb.base/dfp-exprs.exp ...
    DUPLICATE: gdb.base/dfp-exprs.exp: p 1.2dl < 1.3df

Replace hand-written tests checking various comparison operators between
various decimal floating point types with a loop to programmatically
generate all the combinations.  This removes the need to eyeball for all
suffixes, which lead to the original duplication.

Also add a lot more combinations, testing all comparison operators
comprehensively.  The result is 262 unique tests vs 104 before this
patch.

Tested on x86_86-linux.

Change-Id: Id215a3d610aa8e032bf06ee160b5e3aed4a92d1e
2022-01-07 22:43:33 +00:00
Lancelot SIX
0988568e6a gdb/testsuite: Remove duplicates from gdb.base/ptype.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/ptype.exp ...
    DUPLICATE: gdb.base/ptype.exp: ptype the_highest
    DUPLICATE: gdb.base/ptype.exp: list intfoo
    DUPLICATE: gdb.base/ptype.exp: list charfoo

Fix by adjusting the offending test names.

Tested on x86_64-linux.
2022-01-07 22:43:33 +00:00
Lancelot SIX
0fb8b9ba93 gdb/testsuite: Remove duplicates from gdb.base/dfp-test.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/dfp-test.exp ...
    DUPLICATE: gdb.base/dfp-test.exp: 1.23E is an invalid number
    DUPLICATE: gdb.base/dfp-test.exp: 1.23E45A is an invalid number
    DUPLICATE: gdb.base/dfp-test.exp: 1.23E is an invalid number
    DUPLICATE: gdb.base/dfp-test.exp: 1.23E45A is an invalid number

Fix by using proc_with_prefix where appropriate.

Tested on x86_64-linux.
Co-Authored-By: Andrew Burgess <aburgess@redhat.com>
2022-01-07 22:43:33 +00:00
Lancelot SIX
d60bbc70c0 gdb/testsuite: Remove duplicates from gdb.base/del.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/del.exp ...
    DUPLICATE: gdb.base/del.exp: info break after removing break on main

Refactor slightly this test to run the various configurations under
foreach_with_prefix so each variant is automatically prefixed, ensuring
that the forgotten custom test name cannot happen.

Tested on x86_64-linux.
2022-01-07 22:43:33 +00:00
Lancelot SIX
7a6a961611 gdb/testsuite: Remove duplicates from gdb.base/solib-display.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/solib-display.exp ...
    DUPLICATE: gdb.base/solib-display.exp: NO: break 25
    DUPLICATE: gdb.base/solib-display.exp: NO: continue
    DUPLICATE: gdb.base/solib-display.exp: IN: break 25
    DUPLICATE: gdb.base/solib-display.exp: IN: continue
    DUPLICATE: gdb.base/solib-display.exp: SEP: break 25
    DUPLICATE: gdb.base/solib-display.exp: SEP: continue

The 'break 25' appears because the test inserts two breakpoints at the
same location.  Fix this by only inserting the breakpoint once.

Fix the 'continue' DUPLICATE by giving a phony name to the second
continue: 'continue two'.

While at it, this commit also removes a trailing space.

Tested on x86_64-linux.
2022-01-07 22:43:33 +00:00
Lancelot SIX
1182b42df6 gdb/testsuite: Remove duplicates from gdb.base/decl-before-def.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/decl-before-def.exp ...
    DUPLICATE: gdb.base/decl-before-def.exp: p a

Fix by giving explicit names to the two tests that use the same command.

Tested on x86_64-linux.
2022-01-07 22:43:32 +00:00
Lancelot SIX
08c8808ae2 gdb/testsuite: Remove duplicates from gdb.base/pending.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/pending.exp ...
    DUPLICATE: gdb.base/pending.exp: disable other breakpoints

Fix by adjusting the test names.

Tested on x86_64-linux.
2022-01-07 22:43:32 +00:00
Lancelot SIX
2bb68cff48 gdb/testsuite: Remove duplicates from gdb.base/checkpoint.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/checkpoint.exp ...
    DUPLICATE: gdb.base/checkpoint.exp: verify lines 5 two
    DUPLICATE: gdb.base/checkpoint.exp: restart 0 one

This patch fixes the various erroneous incorrect test names.

While at it, this patch also remove some trailing white spaces across
the file.

Tested on x86_64-linux.
2022-01-07 22:43:32 +00:00
Lancelot SIX
f4581a8826 gdb/testsuite: Remove duplicates from gdb.base/pie-fork.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/pie-fork.exp ...
    DUPLICATE: gdb.base/pie-fork.exp: test_no_detach_on_fork: continue

Fix by giving explicit names to the 'continue' commands that cause the
duplicate message.

Tested on x86_64-linux.
2022-01-07 22:43:32 +00:00
Lancelot SIX
f05f3e7235 gdb/testsuite: Remove duplicates from gdb.base/realname-expand.exp
When running the testsuite, I have:

    Running .../gdb/testsuite/gdb.base/realname-expand.exp ...
    DUPLICATE: gdb.base/realname-expand.exp: set basenames-may-differ on

This is due to the fact that the test restarts GDB twice and each time
sets the basenames-may-differ setting.  This patch proposes to fix this
by not restarting GDB so the setting is maintained.  It just clears the
breakpoints between the two tests and updates the breakpoints number as
required.

This patch also perform some minor refactorings to improve visibility.

Tested on x86_64-linux.
2022-01-07 22:43:32 +00:00
Lancelot SIX
27e9a99fa0 gdb/testsuite: Remove duplicates from gdb.base/interp.exp
When running the testsuite I have:

    Running .../gdb/testsuite/gdb.base/interp.exp ...
    DUPLICATE: gdb.base/interp.exp: interpreter-exec mi "-var-update *"

This is due to the fact that multiple successive instances of
gdb_test_multiple use 'pass $cmd', but one of them forgets to reset $cmd
to a new test name.

Fix by using 'pass $gdb_test_name', given that the gdb_test_name is set
by gdb_test_multiple.

While fixing this, this patch refactors all occurrences of the following
pattern:

    set cmd foo
    gdb_test_multiple $cmd $cmd {
        -re ... {
            pass $cmd
        }
    }

into

    gdb_test_multiple foo "" {
        -re ... {
            pass $gdb_test_name
         }
    }

This makes this test file coherent in its use of $gdb_test_name.

Tested on x86_64-linux.
2022-01-07 22:43:32 +00:00
Lancelot SIX
aaff91fdf2 gdb/testsuite: Remove duplicates from gdb.base/miscexprs.exp
When running the testsuite I see:

    Running .../gdb/testsuite/gdb.base/miscexprs.exp ...
    DUPLICATE: gdb.base/miscexprs.exp: print value of !ibig.i[100]
    DUPLICATE: gdb.base/miscexprs.exp: print value of !ibig.i[100]

This is due to an explicit test name repeated across multiple tests.
The actual test explicit names do not add much over the command from
wich default test names are derived.

Fix by removing the explicit test names across the file where they do
not add value.  While at doing some cleaning, also use $gdb_test_name in
the various uses of gdb_test_multiple.

Tested on x86_64-linux.
2022-01-07 22:43:32 +00:00
Lancelot SIX
3c1f0c735d gdb/testsuite: Remove duplicates from gdb.base/stack-checking.exp
When running the testsuite I have:

    Running .../gdb/testsuite/gdb.base/stack-checking.exp ...
    DUPLICATE: gdb.base/stack-checking.exp: bt
    DUPLICATE: gdb.base/stack-checking.exp: bt

Fix by using with_test_prefix.

Tested on x86_64-linux.
2022-01-07 22:43:32 +00:00
Andrew Burgess
d50964864b gdb/doc: shorten some source lines, and prevent some line breaks
Building on the previous commit, this makes use of a trailing @ to
split long @deffn lines in the guile.texi source file.  This splitting
doesn't change how the document is laid out by texinfo.

I have also wrapped keyword and argument name pairs in @w{...} to
prevent line breaks appearing between the two.  I've currently only
done this for the longer @deffn lines, where a line break is
possible.  This makes the @deffn lines much nicer to read in the
generated pdf.
2022-01-07 14:42:35 +00:00
Andrew Burgess
8af9b8009b gdb/doc: Remove (...) around guile procedure names in @deffn lines
Most guile procedures in the guile.texi file are defined like:

  @deffn {Scheme Procedure} name arg1 arg2 arg3

But there are two places where we do this:

  @deffn {Scheme Procedure} (name arg1 arg2 arg3)

Notice the added (...).  Though this does represent how a procedure
call is written in scheme, it's not the normal style throughout the
manual.  I also checked the 'info guile' info page to see how they
wrote there declarations, and they use the first style too.

The second style also has the drawback that index entries are added as
'(name', and so they are grouped in the '(' section of the index,
which is not very user friendly.

In this commit I've changed the definitions of make-command and
make-parameter to use the first style.

The procedure declaration lines can get pretty long with all of the
arguments, and this was true for both of the procedures I am changing
in this commit.  I have made use of a trailing '@' to split the deffn
lines, and keep them under 80 characters in the texi source.  This
makes no difference to how the final document looks.

Finally, our current style for keyword arguments, appears to be:

  [#:keyword-name argument-name]

I don't really understand the reason for this, 'info guile' just seems
to use:

  [#:keyword-name]

which seems just as good to me.  But I don't propose to change
that just now.  What I do notice though, is that sometimes, texinfo
will place a line break between the keyword-name and the
argument-name, for example, the pdf of make-command is:

  make-command name [#:invoke invoke] [#:command-class
    command-class] [#:completer-class completer] [#:prefix? prefix] [#:doc
    doc-string]

Notice the line break after '#:command-class' and after '#:doc',
neither of which are ideal.  And so, for the two commands I am
changing in this commit, I have made use of @w{...} to prevent line
breaks between the keyword-name and the argument-name.  Now the pdf
looks like this:

  make-command name [#:invoke invoke]
    [#:command-class command-class] [#:completer-class completer]
    [#:prefix? prefix] [#:doc doc-string]

Which seems much better.  I'll probably update the other deffn lines
at some point.
2022-01-07 14:38:39 +00:00
Tom Tromey
41e321a897 Use target_announce_detach in more targets
target_announce_detach was added in commit 0f48b757 ("Factor out
"Detaching from program" message printing").  There, Pedro wrote:

    (For now, I left the couple targets that print this a bit differently
    alone.  Maybe this could be further pulled out into infcmd.c.  If we
    did that, and those targets want to continue printing differently,
    this new function could be converted to a target method.)

It seems to me that the differences aren't very big, and in some cases
other targets handled the output a bit more nicely.  In particular,
some targets will print a different message when exec_file==NULL,
rather than printing the same output with an empty string as
exec_file.

This patch incorporates the nicer output into target_announce_detach,
then changes the remaining ports to use this function.
2022-01-06 08:56:20 -07:00
Tom Tromey
bc521517b7 Introduce target_announce_attach
This introduces target_announce_attach, by analog with
target_announce_detach.  Then it converts existing targets to use
this, rather than emitting their own output by hand.
2022-01-06 08:56:20 -07:00
Andrew Burgess
10a85f29c7 gdb: make use add_setshow_prefix_cmd in gnu-nat.c
In gnu-nat.c we currently implement some set/show prefix commands
"manually", that is, we call add_prefix_cmd, and assign a set and show
function to each prefix command.

These set/show functions print an error indicating that the user
didn't type a complete command.

If we instead switch to using add_setshow_prefix_cmd then we can
delete the set/show functions, GDB provides some default functions,
which give a nice help style summary that lists all of the available
sub-commands, along with a one line summary of what each does.

Though this clearly changes the existing behaviour, I think this
change is acceptable as the new behaviour is more inline with other
set/show prefix commands, and the new behaviour is more informative.

This change will conflict with Tom's change here:

  https://sourceware.org/pipermail/gdb-patches/2022-January/184724.html

Where Tom changes the set/show functions that I delete.  My suggestion
is that the set/show functions still be deleted even after Tom's
patch (or instead of Tom's patch).

For testing I've build GDB on GNU/Hurd, and manually tested these
functions.  I did a grep over the testsuite, and don't believe the
existing error messages are being checked for in any tests.
2022-01-06 15:44:50 +00:00
Tom Tromey
390abcd903 Use warning in windows-nat error messages
A warning in windows-nat.c can be converted to use the warning
function.  As a side effect, this arranges for the output to be sent
to gdb_stderr.
2022-01-06 08:37:19 -07:00
Tom Tromey
5bd1d4c158 Clean up some dead code in windows-tdep.c
windows-tdep.c checks the result of xmalloc, which isn't necessary.  I
initially removed this dead check, but then went a bit further and
modified the code so that some "goto"s and explicit memory management
could be removed.  Then, I added a couple of missing bounds checks.

I believe this also fixes a possible bug with a missing 0-termination
of a string.  I am not certain, but that is why I think the existing
code allocates a buffer that is 1 byte too long -- but then it fails
to set this byte to 0.
2022-01-06 08:37:19 -07:00
Tom Tromey
5220f61a22 Avoid crash in language_info
language_info calls:

  show_language_command (NULL, 1, NULL, NULL);

... "knowing" that show_language_command does not use its ui_file
parameter.  However, this was changed in commit 7514a661
("Consistently Use ui_file parameter to show callbacks").

This patch changes language_info to pass a ui_file.

It took a while to write the test -- this function is only called when
'verbose' is on and when switching the "expected" language in auto
mode.
2022-01-06 07:54:30 -07:00
Tom Tromey
d8504344d4 Fix some failures in langs.exp
langs.exp currently has some fails for me because the stack trace
includes full paths to the source files.

    FAIL: gdb.base/langs.exp: up to foo in langs.exp
    FAIL: gdb.base/langs.exp: up to cppsub_ in langs.exp
    FAIL: gdb.base/langs.exp: up to fsub in langs.exp

This fixes the failures by making the filename regexps a bit more lax.
2022-01-06 07:54:30 -07:00
Lancelot SIX
1f927a4a28 gdb: Fix copyright year in gdb/testsuite/gdb.base/inferior-clone.exp
I just realized that I forgot to update the year before pushing the
patch that created this file.  Since it landed after the global
copyright year update have been done, this file’s copyright year is
updated.

This patch fixes that.

Change-Id: I280f7d86e02d38425f7afdcf19a1c3500d51c23f
2022-01-06 06:59:25 -05:00
Tom Tromey
d4be21dce7 Change riscv_return_value to use RETURN_VALUE_ABI_PRESERVES_ADDRESS
Internally, AdaCore has a test that is equivalent to (really a direct
translation of) gdb.base/gnu_vector.exp.  On 32-bit RISC-V, the
"return" part of this test fails.

Joel tracked this down to riscv_return_value returning
RETURN_VALUE_ABI_RETURNS_ADDRESS.  Using
RETURN_VALUE_ABI_PRESERVES_ADDRESS is more correct here, and fixes the
bug.

I tested this for both 32- and 64-bit RISC-V using the AdaCore
internal test suite, and Andrew Burgess tested it using
gnu_vector.exp.
2022-01-05 12:35:42 -07:00
Tom Tromey
729a211143 Filtered output cleanup in expression dumping
Most of the expression-dumping code uses filtered output, but a few
functions did not.  This patch cleans up these instance.

Note that this won't cause any behavior change, because the only calls
to dump_prefix_expression pass in gdb_stdlog.  However, in the long
run it's easier to audit the code if the number of uses of _unfiltered
is reduced.
2022-01-05 11:36:33 -07:00
Tom Tromey
50f5d5c34d Use filtered output in terminal_info implementations
This changes one terminal_info implementation, and
default_terminal_info, to use filtered output.  Other implementations
of this method already use filtered output.

I can't compile go32-nat.c, so this is a 'best effort' patch.
2022-01-05 11:36:33 -07:00
Tom Tromey
d487ae28ce Use filtered output in gnu-nat.c commands
gnu-nat.c has a number of ordinary commands that should use filtered
output.  In a few cases, I changed the output to use gdb_stderr as
well.  I can't compile this file, so this patch is split out as a
"best effort".
2022-01-05 11:36:33 -07:00
Tom Tromey
56c5b29b61 Use filtered output in *-tdep commands
Various targets introduce their own commands, which then use
unfiltered output.  It's better to use filtered output by default, so
this patch fixes the instances I found.
2022-01-05 11:36:33 -07:00
Tom Tromey
7f762abff6 Use filtered output in btrace-related commands
This changes btrace.c and record-btrace.c to use filtered output in
the commands implemented there.
2022-01-05 11:36:33 -07:00
Tom Tromey
7befbbd4c3 Use filtered output in some dumping commands
There are several commands that may optionally send their output to a
file -- they take an optional filename argument and open a file.  This
patch changes these commands to use filtered output.  The rationale
here is that, when printing to gdb_stdout, filtering is appropriate --
it is, and should be, the default for all commands.  And, when writing
to a file, paging will not happen anyway (it only happens when the
stream==gdb_stdout), so using the _filtered form will not change
anything.
2022-01-05 11:36:33 -07:00
Tom Tromey
34fda50bee Use filtered output in kill command
This changes the kill command to use filtered output.  I split this
one into its own patch because, out of an abundance of caution, I
changed the function to call bfd_cache_close_all a bit earlier, in
case pagination caused an exception.
2022-01-05 11:36:33 -07:00
Tom Tromey
b58f47ab4c Use filtered output in ordinary commands
Many otherwise ordinary commands choose to use unfiltered output
rather than filtered.  I don't think there's any reason for this, so
this changes many such commands to use filtered output instead.

Note that complete_command is not touched due to a comment there
explaining why unfiltered output is believed to be used.
2022-01-05 11:36:33 -07:00
Tom Tromey
b68178b9cb Use filtered output in language_info
Change language_info to use filtered output.  This is ok because the
sole caller uses filtered output elsewhere, and because this function
calls show_language_command, which also uses filtered output.
2022-01-05 11:36:22 -07:00
Tom Tromey
a037434531 Use filtered output in files_info implementations
This changes the implementations of the target files_info method to
use filtered output.  This makes sense because the sole caller of this
method is an ordinary command (info_program_command).  This patch
changes this command to use filtered output as well.
2022-01-05 11:36:22 -07:00
Tom Tromey
ec2770563a Use filtered output in target-descriptions.c
target-descriptions.c uses unfiltered output.  However, if you happen
to invoke this command interactively, it's probably better for it to
use filtering.  For non-interactive use, this doesn't matter.
2022-01-05 11:08:44 -07:00
Tom Tromey
a1ea4cacd4 Use filtered output for gdbarch dump
This changes gdbarch dumping to use filtered output.  This seems a bit
better to me, both on the principle that this is an ordinary command,
and because the output can be voluminous, so it may be nice to stop in
the middle.
2022-01-05 11:08:44 -07:00
Tom Tromey
d53fd721a1 Implement putstr and putstrn in ui_file
In my tour of the ui_file subsystem, I found that fputstr and fputstrn
can be simplified.  The _filtered forms are never used (and IMO
unlikely to ever be used) and so can be removed.  And, the interface
can be simplified by removing a callback function and moving the
implementation directly to ui_file.

A new self-test is included.  Previously, I think nothing was testing
this code.

Regression tested on x86-64 Fedora 34.
2022-01-05 11:01:02 -07:00
Tom Tromey
28a4e64dd1 Change how versioned symbols are recorded
A change to BFD caused a gdb regression when using the Ada "catch
exception" feature.  The bug is visible when a shared library throws
an exception that is caught in the main executable.

This was discussed here:

https://sourceware.org/pipermail/binutils/2021-July/117538.html

This patch implements Alan's proposed fix, namely to use VERSYM_HIDDEN
rather than the name when deciding to install a version-less symbol.

The internal test case is identical to the catch_ex_std.exp that is
in-tree, so I haven't added a new test.  I could not make that one
fail on x86-64 Linux, though.  It's possible that maybe I'd have to
update the system linker first, but I didn't want to try that.

Regression tested on x86-64 Fedora 32.
2022-01-05 10:44:53 -07:00
Hannes Domani
72df4c816f Fix inferior_thread attribute in new_thread event
Commit 72ee03ff58 fixed a use-after-move bug in add_thread_object, but
it changed the inferior_thread attribute to contain the inferior instead
of the actual thread.
This now uses the thread_obj in its new location instead.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=28429
2022-01-05 18:35:20 +01:00
Tom Tromey
63a8c05f09 Simplify execute_control_commands_to_string
execute_control_commands_to_string can be rewritten in terms of
execute_fn_to_string, which consolidates some knowledge about which
streams to redirect.

Regression tested on x86-64 Fedora 34.
2022-01-05 10:19:45 -07:00
Tom Tromey
ffcc2b69d1 Do not print anything when self-backtrace unavailable
Right now, gdb's self-backtrace feature will still print something
when a backtrace is unavailable:

   sig_write (_("----- Backtrace -----\n"));
[...]
     sig_write (_("Backtrace unavailable\n"));
    sig_write ("---------------------\n");

However, if GDB_PRINT_INTERNAL_BACKTRACE is undefined, it seems better
to me to print nothing at all.

This patch implements this change.  It also makes a couple of other
small changes in this same module: it adds a header guard to
bt-utils.h, and it protects the definitions of
gdb_internal_backtrace_1 with a check of GDB_PRINT_INTERNAL_BACKTRACE.
2022-01-05 10:08:15 -07:00
Tom Tromey
93f3b8eeaa Fix pager regression
The patch to fix paging with redirection caused a regression in the
internal AdaCore test suite.  The problem occurs when running an MI
command from the CLI using interpreter-exec, when paging is enabled.
This scenario isn't covered by the current test suite, so this patch
includes a new test.

The problem is that, in this situation, MI does:

  fputs_unfiltered (strcmp (context->command, "target-select") == 0
		     ? "^connected" : "^done", mi->raw_stdout);

Here raw_stdout is a stdio_file wrapping stdout, so the pager thinks
that it is ok to buffer the output.  However, in this setup, it isn't
ok, and flushing the wrap buffer doesn't really work properly.  Also,
MI next does:

  mi_out_put (uiout, mi->raw_stdout);

... but this uses ui_file::write, which also doesn't flush the wrap
buffer.

I think all this will be fixed by the pager rewrite series I'm working
on.  However, in the meantime, adding the old gdb_stdout check back to
the pager fixes this problem.

Regression tested on x86-64 Fedora 34.
2022-01-05 06:49:08 -07:00