Commit Graph

105975 Commits

Author SHA1 Message Date
Jan Beulich
b818855549 x86-64: have value properly checked when resolving fixup
Constants not known at the time an individual insn gets assembled and
going into a sign-extended field still shouldn't be silently truncated
at the time the respective fixup gets resolved.
2021-04-26 10:35:51 +02:00
Sergei Trofimovich
c290cb01fa gdb: fix sparc build failure of linux-nat
On sparc build failed as:

```
gdb/sparc-linux-nat.c: In member function
  'virtual void sparc_linux_nat_target::fetch_registers(regcache*, int)':
gdb/sparc-linux-nat.c:36:37:
  error: cannot convert 'regcache*' to 'process_stratum_target*'
   36 |   { sparc_fetch_inferior_registers (regcache, regnum); }
      |                                     ^~~~~~~~
      |                                     |
      |                                     regcache*
```

The fix adopts gdb/sparc-nat.h API change in d1e93af64a
("gdb: set current thread in sparc_{fetch,collect}_inferior_registers").

gdb/ChangeLog:

	* sparc-linux-nat.c (sparc_linux_nat_target): fix sparc build
	by passing `process_stratum_target*` parameter.
2021-04-26 07:22:08 +01:00
GDB Administrator
6476ec743f Automatic date update in version.in 2021-04-26 00:00:16 +00:00
Lancelot SIX
fbb46296d7 [PR gdb/22640] ptype: add option to use hexadecimal notation
This commit adds a flag to the ptype command in order to print the
offsets and sizes of struct members using the hexadecimal notation.  The
'x' flag ensures use of the hexadecimal notation while the 'd' flag
ensures use of the decimal notation.  The default is to use decimal
notation.

Before this patch, gdb only uses decimal notation, as pointed out in PR
gdb/22640.

Here is an example of this new behavior with hex output turned on:

    (gdb) ptype /ox struct type_print_options
    /* offset      |    size */  type = struct type_print_options {
    /* 0x0000: 0x0 |  0x0004 */    unsigned int raw : 1;
    /* 0x0000: 0x1 |  0x0004 */    unsigned int print_methods : 1;
    /* 0x0000: 0x2 |  0x0004 */    unsigned int print_typedefs : 1;
    /* 0x0000: 0x3 |  0x0004 */    unsigned int print_offsets : 1;
    /* 0x0000: 0x4 |  0x0004 */    unsigned int print_in_hex : 1;
    /* XXX  3-bit hole       */
    /* XXX  3-byte hole      */
    /* 0x0004      |  0x0004 */    int print_nested_type_limit;
    /* 0x0008      |  0x0008 */    typedef_hash_table *local_typedefs;
    /* 0x0010      |  0x0008 */    typedef_hash_table *global_typedefs;
    /* 0x0018      |  0x0008 */    ext_lang_type_printers *global_printers;

                                   /* total size (bytes):   32 */
                                 }

This patch also adds the 'set print type hex' and 'show print type hex'
commands in order to set and inspect the default behavior regarding the
use of decimal or hexadecimal notation when printing struct sizes and
offsets.

Tested using on x86_64.

gdb/ChangeLog:

	PR gdb/22640
	* typeprint.h (struct type_print_options): Add print_in_hex
	flag.
	(struct print_offset_data): Add print_in_hex flag, add a
	constructor accepting a type_print_options* argument.
	* typeprint.c (type_print_raw_options, default_ptype_flags): Set
	default value for print_in_hex.
	(print_offset_data::indentation): Allow more horizontal space.
	(print_offset_data::print_offset_data): Add ctor.
	(print_offset_data::maybe_print_hole, print_offset_data::update):
	Handle the print_in_hex flag.
	(whatis_exp): Handle 'x' and 'd' flags.
	(print_offsets_and_sizes_in_hex): Declare.
	(set_print_offsets_and_sizes_in_hex): Create.
	(show_print_offsets_and_sizes_in_hex): Create.
	(_initialize_typeprint): Update help message for the ptype
	command, register the 'set print type hex' and 'show print type
	hex' commands.
	* c-typeprint.c (c_print_type, c_type_print_base_struct_union)
	(c_type_print_base): Construct the print_offset_data
	object using the type_print_optons parameter.
	* rust-lang.c (rust_language::print_type): Construct the
	print_offset_data object using the type_print_optons parameter.
	* NEWS: Mention the new flags of the ptype command.

gdb/doc/ChangeLog:

	PR gdb/22640
	* gdb.texinfo (Symbols): Describe the 'x' and 'd' flags of the
	ptype command, describe 'set print type hex' and 'show print
	type hex' commands.  Update 'ptype/o' examples.

