Commit Graph

104900 Commits

Author SHA1 Message Date
Andrew Burgess
73d4725f21 sim/rx: mark some functions as static
Some functions that should be marked static.

sim/rx/ChangeLog:

	* fpu.c (check_exceptions): Make static.
	* gdb-if.c (handle_step): Likewise.
	* mem.c (mem_put_byte): Likewise.
2021-02-08 11:01:07 +00:00
Andrew Burgess
1c3e93a41f sim/rx: fill in missing 'void' for empty argument lists
Ensure we have 'void' inside empty argument lists.  This was causing
several warnings for the rx simulator.

sim/rx/ChangeLog:

	* cpu.h (trace_register_changes): Add void parameter type.
	* err.c (ee_overrides): Likewise.
	* mem.c (mem_usage_stats): Likewise.
	(e): Likewise.
	* reg.c (stack_heap_stats): Likewise.
	* rx.c (pop): Likewise.
	(poppc): Likewise.
	(decode_opcode): Likewise.
	* syscalls.c (arg): Likewise.
2021-02-08 11:01:07 +00:00
Andrew Burgess
93a01471f3 sim/rx: fix an issue where we try to modify a const string
While experimenting with switching on warnings for the rx simulator I
discovered this bug.  In sim_do_command we get passed a 'const char *'
argument.  We create a copy of this string to work with locally, but
then while processing this we accidentally switch back to reference
the original string.

sim/rx/ChangeLog:

	* gdb-if.c (sim_do_command): Work with a copy of the command.
2021-02-08 11:01:07 +00:00
Andrew Burgess
0309f9549d sim/rx: define sim_memory_map
The rx simulator doesn't define sim_memory_map and so fails to link
with GDB.  Define it now to return NULL, this can be extended later to
return an actual memory map if anyone wants this functionality.

sim/rx/ChangeLog:

	* gdb-if.c (sim_memory_map): New function.
2021-02-08 11:01:07 +00:00
Andrew Burgess
cd074e0415 gdb/tui: fix issue with handling the return character
My initial goal was to fix our gdb/testsuite/lib/tuiterm.exp such that
it would correctly support (some limited) scrolling of the command
window.

What I observe is that when sending commands to the tui command window
in a test script with:

  Term::command "p 1"

The command window would be left looking like this:

  (gdb)
  (gdb) p 1$1 = 1
  (gdb)

When I would have expected it to look like this:

  (gdb) p 1
  $1 = 1
  (gdb)

Obviously a bug in our tuiterm.exp library, right???

Wrong!

Turns out there's a bug in GDB.

If in GDB I enable the tui and then type (slowly) the 'p 1\r' (the \r
is pressing the return key at the end of the string), then you do
indeed get the "expected" terminal output.

However, if instead I copy the 'p 1\r' string and paste it into the
tui in one go then I now see the same corrupted output as we do when
using tuiterm.exp.

It turns out the problem is that GDB fails when handling lots of input
arriving quickly with a \r (or \n) on the end.

The reason for this bug is as follows:

When the tui is active the terminal is in no-echo mode, so characters
sent to the terminal are not echoed out again.  This means that when
the user types \r, this is not echoed to the terminal.

The characters read in are passed to readline and \r indicates that
the command line is complete and ready to be processed.  However, the
\r is not included in readlines command buffer, and is NOT printed by
readline when is displays its buffer to the screen.

So, in GDB we have to manually spot the \r when it is read in and
update the display.  Printing a newline character to the output and
moving the cursor to the next line.  This is done in tui_getc_1.

Now readline tries to reduce the number of write calls.  So if we very
quickly (as in paste in one go) the text 'p 1' to readline (this time
with no \r on the end), then readline will fetch the fist character
and add it to its internal buffer.  But before printing the character
out readline checks to see if there's more input incoming.  As we
pasted multiple characters, then yes, readline sees the ' ' and adds
this to its buffer, and finally the '1', this too is added to the
buffer.

Now if at this point we take a break, readline sees there is no more
input available, and so prints its buffer out.

Now when we press \r the code in tui_getc_1 kicks in, adds a \n to the
output and moves the cursor to the next line.

But, if instead we paste 'p 1\r' in one go then readline adds 'p 1' to
its buffer as before, but now it sees that there is still more input
available.  Now it fetches the '\r', but this triggers the newline
behaviour, we print '\n' and move to the next line - however readline
has not printed its buffer yet!

So finally we end up on the next line.  There's no more input
available so readline prints its buffer, then GDB gets passed the
buffer, handles it, and prints the result.

The solution I think is to put of our special newline insertion code
until we know that readline has finished printing its buffer.  Handily
we know when this is - the next thing readline does is pass us the
command line buffer for processing.  So all we need to do is hook in
to the command line processing, and before we pass the command line to
GDB's internals we do all of the magic print a newline and move the
cursor to the next line stuff.

Luckily, GDB's interpreter mechanism already provides the hooks we
need to do this.  So all I do here is move the newline printing code
from tui_getc_1 into a new function, setup a new input_handler hook
for the tui, and call my new newline printing function.

After this I can enable the tui and paste in 'p 1\r' and see the
correct output.

Also the tuiterm.exp library will now see non-corrupted output.

gdb/ChangeLog:

	* tui/tui-interp.c (tui_command_line_handler): New function.
	(tui_interp::resume): Register tui_command_line_handler as the
	input_handler.
	* tui/tui-io.c (tui_inject_newline_into_command_window): New
	function.
	(tui_getc_1): Delete handling of '\n' and '\r'.
	* tui-io.h (tui_inject_newline_into_command_window): Declare.

gdb/testsuite/ChangeLog:

	* gdb.tui/scroll.exp: Tighten expected results.  Remove comment
	about bug in GDB, update expected results, and add more tests.
2021-02-08 09:51:46 +00:00
Andrew Burgess
5fb9763991 gdb/testsuite: fix implementation of delete line in tuiterm.exp
The implementation of the delete line escape sequence in tuiterm.exp
was wrong.  Delete should take a count and then delete COUNT lines at
the current cursor location, all remaining lines in the scroll region
are moved up to replace the deleted lines, with blank lines being
added at the end of the scroll region.

It's not clear to me what "scroll region" means here (or at least how
that is defined), but for now I'm just treating the whole screen as
the scroll region, which seems to work fine.

In contrast the current broken implementation deletes COUNT lines at
the cursor location moving the next COUNT lines up to fill the gap.
The rest of the screen is then cleared.

gdb/testsuite/ChangeLog:

	* gdb.tui/scroll.exp: New file.
	* gdb.tui/tui-layout-asm-short-prog.exp: Update expected results.
	* lib/tuiterm.exp (Term::_csi_M): Delete count lines, scroll
	remaining lines up.
	(Term::check_region_contents): New proc.
	(Term::check_box_contents): Use check_region_contents.
2021-02-08 09:51:45 +00:00
GDB Administrator
d6f2700b48 Automatic date update in version.in 2021-02-08 00:00:11 +00:00
H.J. Lu
38a143aa8c ld: Remove x86 ISA level run-time tests
Remove x86 ISA level run-time tests since with glibc 2.33, they will fail
to run on machines with lesser x86 ISA level:

tmpdir/property-5-pie: CPU ISA level is lower than required

	PR ld/27358
	* testsuite/ld-i386/i386.exp: Remove property 3/4/5 run-time
	tests.
	* testsuite/ld-x86-64/x86-64.exp: Likewise.
2021-02-07 13:12:42 -08:00
Hannes Domani
4cf28e918a Don't draw register sub windows outside the visible area
If the regs window is not big enough to show all registers, the
registers whose values changed are always drawn, even if they are not
in the currently visible area.

So this marks the invisible register sub windows with y=0, and skips
their rerender call in check_register_values.

gdb/ChangeLog:

2021-02-07  Hannes Domani  <ssbssa@yahoo.de>

	* tui/tui-regs.c (tui_data_window::display_registers_from):
	Mark invisible register sub windows.
	(tui_data_window::check_register_values): Ignore invisible
	register sub windows.
2021-02-07 19:13:45 +01:00
Hannes Domani
3537bc23d9 Don't fill regs window with a negative number of spaces
Function n_spaces can't handle negative values, and returns an invalid
pointer in this case.

gdb/ChangeLog:

2021-02-07  Hannes Domani  <ssbssa@yahoo.de>

	* tui/tui-regs.c (tui_data_item_window::rerender): Don't call
	n_spaces with a negative value.
2021-02-07 19:11:53 +01:00
Hannes Domani
5fc2d6aa06 Refresh regs window in display_registers_from
Otherwise the register window is redrawn empty when scrolling or
changing its size with winheight.

gdb/ChangeLog:

2021-02-07  Hannes Domani  <ssbssa@yahoo.de>

	* tui/tui-regs.c (tui_data_window::display_registers_from):
	Add refresh_window call.
2021-02-07 19:10:17 +01:00
Hannes Domani
83962f8340 Also compare frame_id_is_next in frapy_richcompare
The last frame in a corrupt stack stores the frame_id of the next frame,
so these two frames currently compare as equal.

So if you have a backtrace where the oldest frame is corrupt, this happens:

(gdb) py
 >f = gdb.selected_frame()
 >while f.older():
 >  f = f.older()
 >print(f == f.newer())
 >end
True

With this change, that same example returns False.

gdb/ChangeLog:

2021-02-07  Hannes Domani  <ssbssa@yahoo.de>

	* python/py-frame.c (frapy_richcompare): Compare frame_id_is_next.