gdb/testsuite/ChangeLog:

	PR gdb/22640
	* gdb.base/ptype-offsets.exp: Add tests to verify the behavior
	of 'ptype/ox' and 'ptype/od'. Check that 'set print type hex'
	changes the default behavior of 'ptype/o'.  Update to take into
	account new horizontal layout.
	* gdb.rust/simple.exp: Update ptype test to check new horizontal
	layout.
	* gdb.rust/union.exp: Same.
2021-04-25 18:00:54 +01:00
Lancelot SIX
18bbba46a9 gdb/typeprint.h: reorder struct declaration
Move the declaration of struct type_print_raw_options before struct
print_offset_data to ease upcoming changes.  This is a helper commit
intended to make it easier to build a print_offset_data object from
configurations given by a type_print_raw_options.

gdb/ChangeLog:

	* typeprint.h (struct type_print_options): Move before
	  print_offset_data.
2021-04-25 17:55:09 +01:00
Tom Tromey
b22138f32f Add engv32.h to SIM_EXTRA_DEPS in sim/cris
A rebuild showed that an earlier change of mine missed a built header
file -- cris/engv32.h.  This patch fixes the problem.

sim/cris/ChangeLog
2021-04-25  Tom Tromey  <tom@tromey.com>

	* Makefile.in (SIM_EXTRA_DEPS): Add engv32.h.
2021-04-25 07:30:03 -06:00
Tom Tromey
4478c33127 Use htab_t in sim-options.c
This changes sim-options.c to use the libiberty hash table, rather
than its own custom hash table.

sim/common/ChangeLog
2021-04-25  Tom Tromey  <tom@tromey.com>

	* sim-options.c (compare_strings): New function.
	(ARG_HASH_SIZE, ARG_HASH): Remove.
	(dup_arg_p): Use htab_t.
	(sim_parse_args): Remove assert.
2021-04-25 07:02:20 -06:00
Joel Brobecker
77393c9b18 Document the GDB 10.2 release in gdb/ChangeLog
gdb/ChangeLog:

	GDB 10.2 released.
2021-04-25 08:19:04 +04:00
GDB Administrator
219df3d924 Automatic date update in version.in 2021-04-25 00:00:17 +00:00
Simon Marchi
a8536c466a gdbsupport: add observer_debug_printf, OBSERVER_SCOPED_DEBUG_ENTER_EXIT
Switch observer to use the "new" debug printf mechanism and sprinkle a
few debug prints.  Here's a small example of the output with "infrun"
and "observer" debug output enabled:

    [infrun] proceed: enter
      [observer] notify: start: observable target_resumed notify() called
        [observer] notify: start: calling observer mi-interp of observable target_resumed
        [observer] notify: end: calling observer mi-interp of observable target_resumed
        [observer] notify: start: calling observer py-inferior of observable target_resumed
        [observer] notify: end: calling observer py-inferior of observable target_resumed
      [observer] notify: end: observable target_resumed notify() called
      ...

gdbsupport/ChangeLog:

	* observable.h (observer_debug_printf,
	OBSERVER_SCOPED_DEBUG_START_END): New.
	(class observable) <notify, attach>: Use them.

Change-Id: If3ae4b6b65450ca3b7cae56698a87fc526688b86
2021-04-24 19:26:41 -04:00
Simon Marchi
0df0cce7c6 gdbsupport: allow passing format string to scoped_debug_start_end
A little thing that bothers me with scoped_debug_start_end is that it's
not possible to pass a format string to add context to the messages: the
start and end messages are fixed.

It was done like this at the time because there's the risk that debug
output is not enabled on entry (when the constructor runs) but is
enabled on exit (when the destructor runs).  For example, a user
debugging from a top-gdb may manually enable a debug_foo variable.  If
debug output is disabled while the constructor runs, we won't render the
format string (to minimize overhead) so it won't be available in the
destructor.

I think it would be nice to be able to use a format string along with
scoped_debug_start_end, and I think it's unfortunate that such a narrow
use case prevents it.  So with this patch, I propose that we allow
passing a format string to scoped_debug_start_end, and if the rare
situation described above happens, then we just show a "sorry, message
not available" kind of message.

The following patch makes use of this.

gdbsupport/ChangeLog:

	* common-debug.h (struct scoped_debug_start_end)
	<scoped_debug_start_end>: Change start_msg/end_msg for
	start_prefix/end_prefix.  Add format string parameter and make
	variadic.
	<~scoped_debug_start_end>: Adjust.
	<m_end_msg>: Rename to...
	<m_end_prefix>: ... this.
	<m_with_format>: New.
	<m_msg>: New.
	(scoped_debug_start_end): Make variadic.
	(scoped_debug_enter_exit): Adjust.