2021-02-07 19:08:23 +01:00
Alan Modra
de8d420310 asan: unwind-ia64.c: stack buffer overflow
Printing "invalid" is better than printing an uninitialised buffer
and occasionally running off the end of the buffer.

	* unwind-ia64.c (unw_print_xyreg): Don't leave output buffer
	uninitialised on invalid input.
2021-02-07 14:49:19 +10:30
GDB Administrator
cca043e071 Automatic date update in version.in 2021-02-07 00:00:10 +00:00
Tom de Vries
c0e5674584 [gdb/testsuite] Fix gdb.tui/tui-layout-asm.exp with -m32
When running test-case gdb.tui/tui-layout-asm.exp with target board
unix/-m32, we run into:
...
FAIL: gdb.tui/tui-layout-asm.exp: scroll to end of assembler (scroll failed)
...

Comparing screen dumps (edited a bit to fit column width) before:
...
 0 +--------------------------------------------------------------------+
 1 | 0x8049194 <__libc_csu_init+68>  call   *-0x104(%ebp,%esi,4)        |
 2 | 0x804919b <__libc_csu_init+75>  add    $0x1,%esi                   |
 3 | 0x804919e <__libc_csu_init+78>  add    $0x10,%esp                  |
 4 | 0x80491a1 <__libc_csu_init+81>  cmp    %esi,%ebx                   |
 5 | 0x80491a3 <__libc_csu_init+83>  jne    0x8049188 <__...>           |
 6 | 0x80491a5 <__libc_csu_init+85>  add    $0xc,%esp                   |
 7 | 0x80491a8 <__libc_csu_init+88>  pop    %ebx                        |
 8 | 0x80491a9 <__libc_csu_init+89>  pop    %esi                        |
 9 | 0x80491aa <__libc_csu_init+90>  pop    %edi                        |
10 | 0x80491ab <__libc_csu_init+91>  pop    %ebp                        |
11 | 0x80491ac <__libc_csu_init+92>  ret                                |
12 | 0x80491ad                           lea    0x0(%esi),%esi          |
13 | 0x80491b0 <__libc_csu_fini>     ret                                |
14 +--------------------------------------------------------------------+
...
and after:
...
 0 +--------------------------------------------------------------------+
 1 | 0x804919b <__libc_csu_init+75>          add    $0x1,%esi           |
 2 | 0x804919e <__libc_csu_init+78>          add    $0x10,%esp          |
 3 | 0x80491a1 <__libc_csu_init+81>          cmp    %esi,%ebx           |
 4 | 0x80491a3 <__libc_csu_init+83>          jne    0x8049188 <__...>   |
 5 | 0x80491a5 <__libc_csu_init+85>          add    $0xc,%esp           |
 6 | 0x80491a8 <__libc_csu_init+88>          pop    %ebx                |
 7 | 0x80491a9 <__libc_csu_init+89>          pop    %esi                |
 8 | 0x80491aa <__libc_csu_init+90>          pop    %edi                |
 9 | 0x80491ab <__libc_csu_init+91>          pop    %ebp                |
10 | 0x80491ac <__libc_csu_init+92>          ret                        |
11 | 0x80491ad                                   lea    0x0(%esi),%esi  |
12 | 0x80491b0 <__libc_csu_fini>             ret                        |
13 | 0x80491b1 <__x86.get_pc_thunk.bp>       mov    (%esp),%ebp         |
14 +--------------------------------------------------------------------+
...
it seems the mismatch comes from the extra indentation forced by the longer
<__x86.get_pc_thunk.bp> that was scrolled in.

Fix this by ignoring whitespace when comparing scrolled lines.

Tested on x86_64-linux, using -m64 and -m32.

gdb/testsuite/ChangeLog:

2021-02-06  Tom de Vries  <tdevries@suse.de>

	PR testsuite/26922
	* gdb.tui/tui-layout-asm.exp: Ignore whitespace mismatches when
	scrolling.
2021-02-06 23:22:03 +01:00
Mike Frysinger
7a9bd3b4e2 sim: erc32/m32c/rl78: add sim_memory_map stub for gdb
These ports don't use the common sim core, so they weren't providing
a sim_memory_map for gdb, so they failed to link with the new memory
map logic added for the sim.  Add stubs to fix.
2021-02-06 12:15:34 -05:00
Mike Frysinger
4c0d76b9c4 sim: watchpoints: use common sim_pc_get
Few arches implement STATE_WATCHPOINTS()->pc while all of them implement
sim_pc_get.  Lets switch the sim-watch core for monitoring pc events to
the sim_pc_get API so this module works for all ports, and then we can
delete this old back channel of snooping in the port's cpu state -- the
code needs the pointer to the pc storage so that it can read out bytes
and compare them to the watchrange.