Change-Id: I9427ce8877a246a46694b3a1fec3837dc6954d6e
2021-04-24 19:26:41 -04:00
Simon Marchi
c90e7d6352 gdbsupport, gdb: give names to observers
Give a name to each observer, this will help produce more meaningful
debug message.

gdbsupport/ChangeLog:

	* observable.h (class observable) <struct observer> <observer>:
	Add name parameter.
	<name>: New field.
	<attach>: Add name parameter, update all callers.

Change-Id: Ie0cc4664925215b8d2b09e026011b7803549fba0
2021-04-24 19:26:41 -04:00
Simon Marchi
ec098003e2 gdbsupport: introduce struct observer
Instead of using a pair.  This allows keeping more data per observer in
a structured way, and using field names is clearer than first/second.

gdbsupport/ChangeLog:

	* observable.h (class observable) <struct observer>: New.
	<detach, notify>: Update.
	<m_observers>: Change type to vector of observers.

Change-Id: Iadf7d1fa25049cfb089e6b1b429ddebc548825ab
2021-04-24 19:26:41 -04:00
Mike Frysinger
3886790f13 sim: dv-cfi: fix printf format
Use the existing PRI constants to select the right format rather than
assume signed_cell is always %u.  Fixes building for riscv64.
2021-04-24 00:18:48 -04:00
Mike Frysinger
837b53fd08 sim: options: increase max option count
As we turn on more modules by default for all ports, the number of
options has been increasing.  The sim-options module has a limit on
the number of options it can support, and if it's exceeded, it likes
to go into an infinite loop.  Increase the ceiling and add an assert
so we abort right away instead of hanging.

This will be needed to turn on hw support for v850 as it will then
exceed the current limit.
2021-04-24 00:17:35 -04:00
Mike Frysinger
9d90335212 sim: simplify hardware m4 macro
Every port using this sets the 1st arg to yes and the 2nd arg to "".
These are the defaults we probably want anyways in order to unify the
codebase, so move them to the macro and only allow ports to declare
extra hardware models.
2021-04-23 21:58:21 -04:00
GDB Administrator
b2d14d3d8f Automatic date update in version.in 2021-04-24 00:00:15 +00:00
Simon Marchi
98c897e37a gdbsupport, gdb: change observer_debug to bool
gdb/ChangeLog:

	* observable.c (observer_debug): Change to bool.

gdbsupport/ChangeLog:

	* observable.h (observer_debug): Change to bool.

Change-Id: I58634235a20740a66eacb1c83bae3cf3304ae1fd
2021-04-23 16:28:26 -04:00
H.J. Lu
69cc19455b ld: Properly create a symbolic link to tmpdir/ldscripts
Don't create a symbolic link to tmpdir/ldscripts if it exists.

	PR ld/27771
	* testsuite/ld-bootstrap/bootstrap.exp: Create a symbolic link
	to tmpdir/ldscripts only if it doesn't exist.
2021-04-23 12:36:45 -07:00
Simon Marchi
4d6840c335 gdbsupport: include preprocessor.h in common-debug.h
While doing some changes, some code failed to compile because it used
the scoped_debug_start_end macro, but couldn't find the CONCAT macro.
Fix that by making common-debug.h include preprocessor.h, the header
file that provides CONCAT.

gdbsupport/ChangeLog:

	* common-debug.h: Include preprocessor.h.

Change-Id: Ibf863a932a18cba9a57b4bd72df538ef52d39127
2021-04-23 14:03:39 -04:00
Eric Botcazou
f5e98b7d67 Fix type of .persistent.bss section
The change implementing the .persistent family of sections broke the
existing support for the .persistent.bss section in the compiler:

int a __attribute__ ((section (".persistent.bss")));

t.s: Assembler messages:
t.s:4: Warning: setting incorrect section type for .persistent.bss

The compiler encodes it as @nobits but the assembler expects @progbits.
The assembler is incorrect and should treat the section like the compiler.

bfd/
	* elf.c (special_sections_p): Add .persistent.bss.
gas/
	* testsuite/gas/elf/section25.d: Run it everywhere.
	* testsuite/gas/elf/section26.d: Likewise.
	* testsuite/gas/elf/section26.s: Add test for .persistent.bss.
2021-04-23 19:13:52 +02:00
J?r?me Gardou
d039200a7e Allow .seh_pushframe to take an optional [code] parameter
* config/obj-coff-seh.c (obj_coff_seh_pushframe): Allow an
	optional "code" argument.
2021-04-23 16:33:47 +01:00
Max Filippov
b3ea76397a opcodes: xtensa: display loaded literal value
Display literal value loaded with l32r opcode as a part of disassembly.
This significantly simplifies reading of disassembly output.

2020-04-23  Max Filippov  <jcmvbkbc@gmail.com>
opcodes/
	* xtensa-dis.c (print_xtensa_operand): For PC-relative operand
	of l32r fetch and display referenced literal value.