This also fixes the logic on multi-cpu sims by removing the limitation
of only being able to watch CPU0's state.
2021-02-06 12:12:51 -05:00
Mike Frysinger
cd89c53f6d sim: add ChangeLog entries for last commits 2021-02-06 12:07:08 -05:00
Mike Frysinger
8e25beb4af sim: igen: drop libiberty linkage
This dir doesn't use anything from libiberty, so drop the linkage.
2021-02-06 12:01:40 -05:00
Mike Frysinger
7a36eeea26 sim: common: switch AC_CONFIG_HEADERS
The AC_CONFIG_HEADER macro is long deprecated, so switch to the
newer form.  This also gets rid of the position limitation, and
drops support for an argument to SIM_AC_COMMON which we haven't
used anywhere.
2021-02-06 12:00:42 -05:00
Mike Frysinger
aa09469fc6 sim: drop use of bfd/configure.host
These settings might have made sense in darker compiler times, but I
think they're largely obsolete now.  Looking through the values that
get used in HDEFINES, it's quite limited, and configure itself should
handle them.  If we still need something, we can leverage standard
autoconf macros instead, after we get a clear user report.

TDEFINES was never set anywhere and was always empty, so prune that.
2021-02-06 10:56:11 -05:00
GDB Administrator
2c6f2aa664 Automatic date update in version.in 2021-02-06 00:00:14 +00:00
Alan Modra
51a2525281 PR27349, ar breaks symlinks
PR 27349
	* rename.c (smart_rename): Test for existence and type of output
	file with lstat.
2021-02-06 07:28:21 +10:30
Paul E. Murphy
9c9d63b15a gnulib: update to 776af40e0
This fixes PR27184, a failure to compile gdb due to
cdefs.h being out of sync with glibc on ppc64le targets
which are compiled with -mabi=ieeelongdouble and glibc
2.32.

Likewise, update usage of _GL_ATTRIBUTE_FORMAT_PRINTF to
_GL_ATTRIBUTE_FORMAT_PRINTF_STANDARD.

Likewise, disable newly added rpl_free gnulib api in
gdbserver support libraries.

Likewise, undefine read/write macros before redefining them
on mingw targets.

Likewise, wrap C++ usage of free with GNULIB_NAMESPACE namespace
as needed.

Change-Id: I86517613c0d8ac8f5ea45bbc4ebe2b54a3aef29f
2021-02-05 13:35:20 -05:00
Simon Marchi
0110ec824e gdb: symmisc.c: remove std_{in,out,err}
These are likely not very useful, remove them.

gdb/ChangeLog:

	* symmisc.c (std_in, std_out, std_err): Remove.
	(_initialize_symmisc): Don't set std_in, std_out and std_err.

Change-Id: I140bfffd7fb655d39c32333bb53924b91b1eb13c
2021-02-05 13:06:33 -05:00
Tom de Vries
7c6944ab9b [gdb/breakpoints] Handle glibc with debuginfo in create_exception_master_breakpoint
The test-case nextoverthrow.exp is failing on targets with unstripped libc.

This is a regression since commit 1940319c0e "[gdb] Fix internal-error in
process_event_stop_test".

The problem is that this code in create_exception_master_breakpoint:
...
      for (objfile *sepdebug = obj->separate_debug_objfile;
      	   sepdebug != nullptr; sepdebug = sepdebug->separate_debug_objfile)
        if (create_exception_master_breakpoint_hook (sepdebug))
...
iterates over all the separate debug object files, but fails to handle the
case that obj itself has the debug info we're looking for.

Fix this by using the separate_debug_objfiles () range instead, which does
iterate both over obj and the obj->separate_debug_objfile chain.

Tested on x86_64-linux.

gdb/ChangeLog:

2021-02-05  Tom de Vries  <tdevries@suse.de>

	PR breakpoints/27330
	* breakpoint.c (create_exception_master_breakpoint): Handle case that
	glibc object file has debug info.
2021-02-05 17:47:07 +01:00
Tom de Vries
e77b0004dd [gdb/symtab] Handle DW_TAG_type_unit in process_psymtab_comp_unit
When running test-case gdb.cp/cpexprs-debug-types.exp with target board
unix/gdb:debug_flags=-gdwarf-5, I run into:
...
(gdb) file cpexprs-debug-types^M
Reading symbols from cpexprs-debug-types...^M
ERROR: Couldn't load cpexprs-debug-types into GDB (eof).
ERROR: Couldn't send delete breakpoints to GDB.
ERROR: GDB process no longer exists
GDB process exited with wait status 23054 exp9 0 0 CHILDKILLED SIGABRT SIGABRT
...

We're running into this abort in process_psymtab_comp_unit:
...
  switch (reader.comp_unit_die->tag)
    {
    case DW_TAG_compile_unit:
      this_cu->unit_type = DW_UT_compile;
      break;
    case DW_TAG_partial_unit:
      this_cu->unit_type = DW_UT_partial;
      break;
    default:
      abort ();
    }
...
because reader.comp_unit_die->tag == DW_TAG_type_unit.

Fix this by adding a DW_TAG_type_unit case.

Tested on x86_64-linux.

gdb/ChangeLog:

2021-02-05  Tom de Vries  <tdevries@suse.de>

	PR symtab/27333
	* dwarf2/read.c (process_psymtab_comp_unit): Handle DW_TAG_type_unit.
2021-02-05 17:47:07 +01:00
Tom de Vries
0e857c8288 [gdb/breakpoints] Fix segfault for catch syscall -1
Using a hello world a.out, I run into a segfault:
...
$ gcc hello.c
$ gdb -batch a.out -ex "catch syscall -1" -ex r
Catchpoint 1 (syscall -1)
Aborted (core dumped)
...

Fix this by erroring out if a negative syscall number is used in the
catch syscall command.

Tested on x86_64-linux.

gdb/ChangeLog:

2021-02-05  Tom de Vries  <tdevries@suse.de>

	PR breakpoints/27313
	* break-catch-syscall.c (catch_syscall_split_args): Reject negative
	syscall numbers.

gdb/testsuite/ChangeLog:

2021-02-05  Tom de Vries  <tdevries@suse.de>

	PR breakpoints/27313
	* gdb.base/catch-syscall.exp: Check that "catch syscall -1" is
	rejected.
2021-02-05 17:47:07 +01:00
Tom Tromey
bdfea17ea9 Return unique_ptr from language_defn::get_compile_context
This changes language_defn::get_compile_context to return a
unique_ptr.  This makes the ownership transfer clear.

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

	* compile/compile-c-support.c (get_compile_context)
	(c_get_compile_context, cplus_get_compile_context): Change return
	type.
	* language.c (language_defn::get_compile_instance): New method.
	* language.h (language_defn::get_compile_instance): Change return
	type.  No longer inline.
	* c-lang.c (c_language::get_compile_instance): Change return type.
	(cplus_language::get_compile_instance): Change return type.
	* c-lang.h (c_get_compile_context, cplus_get_compile_context):
	Change return type.
	* compile/compile.c (compile_to_object): Update.
2021-02-05 07:17:12 -07:00
Tom Tromey
1b30f42106 Extract symbol-writing function from parsers
I noticed that several parsers shared the same code to write a symbol
reference to an expression.  This patch factors this code out into a
new function.

Regression tested on x86-64 Fedora 32.

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

	* parser-defs.h (write_exp_symbol_reference): Declare.
	* parse.c (write_exp_symbol_reference): New function.
	* p-exp.y (variable): Use write_exp_symbol_reference.
	* m2-exp.y (variable): Use write_exp_symbol_reference.
	* f-exp.y (variable): Use write_exp_symbol_reference.
	* d-exp.y (PrimaryExpression): Use write_exp_symbol_reference.
	* c-exp.y (variable): Use write_exp_symbol_reference.
2021-02-05 07:11:01 -07:00
Nick Clifton
e37d88e5e5 Remove Richard Henderson as the Alpha maintainer 2021-02-05 11:15:50 +00:00
Tom de Vries
a22ec6e8a4 [gdb/testsuite] Add KFAILs for PR symtab/24549
When an executable contains an index such as a .gdb_index or .debug_names
section, gdb ignores the DW_AT_subprogram attribute.

This problem has been filed as PR symtab/24549.

Add KFAILs for this PR in test-cases gdb.dwarf2/main-subprogram.exp and
gdb.fortran/mixed-lang-stack.exp.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-02-05  Tom de Vries  <tdevries@suse.de>

	* gdb.dwarf2/main-subprogram.exp: Add KFAIL for PR symtab/24549.
	* gdb.fortran/mixed-lang-stack.exp: Same.