2021-04-23 03:29:39 -07:00
Max Filippov
c1cbb7d8a1 opcodes: xtensa: improve literal output
Output literals as 4-byte words, not as separate bytes.

2021-04-23  Max Filippov  <jcmvbkbc@gmail.com>
opcodes/
	* xtensa-dis.c (print_insn_xtensa): Set info->bytes_per_chunk
	to 4 for literal disassembly.
2021-04-23 03:28:38 -07:00
Andrew Burgess
9fc2995588 gdb: remove some caching from the dwarf reader
While working on some changes to 'info sources' I ran into a situation
where I was seeing the same source files reported twice in the output
of the 'info sources' command when using either .gdb_index or the
.debug_name index.

I traced the problem back to some caching in
dwarf2_base_index_functions::map_symbol_filenames; when called GDB
caches the set of filenames, but, filesnames are not removed as the
index entries are expanded into full symtabs.  As a result we can end
up seeing filenames reported both from a full symtab _and_ from
a (stale) previously cached index entry.

Now, obviously, when seeing a problem like this the "correct" fix is
to remove the stale entries from the cache, however, I ran a few
experiments to see why this wasn't really hitting us anywhere, and, as
far as I can tell, ::map_symbol_filenames is only called from three
places:

  1. The mi command -file-list-exec-source-files,
  2. The 'info sources' command, and
  3. Filename completion

However, the result of this "bug" is that we will see duplicate
filenames, and readline's completion mechanism already removes
duplicates, so for case #3 we will never see any problems.

Cases #1 and #2 are basically the same, and in each case, to see a
problem we need to ensure we craft the test in a particular way, start
up ensuring we have some unexpected symtabs, then run one of the
commands to populate the cache, then expand one of the symtabs, and
list the sources again.  At this point you'll see duplicate entries in
the results.  Hardly surprising we haven't randomly hit this situation
in testing.

So, considering that use cases #1 and #2 are certainly not "high
performance" code (i.e. I don't think these justify the need for
caching) this leaves use case #3.  Does this use justify the need for
caching?  Well the psymbol_functions::map_symbol_filenames function
doesn't seem to do any extra caching, and within
dwarf2_base_index_functions::map_symbol_filenames, the only expensive
bit appears to be the call to dw2_get_file_names, and this already
does its own caching via this_cu->v.quick->file_names.

The upshot of all this analysis was that I'm not convinced the need
for the additional caching is justified, and so, I propose that to fix
the bug in GDB, I just remove the extra caching (for now).

If we later find that the caching _was_ useful, then we can
reintroduce it, but add it back such that it doesn't reintroduce this
bug.

As I was changing dwarf2_base_index_functions::map_symbol_filenames I
replaced the use of htab_up with std::unordered_set.

Tested using target_boards cc-with-debug-names and dwarf4-gdb-index.

gdb/ChangeLog:

	* dwarf2/read.c: Add 'unordered_set' include.
	(dwarf2_base_index_functions::map_symbol_filenames): Replace
	'visited' hash table with 'qfn_cache' unordered_set.  Remove use
	of per_Bfd->filenames_cache cache, and use function local
	filenames_cache instead.  Reindent.
	* dwarf2/read.h (struct dwarf2_per_bfd) <filenames_cache>: Delete.

gdb/testsuite/ChangeLog:

	* gdb.base/info_sources.exp: Add new tests.
2021-04-23 09:40:42 +01:00
Jan Beulich
c21346c5e2 x86: TLS desc call relocs target zero-size fields
These are marker relocations, so together with their bit size being zero
their byte size should be zero as well. This is expressed by a value of
3, not 0.
2021-04-23 09:18:48 +02:00
Jan Beulich
a9aabc23ef x86-64: special case LEA when determining signedness of displacement
LEA behavior without a 64-bit destination is independent of address size
- in particular LEA with 32-bit addressing and 64-bit destination is the
same as LEA with 64-bit addressing and 32-bit destination. IOW checking
merely i.prefix[ADDR_PREFIX] is insufficient. This also means wrong
relocation types (R_X86_64_32S when R_X86_64_32 is needed) were used so
far in such cases.

Note that in one case in build_modrm_byte() the 64-bit check came too
early altogether, and hence gets dropped in favor of the one included in
the new helper. This is benign to non-64-bit code from all I can tell,
but the failure to clear disp16 could have been a latent problem.
2021-04-23 09:18:06 +02:00
Jan Beulich
cce08655c6 x86-64: defer 32-bit signed displacement check
In preparation for extending the conditions here defer this check until
operands have been parsed, as certain further attributes will need to
be known for determinig applicability of this check to be correct to
LEA.
2021-04-23 09:17:33 +02:00
Jan Beulich
28a167a406 x86: re-order optimize_disp()
While I can't point out any specific case where things break, it looks
wrong to have the consumer of a flag before its producer. Set .disp32
first, then do the possible conversion to signed 32-bit, and finally
check whether the value fits in a signed long.
2021-04-23 09:16:57 +02:00
Jan Beulich
7b025ee8c8 x86: don't truncate values in diagnostics and alike
Truncating an expression's X_add_number to just "long" can result in
confusing output (e.g. an apparently in-range number claimed to be out
of range). Use the abstraction that bfd provides for this.

Take the opportunity and also insert a missing "of".
2021-04-23 09:15:45 +02:00
Simon Marchi
0406545d06 gdb: use function_view for iterate_over_bp_locations' callback
Use a function_view instead of function pointer + data.  Actually,
nothing uses the data anyway, but that makes iterate_over_bp_locations
more like iterate_over_breakpoints.

gdb/ChangeLog:

	* breakpoint.c (iterate_over_bp_locations): Change callback to
	function view, remove data parameter.
	* breakpoint.h (iterate_over_bp_locations): Likewise.
	* record-full.c (record_full_sync_record_breakpoints): Remove
	data parameter.

Change-Id: I66cdc94a505f67bc640bcc66865fb535ee939a57
2021-04-22 22:01:19 -04:00
Tom Tromey
19f6a43c6c Do not check for sys/time.h or sys/times.h
This updates the sim so that it unconditionally uses sys/time.h.  This
is in agreement with existing code, and a recent change to BFD.

I also think that sys/times.h is never needed by the sim, so this
patch removes the check and the one spot that was conditionally
including it.

sim/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* m4/sim_ac_common.m4 (SIM_AC_COMMON): Don't check for sys/time.h
	or sys/times.h.

sim/aarch64/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/arm/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/avr/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/bfin/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/bpf/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/common/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* sim-utils.c: Update includes.

sim/cr16/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* simops.c: Update includes.
	* configure, config.in: Rebuild.

sim/cris/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* rvdummy.c: Update includes.
	* dv-rv.c: Update includes.
	* configure, config.in: Rebuild.

sim/d10v/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/erc32/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/example-synacor/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/frv/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/ft32/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/h8300/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/iq2000/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/lm32/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/m32c/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/m32r/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/m68hc11/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/mcore/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/microblaze/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/mips/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/mn10300/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/moxie/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/msp430/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/or1k/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/ppc/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* mon.c: Update includes.
	* emul_unix.c: Update includes.
	(do_unix_gettimeofday): Update condition.

sim/pru/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/riscv/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/rl78/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/rx/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.

sim/sh/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* interp.c: Update includes.
	* configure, config.in: Rebuild.

sim/v850/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure, config.in: Rebuild.
2021-04-22 19:51:55 -06:00
Tom Tromey
51de628a22 Remove LIBS from two sim Makefiles
A couple of sim Makefiles define LIBS, but don't use it.  This removes
these.

sim/m32c/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (LIBS): Remove

sim/rx/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (LIBS): Remove.
2021-04-22 19:51:55 -06:00
Tom Tromey
d6581fcd69 Remove INCLUDE variable from some sim Makefiles
Some Makefiles in sim define INCLUDE but don't use it.  This removes
these instances.

sim/bfin/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (INCLUDE): Remove.

sim/m68hc11/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (INCLUDE): Remove.

sim/mn10300/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (INCLUDE): Remove.

sim/v850/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (INCLUDE): Remove.
2021-04-22 19:51:55 -06:00
Tom Tromey
e7d8f1da71 Remove and modernize dependencies in sim
Some spots in the sim build used manual dependencies, and some spots
did a compilation by hand but did not use the automatic dependency
tracking code.  This patch fixes these spots.

I didn't touch ppc, because it doesn't use the common Makefile code.
I also didn't touch objects that are for the build machine, because
automatic dependencies don't work for those.

sim/arm/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (armemu26.o, armemu32.o): Use COMPILE and
	POSTCOMPILE.

sim/bpf/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (arch.o, cpu.o, sim-if.o, traps.o): Remove.
	(mloop-le.o, mloop-be.o, decode-le.o, decode-be.o, sim-le.o)
	(sim-be.o): Use COMPILE and POSTCOMPILE.
	(SIM_EXTRA_DEPS): Add eng-le.h, eng-be.h.

sim/cr16/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (SIM_EXTRA_DEPS): New variable.
	(simops.o): Remove.