2021-02-05 10:56:39 +01:00
Tom de Vries
ae71049661 [gdb/exp] Fix assert when adding ptr to imaginary unit
I'm running into this assertion failure:
...
$ gdb -batch -ex "p (void *)0 - 5i"
gdbtypes.c:3430: internal-error: \
  type* init_complex_type(const char*,   type*): Assertion \
  `target_type->code () == TYPE_CODE_INT \
   || target_type->code () == TYPE_CODE_FLT' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
...

This is a regression since commit c34e871466 "Implement complex arithmetic".
Before that commit we had:
...
(gdb) p (void *)0 - 5i
Argument to arithmetic operation not a number or boolean.
...

Fix this in complex_binop by throwing an error, such that we have:
...
(gdb) print (void *)0 - 5i
Argument to complex arithmetic operation not supported.
...

Tested on x86_64-linux.

gdb/ChangeLog:

2021-02-05  Tom de Vries  <tdevries@suse.de>

	PR exp/27265
	* valarith.c (complex_binop): Throw an error if complex type can't
	be created.

gdb/testsuite/ChangeLog:

2021-02-05  Tom de Vries  <tdevries@suse.de>

	PR exp/27265
	* gdb.base/complex-parts.exp: Add tests.
2021-02-05 10:56:39 +01:00
Tom de Vries
d3b54e63f4 [gdb/symtab] Fix duplicate CUs in create_cus_from_debug_names_list
When running test-case gdb.dwarf2/clang-debug-names.exp, I run into the
following warning:
...
(gdb) file clang-debug-names^M
Reading symbols from clang-debug-names...^M
warning: Section .debug_aranges in clang-debug-names has duplicate \
  debug_info_offset 0xc7, ignoring .debug_aranges.^M
...

This is caused by a missing return in commit 3ee6bb113a "[gdb/symtab] Fix
incomplete CU list assert in .debug_names".

Fix this by adding the missing return, such that we have instead this warning:
...
(gdb) file clang-debug-names^M
Reading symbols from clang-debug-names...^M
warning: Section .debug_aranges in clang-debug-names \
  entry at offset 0 debug_info_offset 0 does not exists, \
  ignoring .debug_aranges.^M
...
which is a known problem filed as PR25969 - "Ignoring .debug_aranges with
clang .debug_names".

Tested on x86_64-linux.

gdb/ChangeLog:

2021-02-05  Tom de Vries  <tdevries@suse.de>

	PR symtab/27307
	* dwarf2/read.c (create_cus_from_debug_names_list): Add missing
	return.

gdb/testsuite/ChangeLog:

2021-02-05  Tom de Vries  <tdevries@suse.de>

	PR symtab/27307
	* gdb.dwarf2/clang-debug-names.exp: Check file command warnings.
2021-02-05 09:14:25 +01:00
Tom de Vries
fc9a13fbdd [gdb/symtab] Fix indentation in create_cus_from_debug_names_list
Fix indentation in !map.augmentation_is_gdb part of
create_cus_from_debug_names_list.

gdb/ChangeLog:

2021-02-05  Tom de Vries  <tdevries@suse.de>

	* dwarf2/read.c (create_cus_from_debug_names_list): Fix indentation.
2021-02-05 09:14:25 +01:00
Eli Zaretskii
887854bae4 Fix typos in comments added in PR 27252 fix
PR 27252
	* elfedit.c (check_file):
	* bucomm.c (get_file_size): Fix typos in comments.
2021-02-05 09:05:58 +02:00
Alan Modra
554c30abef ld testsuite on x86_64 with --enable-shared
These tests fail since 1c9c9b9b55, due to not being able to access
some scripts:
FAIL: Absolute non-overflowing relocs
FAIL: ld-i386/iamcu-1
FAIL: ld-i386/iamcu-2

The problem is that when built with --enable-shared the ld-new
executable sits in a .libs/ directory.

	* Makefile.am (check-DEJAGNU): Set up ldscripts link in .libs.
	* Makefile.in: Regenerate.
2021-02-05 14:14:17 +10:30
Nelson Chu
5f40035fb8 RISC-V: PR27348, Remove the obsolete OP_*CUSTOM_IMM.
include/
    PR 27348
    * opcode/riscv.h: Remove obsolete OP_*CUSTOM_IMM.
2021-02-05 11:16:45 +08:00
Nelson Chu
cb4ff67af3 RISC-V: PR27348, Remove obsolete Xcustom support.
include/
    PR 27348
    * opcode/riscv-opc.h: Remove obsolete Xcustom support.
2021-02-05 11:04:59 +08:00
Alan Modra
c180f095f3 PR27345, binutils/arsup.c: lstat() not available on all targets
We can just use stat here, the same as is done in ar.c:open_inarch.

	PR 27345
	* arsup.c (ar_save): Use stat rather than lstat.
2021-02-05 13:04:29 +10:30
Mike Frysinger
04b4939b03 gdb: riscv: enable sim integration
Now the simulator can be loaded via gdb using "target sim".
2021-02-04 19:15:17 -05:00
Mike Frysinger
b9249c461c sim: riscv: new port
This is a hand-written implementation that should have fairly complete
coverage for the base integer instruction set ("i"), and for the atomic
("a") and integer multiplication+division ("m") extensions.  It also
covers 32-bit & 64-bit targets.

The unittest coverage is a bit weak atm, but should get better.
2021-02-04 19:02:19 -05:00
GDB Administrator
a9ab6e2ea0 Automatic date update in version.in 2021-02-05 00:00:11 +00:00
Simon Marchi
6ff267e186 gdb: make target_is_non_stop_p return bool
gdb/ChangeLog:

	* target.c (target_is_non_stop_p): Return bool.
	* target.h (target_is_non_stop_p): Return bool.

Change-Id: Icdb37ffe917798e59b822976794d4b1b7aafd709
2021-02-04 15:47:28 -05:00
Shahab Vahedi
3eccb1c8bf gdb: Use correct feature in tdesc-regs for ARC
tdesc-regs.exp test fails for ARC because the test is not
using the correct XML files as target description.  With
this change, the correct directory and files are used.

v2 (after Andrew's remark [1]):
- Update the feature file names again.  Test results now:

  Test run by shahab on Tue Jan 26 11:31:16 2021
  Target is arc-default-elf32
  Host   is x86_64-unknown-linux-gnu

		  === gdb tests ===

  Schedule of variations:
      arc-nsim

  Running target arc-nsim
  Running /src/gdb/testsuite/gdb.xml/tdesc-regs.exp ...
  PASS: gdb.xml/tdesc-regs.exp: set tdesc file single-reg.xml
  PASS: gdb.xml/tdesc-regs.exp: cd to directory holding xml
  PASS: gdb.xml/tdesc-regs.exp: set tdesc filename test-extra-regs.xml...
  PASS: gdb.xml/tdesc-regs.exp: ptype $extrareg
  PASS: gdb.xml/tdesc-regs.exp: ptype $uintreg
  PASS: gdb.xml/tdesc-regs.exp: ptype $vecreg
  PASS: gdb.xml/tdesc-regs.exp: ptype $unionreg
  PASS: gdb.xml/tdesc-regs.exp: ptype $unionreg.v4
  PASS: gdb.xml/tdesc-regs.exp: ptype $structreg
  PASS: gdb.xml/tdesc-regs.exp: ptype $structreg.v4
  PASS: gdb.xml/tdesc-regs.exp: ptype $bitfields
  PASS: gdb.xml/tdesc-regs.exp: ptype $flags
  PASS: gdb.xml/tdesc-regs.exp: ptype $mixed_flags
  PASS: gdb.xml/tdesc-regs.exp: maintenance print reggroups
  PASS: gdb.xml/tdesc-regs.exp: core-only.xml: set tdesc filename...
  PASS: gdb.xml/tdesc-regs.exp: core-only.xml: ptype $extrareg

		=== gdb Summary ===

  # of expected passes		16

[1]
https://sourceware.org/pipermail/gdb-patches/2021-January/175465.html

gdb/testsuite/ChangeLog:

	* gdb.xml/tdesc-regs.exp: Use correct core-regs for ARC.
2021-02-04 20:33:21 +01:00
Simon Marchi
fdbc5215e7 gdb: make record-full clear async handler in wait
For the same reason explained in the previous patch (which was for the
record-btrace target), move clearing of the async event handler of the
record-full target to the wait method.

I'm not sure if/where that target needs to re-set its async event
handler in the wait method.  Since it only supports a single thread,
there probably can't be multiple events to report at the same time.

gdb/ChangeLog:

	* record-full.c (record_full_async_inferior_event_handler):
	Don't clear async event handler.
	(record_full_base_target::wait): Clear async event handler at
	beginning.

Change-Id: I146fbdb53d99e3a32766ac7cd337ac5ed7fd9adf
2021-02-04 13:35:37 -05:00
Simon Marchi
85d3ad8e0b gdb: make record-btrace clear event handler in wait
For the same reason explained in the previous patch (which was for the
remote target), move clearing of the async event handler of the
record-btrace target to the wait method.

The record-btrace target already re-sets its async event handler in its
wait method, so that part doesn't need to be changed:

    /* In async mode, we need to announce further events.  */
    if (target_is_async_p ())
      record_btrace_maybe_mark_async_event (moving, no_history);

gdb/ChangeLog:

	* record-btrace.c (record_btrace_handle_async_inferior_event):
	Don't clear async event handler.
	(record_btrace_target::wait): Clear async event handler at
	beginning.

Change-Id: Ib32087a81bf94f1b884a938c8167ac8bbe09e362
2021-02-04 13:35:09 -05:00
Simon Marchi
baa8575b29 gdb: make remote target clear its handler in remote_target::wait
The remote target's remote_async_inferior_event_token is a flag that
tells when it wants the infrun loop to call its wait method.  The flag
is cleared in the async_event_handler's callback
(remote_async_inferior_event_handler), just before calling
inferior_event_handler.  However, since inferior_event_handler may
actually call another target's wait method, there needs to be code that
checks if we need to re-raise the flag.

It would be simpler instead for remote_target::wait to clear the flag
when it returns an event and there are no more to report after that.  If
another target's wait method gets called by inferior_event_handler, the
remote target's flag will stay naturally stay marked.

Note that this is already partially implemented in remote_target::wait,
since the remote target may have multiple events to report (and it can
only report one at the time):

  if (target_is_async_p ())
    {
      remote_state *rs = get_remote_state ();

      /* If there are are events left in the queue tell the event loop
	 to return here.  */
      if (!rs->stop_reply_queue.empty ())
	mark_async_event_handler (rs->remote_async_inferior_event_token);
    }

The code in remote_async_inferior_event_handler also checks for pending
events as well, in addition to the stop reply queue, so I've made
remote_target::wait check for that as well.  I'm not completely sure
this is ok, since I don't understand very well how the pending events
mechanism works.  But I figured it was safer to do this, worst case it
just leads to unnecessary calls to remote_target::wait.

gdb/ChangeLog:

	* remote.c (remote_target::wait): Clear async event handler at
	beginning, mark if needed at the end.
	(remote_async_inferior_event_handler): Don't set or clear async
	event handler.

Change-Id: I20117f5b5acc8a9972c90f16280249b766c1bf37
2021-02-04 13:34:11 -05:00
Simon Marchi
6b36ddeb1e gdb: make async event handlers clear themselves
The `ready` flag of async event handlers is cleared by the async event
handler system right before invoking the associated callback, in
check_async_event_handlers.

This is not ideal with how the infrun subsystem consumes events: all
targets' async event handler callbacks essentially just invoke
`inferior_event_handler`, which eventually calls `fetch_inferior_event`
and `do_target_wait`.  `do_target_wait` picks an inferior at random,
and thus a target at random (it could be the target whose `ready` flag
was cleared, or not), and pulls one event from it.

So it's possible that:

- the async event handler for a target A is called
- we end up consuming an event for target B
- all threads of target B are stopped, target_async(0) is called on it,
  so its async event handler is cleared (e.g.
  record_btrace_target::async)

As a result, target A still has events to report while its async event
handler is left unmarked, so these events are not consumed.  To counter
this, at the end of their async event handler callbacks, targets check
if they still have something to report and re-mark their async event
handler (e.g. remote_async_inferior_event_handler).

The linux_nat target does not suffer from this because it doesn't use an
async event handler at the moment.  It only uses a pipe registered with
the event loop.  It is written to in the SIGCHLD handler (and in other
spots that want to get target wait method called) and read from in
the target's wait method.  So if linux_nat happened to be target A in
the example above, the pipe would just stay readable, and the event loop
would wake up again, until linux_nat's wait method is finally called and
consumes the contents of the pipe.

I think it would be nicer if targets using async_event_handler worked in
a similar way, where the flag would stay set until the target's wait
method is actually called.  As a first step towards that, this patch
moves the responsibility of clearing the ready flags of async event
handlers to the invoked callback.

All async event handler callbacks are modified to clear their ready flag
before doing anything else.  So in practice, nothing changes with this
patch.  It's only the responsibility of clearing the flag that is
shifted toward the callee.

gdb/ChangeLog:

	* async-event.h (async_event_handler_func):  Add documentation.
	* async-event.c (check_async_event_handlers): Don't clear
	async_event_handler ready flag.
	* infrun.c (infrun_async_inferior_event_handler): Clear ready
	flag.
	* record-btrace.c (record_btrace_handle_async_inferior_event):
	Likewise.
	* record-full.c (record_full_async_inferior_event_handler):
	Likewise.
	* remote-notif.c (remote_async_get_pending_events_handler):
	Likewise.
	* remote.c (remote_async_inferior_event_handler): Likewise.

Change-Id: I179ef8e99580eae642d332846fd13664dbddc0c1
2021-02-04 13:13:30 -05:00
Nick Alcock
ee87f50b8d libctf: always name nameless types "", never NULL
The ctf_type_name_raw and ctf_type_aname_raw functions, which return the
raw, unadorned name of CTF types, have one unfortunate wrinkle: they
return NULL not only on error but when returning the name of types
without a name in writable dicts.  This was unintended: it not only
makes it impossible to reliably tell if a given call to
ctf_type_name_raw failed (due to a bad string offset say), but also
complicates all its callers, who now have to check for both NULL and "".

The written-out form of CTF has no concept of a NULL pointer instead of
a string: all null strings are strtab offset 0, "".  So the more we can
do to remove this distinction from the writable form, the less complex
the rest of our code needs to be.

Armour against NULL in multiple places, arranging to return "" from
ctf_type_name_raw if offset 0 is passed in, and removing a risky
optimization from ctf_str_add* that avoided doing anything if a NULL was
passed in: this added needless irregularity to the functions' API
surface, since "" and NULL should be treated identically, and in the
case of ctf_str_add_ref, we shouldn't skip adding the passed-in REF to
the list of references to be updated no matter what the content of the
string happens to be.

This means we can simplify the deduplicator a tiny bit, also fixing a
bug (latent when used by ld) where if the input dict was writable,
we failed to realise when types were nameless and could end up creating
deeply unhelpful synthetic forwards with no name, which we just banned
a few commits ago, so the link failed.

libctf/ChangeLog
2021-01-27  Nick Alcock  <nick.alcock@oracle.com>

	* ctf-string.c (ctf_str_add): Treat adding a NULL as adding "".
	(ctf_str_add_ref): Likewise.
	(ctf_str_add_external): Likewise.
	* ctf-types.c (ctf_type_name_raw): Always return "" for offset 0.
	* ctf-dedup.c (ctf_dedup_multiple_input_dicts): Don't armour
	against NULL name.
	(ctf_dedup_maybe_synthesize_forward): Likewise.
2021-02-04 16:01:53 +00:00