sim/cris/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (sim-if.o, dv-cris.o, dv-rv.o, arch.o, traps.o)
	(devices.o, crisv10f.o, mloopv10f.o, cpuv10.o, decodev10.o)
	(modelv10.o, crisv32f.o, mloopv32f.o, cpuv32.o, decodev32.o)
	(modelv32.o): Remove.
	(SIM_EXTRA_DEPS): Add engv10.h.

sim/d10v/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (SIM_EXTRA_DEPS): New variable.
	(simops.o): Remove.

sim/frv/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (arch.o, devices.o, frv.o, traps.o, pipeline.o)
	(interrupts.o, memory.o, cache.o, options.o, reset.o)
	(registers.o, profile.o, profile-fr400.o, profile-fr450.o)
	(profile-fr500.o, profile-fr550.o, sim-if.o, mloop.o, cpu.o)
	(decode.o, sem.o, model.o): Remove.
	(SIM_EXTRA_DEPS): Add eng.h.

sim/iq2000/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (sim-if.o): Remove.
	(arch.o): Use COMPILE and POSTCOMPILE.
	(devices.o, iq2000.o, mloop.o, cpu.o, decode.o, sem.o, model.o):
	Remove.
	(SIM_EXTRA_DEPS): Add eng.h.

sim/lm32/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (arch.o, traps.o, sim-if.o, lm32.o, mloop.o)
	(cpu.o, decode.o, sem.o, model.o): Remove.
	(SIM_EXTRA_DEPS): Add eng.h.

sim/m32r/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (sim-if.o, arch.o, traps.o, traps-linux.o)
	(devices.o, m32r.o, mloop.o, cpu.o, decode.o, sem.o, model.o)
	(m32rx.o, mloopx.o, cpux.o, decodex.o, semx.o, modelx.o)
	(m32r2.o, mloop2.o, cpu2.o, decode2.o, sem2.o, model2.o): Remove.
	(SIM_EXTRA_DEPS): Add eng.h, engx.h, eng2.h.

sim/m68hc11/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (interp.o): Remove.

sim/mips/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (interp.o, m16run.o, micromipsrun.o, multi-run.o):
	Remove.
	(SIM_EXTRA_DEPS): New variable.

sim/mn10300/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (interp.o): Remove.
	(idecode.o op_utils.o semantics.o): Remove.

sim/or1k/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (mloop.o, arch.o, cpu.o, decode.o, sem.o)
	(sem-switch.o, model.o): Remove.

sim/rl78/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (err.o, fpu.o, gdb-if.o, load.o, main.o, mem.o)
	(reg.o, rl78.o): Remove.

sim/rx/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (err.o, fpu.o, gdb-if.o, load.o, main.o, mem.o)
	(misc.o, reg.o, rx.o, syscalls.o, trace.o): Remove.

sim/sh/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (SIM_EXTRA_DEPS): New variable.
	(interp.o): Remove.

sim/v850/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (interp.o, simops.o, semantics.o): Remove.
2021-04-22 19:51:55 -06:00
Tom Tromey
efd82ac7cb Require GNU make
GDB has required GNU make for quite some time, and this patch applies
this approach to the sim as well.  Requiring GNU make means that
automatic dependency tracking can be simple and reliable, and it also
makes other refactorings simpler.

sim/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* m4/sim_ac_common.m4 (SIM_AC_COMMON): Don't check for make.

sim/aarch64/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/arm/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/avr/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/bfin/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/common/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Make-common.in: Require GNU make.

sim/cr16/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/cris/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/d10v/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/erc32/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/example-synacor/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/frv/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/ft32/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/h8300/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/iq2000/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/lm32/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/m32c/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/m32r/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/m68hc11/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/mcore/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/microblaze/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/mips/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/mn10300/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/moxie/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/msp430/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/or1k/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/pru/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/riscv/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/rl78/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/rx/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/sh/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.

sim/v850/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* configure: Rebuild.
2021-04-22 19:51:54 -06:00
Tom Tromey
06a84ea384 Add stamp files for generated files in sim/ppc
This changes the sim/ppc Makefile to use the stamp file idiom for a
couple of generated files, avoiding extra rebuilds.

sim/ppc/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Makefile.in (stamp-vals, stamp-map): New targets.
	(targ-vals.h, targ-map.c): Update.
	(clean): Remove files.
2021-04-22 19:51:54 -06:00
Tom Tromey
b396d3a16e Introduce stamp file for hw-config.h
This adds a stamp file for hw-config.h, to avoid unnecessary rebuilds.
It also arranges to remove hw-config.h in "mostlyclean", because the
file is created by "make".

sim/common/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Make-common.in (stamp-hw): New target.
	(hw-config.h): Depend on stamp-hw.
	(mostlyclean): Remove stamp-hw and hw-config.h.
2021-04-22 19:51:54 -06:00
Tom Tromey
be866656a0 Make mostlyclean an alias for clean
I found out by accident that "mostlyclean" in a sim subdir removes all
the configure artifacts.  The usual rule is:

* If the maintainer built it, maintainer-clean should remove it;
* If configure built it, distclean should remove it;
* If make built it, "clean" should remove it;
* If there is a handy subset of "clean" that is "easy" to rebuild,
  "mostlyclean" should remove it; otherwise mostlyclean should be an
  alias for clean

This patch makes mostlyclean an alias for clean.

sim/common/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* Make-common.in (mostlyclean): Now an alias for clean, not
	distclean.
2021-04-22 19:51:54 -06:00
Tom Tromey
dbc0e7ce65 Fix sim build failure
On x86-64 Fedora 32, the sim was failing to build.
sim_events_schedule was passing a 'dummy' argument to
sim_events_schedule_vtracef, which caused an error because the format
parameter was NULL.  However, removing this dummy argument caused an
error because too few arguments were being passed -- catch 22.

This patch fixes the build problem by using sim_events_schedule_tracef
instead.

sim/common/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* sim-events.c (sim_events_schedule): Use
	sim_events_schedule_tracef.
2021-04-22 19:44:12 -06:00
Tom Tromey
432ce4cf68 Fix ptype/o bug with "<no data fields>"
I noticed that when using ptype/o, the "<no data fields>" text that
may be emitted is indented incorrectly.  This patch fixes the bug and
adds a new test case.

I also removed a stray backslash from ptype-offsets.exp that I noticed
while writing the test.  This seemed too trivial to warrant a separate
patch.

gdb/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* c-typeprint.c (c_type_print_base_struct_union): Use
	print_spaces_filtered_with_print_options.

gdb/testsuite/ChangeLog
2021-04-22  Tom Tromey  <tom@tromey.com>

	* gdb.base/ptype-offsets.cc (struct empty_member): New.
	(main): Use empty_member.
	* gdb.base/ptype-offsets.exp: Add new test.
2021-04-22 19:39:56 -06:00
GDB Administrator
ae6a3f81a1 Automatic date update in version.in 2021-04-23 00:00:15 +00:00
Simon Marchi
a87caa6d52 gdb/testsuite: add Python support check in gdb.python/flexible-array-member.exp
We don't want to execute this test if Python support is not compiled in
GDB, add the necessary check.

gdb/testsuite/ChangeLog:

	* gdb.python/flexible-array-member.exp: Add check for Python
	support.

Change-Id: I853b937d2a193a0bb216566bef1a35354264b1c5
2021-04-22 15:45:34 -04:00
Simon Marchi
e25d6d93c4 gdb: fix getting range of flexible array member in Python
As reported in bug 27757, we get an internal error when doing:

    $ cat test.c
    struct foo {
        int len;
        int items[];
    };

    struct foo *p;

    int main() {
        return 0;
    }
    $ gcc test.c -g -O0 -o test
    $ ./gdb -q -nx --data-directory=data-directory ./test -ex 'python gdb.parse_and_eval("p").type.target()["items"].type.range()'
    Reading symbols from ./test...
    /home/simark/src/binutils-gdb/gdb/gdbtypes.h:435: internal-error: LONGEST dynamic_prop::const_val() const: Assertion `m_kind == PROP_CONST' failed.
    A problem internal to GDB has been detected,
    further debugging may prove unreliable.
    Quit this debugging session? (y or n)

This is because the Python code (typy_range) blindly reads the high
bound of the type of `items` as a constant value.  Since it is a
flexible array member, it has no high bound, the property is undefined.
Since commit 8c2e4e0689 ("gdb: add accessors to struct dynamic_prop"),
the getters check that you are not getting a property value of the wrong
kind, so this causes a failed assertion.

Fix it by checking if the property is indeed a constant value before
accessing it as such.  Otherwise, use 0.  This restores the previous GDB
behavior: because the structure was zero-initialized, this is what was
returned before.  But now this behavior is explicit and not accidental.

Add a test, gdb.python/flexible-array-member.exp, that is derived from
gdb.base/flexible-array-member.exp.  It tests the same things, but
through the Python API.  It also specifically tests getting the range
from the various kinds of flexible array member types (AFAIK it wasn't
possible to do the equivalent through the CLI).

gdb/ChangeLog:

	PR gdb/27757
	* python/py-type.c (typy_range): Check that bounds are constant
	before accessing them as such.
	* guile/scm-type.c (gdbscm_type_range): Likewise.

gdb/testsuite/ChangeLog:

	PR gdb/27757
	* gdb.python/flexible-array-member.c: New test.
	* gdb.python/flexible-array-member.exp: New test.
	* gdb.guile/scm-type.exp (test_range): Add test for flexible
	array member.
	* gdb.guile/scm-type.c (struct flex_member): New.
	(main): Use it.

Change-Id: Ibef92ee5fd871ecb7c791db2a788f203dff2b841
2021-04-22 15:01:28 -04:00
Simon Marchi
2f63213381 sim: sprinkle some ATTRIBUTE_PRINTF
Add some ATTRIBUTE_PRINTF attributes to functions that take a format
string, to fix a few -Wformat-nonliteral warnings.  Use the
ATTRIBUTE_PRINTF macro like we use in GDB, instead of spelling out
__attribute__((format...)).  Use ATTRIBUTE_NULL_PRINTF at one place,
because callers expect to be able to pass NULL.

sim/common/ChangeLog:

	* callback.c (os_printf_filtered, os_vprintf_filtered,
	os_evprintf_filtered, os_error): Use ATTRIBUTE_PRINTF.
	* sim-engine.h (sim_engine_abort, sim_engine_vabort): Likewise.
	* sim-events.h (sim_events_schedule_tracef,
	sim_events_schedule_vtracef): Use ATTRIBUTE_NULL_PRINTF.

Change-Id: Icd206f7b2c325e8b144f72eb129fb2a6b5af2fa3
2021-04-22 12:07:14 -04:00
Tankut Baris Aktemur
4efeb0d3e8 gdb/continuations: turn continuation functions into inferior methods
Turn continuations-related functions into methods of the inferior
class.  This is a refactoring.

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

	* Makefile.in (COMMON_SFILES): Remove continuations.c.
	* inferior.c (inferior::add_continuation): New method, adapted
	from 'add_inferior_continuation'.
	(inferior::do_all_continuations): New method, adapted from
	'do_all_inferior_continuations'.
	(inferior::~inferior): Clear the list of continuations directly.
	* inferior.h (class inferior) <continuations>: Rename into...
	<m_continuations>: ...this and make private.
	* continuations.c: Remove.
	* continuations.h: Remove.
	* event-top.c: Don't include "continuations.h".

	Update the users below.
	* inf-loop.c (inferior_event_handler)
	* infcmd.c (attach_command)
	(notice_new_inferior): Update.
2021-04-22 17:22:39 +02:00
Tankut Baris Aktemur
c4c493de2b gdb/continuations: use lambdas instead of function pointers
Use lambdas and std::list to track inferior continuations.  This is a
refactoring.

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

	* inferior.h (class inferior) <continuations>: Change the type
	to be an std::list of std::function's.
	Update the references and uses below.
	* continuations.c (struct continuation): Delete.
	(make_continuation): Delete.
	(do_my_continuations_1): Delete.
	(do_my_continuations): Delete.
	(discard_my_continuations_1): Delete.
	(discard_my_continuations): Delete.
	(add_inferior_continuation): Update.
	(do_all_inferior_continuations): Update.
	(discard_all_inferior_continuations): Update.
	* continuations.h (add_inferior_continuation): Update to take
	an std::function as the parameter.
	* infcmd.c (struct attach_command_continuation_args): Delete.
	(attach_command_continuation): Delete.
	(attach_command_continuation_free_args): Delete.
	(attach_command): Update.
	(notice_new_inferior): Update.
2021-04-22 17:22:39 +02:00
Tankut Baris Aktemur
1194676e0b gdb/continuations: do minor cleanup
Inferior continuations are no longer used by the until and finish
command.  It is used only by the attach command and the remote target
upon detecting new inferiors.  Update the comment accordingly.

Also update another comment about non-existent thread continuations and
remove an unused #include.

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

	* continuations.h: Update the general comment.
	* inferior.h (class inferior) <continuations>: Update the comment.
	* interps.c: Do not include "continuations.h".
2021-04-22 17:22:39 +02:00
Tankut Baris Aktemur
35682f0a64 gdb/continuations: remove the 'err' from 'do_all_inferior_continuations'
The 'err' parameter of 'do_all_inferior_continuations' is effectively
unused.  There is only one place where the function is called, and
there the argument is a literal 0.  So, remove the parameter.

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

	* continuations.h (do_all_inferior_continuations): Remove the 'err'
	parameter.  Update the references below.
	* continuations.c (do_my_continuations_1)
	(do_my_continuations)
	(do_all_inferior_continuations): Update.
	* inf-loop.c (inferior_event_handler): Update.
	* infcmd.c (attach_command_continuation): Update.
2021-04-22 17:22:38 +02:00
Tankut Baris Aktemur
6fee5eee88 gdb/infcmd: update the comment for 'attach_post_wait'
gdb/ChangeLog:
2021-04-22  Tankut Baris Aktemur  <tankut.baris.aktemur@intel.com>

	* infcmd.c (attach_post_wait): Update the function comment.
2021-04-22 17:22:38 +02:00