Commit Graph

689 Commits

Author SHA1 Message Date
Simon Marchi 41a77cbaad gdb: make gdbarch.sh write gdbarch.{c,h} directly
It was suggested in this thread [1] that gdbarch.sh should write to
gdbarch.h and gdbarch.c directly.  This patch implements that.

When running gdbarch.sh, we currently need to move new-gdbarch.c over
gdbarch.c and new-gdbarch.h over gdbarch.h.  It might have been useful
at some point to not have gdbarch.sh overwrite gdbarch.h and gdbarch.c,
but with git it's really unnecessary.  Any changes to gdbarch.sh can be
inspected using `git diff`.

A next step would be to have the Makefile automatically run gdbarch.sh
if it sees that gdbarch.c and gdbarch.h are out of date.  Or maybe even
remove gdbarch.c and gdbarch.h from the tree and generate them in the
build directory when building.  But that requires more thinking and
discussions, and I think that this change is already useful in itself.

[1] https://sourceware.org/pipermail/gdb-patches/2020-May/168265.html

gdb/ChangeLog;

	* gdbarch.sh: Write to gdbarch.c/gdbarch.h directly.  Don't
	compare old and new versions.
	(compare_new): Remove.

Change-Id: I7970a9e8af0afc0145cb5a28e73d94fbaa1e25b9
2020-05-24 11:11:36 -04:00
Simon Marchi ffc2844e96 gdb: silence shellcheck warning SC2162 (use read -r) in gdbarch.sh
shellcheck reports:

    In gdbarch.sh line 53:
        while IFS='' read line
                     ^--^ SC2162: read without -r will mangle backslashes.

See the rationale at [1].  In our case, we actually want the backslashes
to be interpreted and removed.  Silence the warning using a directive.

[1] https://github.com/koalaman/shellcheck/wiki/SC2162

gdb/ChangeLog:

	* gdbarch.sh (do_read): Add shellcheck disable directive for
	warning SC2162.
2020-04-29 20:35:36 -04:00
Simon Marchi 1207375d76 gdb: fix shellcheck warnings SC2154 (referenced but not assigned) in gdbarch.sh
Fix all instances of this kind of warning:

    In gdbarch.sh line 96:
                    m ) staticdefault="${predefault}" ;;
                                       ^-----------^ SC2154: predefault is referenced but not assigned.

These warnings appear because we are doing something a bit funky when reading
the gdbarch fields.  These variables are not assigned explicitly, but
using some `eval` commands.

I don't think there is so much we can fix about those warnings.  To
silence them, I've changed `${foo}` to `${foo:-}`.  This tells the shell
to substitute with an empty string if `foo` is not defined.  This
retains the current behavior, but the warnings go away.

gdb/ChangeLog:

	* gdbarch.sh: Use ${foo:-} where shellcheck would report a
	"referenced but not assigned" warning.
2020-04-29 20:35:35 -04:00
Simon Marchi 9fdb2916fe gdb: fix shellcheck warnings SC2034 (unused variable) in gdbarch.sh
shellcheck reports:

    In gdbarch.sh line 139:
                    fallbackdefault="0"
                    ^-------------^ SC2034: fallbackdefault appears unused. Verify use (or export if used externally).

Indeed, the `fallbackdefault` variable appears to be unused, remove the
code that sets it.

gdb/ChangeLog:

	* gdbarch.sh: Remove code that sets fallbackdefault.
2020-04-29 20:35:35 -04:00
Simon Marchi 759cea5e3f gdb: fix shellcheck warnings SC2166 (&& and !! instead of -a and -o) in gdbarch.sh
Fix all warnings of this type:

    In gdbarch.sh line 1238:
        if [ "x${invalid_p}" = "x0" -a -n "${postdefault}" ]
                                    ^-- SC2166: Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.

See the rationale here [1].

[1] https://github.com/koalaman/shellcheck/wiki/SC2166

gdb/ChangeLog:

	* gdbarch.sh: Use shell operators && and || instead of
	-a and -o.
2020-04-29 20:35:34 -04:00
Simon Marchi cb02ab2416 gdb: fix shellcheck warnings SC2006 (use $() instead of ``) in gdbarch.sh
Fix all instances of:

    In gdbarch.sh line 2195:
            printf "            `echo "$function" | sed -e 's/./ /g'`  %s %s)\n" "$returntype" "$function"
                                ^-- SC2006: Use $(...) notation instead of legacy backticked `...`.

    Did you mean:
            printf "            $(echo "$function" | sed -e 's/./ /g')  %s %s)\n" "$returntype" "$function"

See here [1] for the rationale.

[1] https://github.com/koalaman/shellcheck/wiki/SC2006

gdb/ChangeLog:

	* gdbarch.sh: Use $(...) instead of `...`.
2020-04-29 20:35:34 -04:00
Simon Marchi a6fc5ffc50 gdb: fix shellcheck warnings SC2086 (missing double quotes) in gdbarch.sh
Fix all instances of:

    In gdbarch.sh line 31:
        if test ! -r ${file}
                     ^-----^ SC2086: Double quote to prevent globbing and word splitting.

    Did you mean:
        if test ! -r "${file}"

Note that some instances of these are in text that is eval'ed.  I'm
pretty sure that things could go wrong during the eval too, but that's
not something shellcheck can check.

gdb/ChangeLog:

	* gdbarch.sh: Use double quotes around variables.
2020-04-29 20:35:34 -04:00
Simon Marchi 8d113d130e gdb: fix shellcheck warnings SC2059 (variables in printf format string) in gdbarch.sh
Fix all instances of this:

    In gdbarch.sh line 2182:
                printf "  gdb_assert (!(${invalid_p}));\n"
                       ^-- SC2059: Don't use variables in the printf format string. Use printf "..%s.." "$foo".

... by doing exactly as the message suggests.

The rationale explained here [1] makes sense, if there happens to be a
format specifier in text substituted for the variable, the printf won't
do what we expect.

[1] https://github.com/koalaman/shellcheck/wiki/SC2059

gdb/ChangeLog:

	* gdbarch.sh: Use %s with printf, instead of variables in the
	format string.
2020-04-29 20:35:33 -04:00
Simon Marchi fe4b2ee65c gdb: move enum gdb_osabi to osabi.h
I think it makes sense to have it there instead of in the catch-all
defs.h.

gdb/ChangeLog:

	* defs.h (enum gdb_osabi): Move to...
	* osabi.h (enum gdb_osabi): ... here.
	* gdbarch.sh: Include osabi.h in gdbarch.h.
	* gdbarch.h: Re-generate.
2020-03-16 16:56:34 -04:00
Simon Marchi fdb61c6c39 gdb: introduce displaced_step_closure_up type alias
To help with readability, add the type displaced_step_closure_up, an
alias for std::unique_ptr<displaced_step_closure>, and use it throughout
the code base.

gdb/ChangeLog:

	* aarch64-tdep.c (aarch64_displaced_step_copy_insn): Use
	displaced_step_closure_up.
	* aarch64-tdep.h (aarch64_displaced_step_copy_insn): Likewise.
	(struct displaced_step_closure_up):
	* amd64-tdep.c (amd64_displaced_step_copy_insn): Likewise.
	* amd64-tdep.h (amd64_displaced_step_copy_insn): Likewise.
	* arm-linux-tdep.c (arm_linux_displaced_step_copy_insn):
	Likewise.
	* gdbarch.sh (displaced_step_copy_insn): Likewise.
	* gdbarch.c, gdbarch.h: Re-generate.
	* i386-linux-tdep.c (i386_linux_displaced_step_copy_insn): Use
	displaced_step_closure_up.
	* i386-tdep.c (i386_displaced_step_copy_insn): Likewise.
	* i386-tdep.h (i386_displaced_step_copy_insn): Likewise.
	* infrun.h (displaced_step_closure_up): New type alias.
	(struct displaced_step_inferior_state) <step_closure>: Change
	type to displaced_step_closure_up.
	* rs6000-tdep.c (ppc_displaced_step_copy_insn): Use
	displaced_step_closure_up.
	* s390-tdep.c (s390_displaced_step_copy_insn): Likewise.
2020-02-14 16:46:38 -05:00
Simon Marchi e8217e61f5 gdb: make gdbarch_displaced_step_copy_insn return an std::unique_ptr
This callback dynamically allocates a specialized displaced_step_closure, and
gives the ownership of the object to its caller.  So I think it would make
sense for the callback to return an std::unique_ptr, this is what this patch
implements.

gdb/ChangeLog:

	* gdbarch.sh (displaced_step_copy_insn): Change return type to an
	std::unique_ptr.
	* gdbarch.c: Re-generate.
	* gdbarch.h: Re-generate.
	* infrun.c (displaced_step_prepare_throw): Adjust to std::unique_ptr
	change.
	* aarch64-tdep.c (aarch64_displaced_step_copy_insn): Change return
	type to std::unique_ptr.
	* aarch64-tdep.h (aarch64_displaced_step_copy_insn): Likewise.
	* amd64-tdep.c (amd64_displaced_step_copy_insn): Likewise.
	* amd64-tdep.h (amd64_displaced_step_copy_insn): Likewise.
	* arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise.
	* i386-linux-tdep.c (i386_linux_displaced_step_copy_insn): Likewise.
	* i386-tdep.c (i386_displaced_step_copy_insn): Likewise.
	* i386-tdep.h (i386_displaced_step_copy_insn): Likewise.
	* rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise.
	* s390-tdep.c (s390_displaced_step_copy_insn): Likewise.
2020-02-14 15:29:08 -05:00
Luis Machado 5133a31537 Recognize more program breakpoint patterns
New in v3:

- Code cleanups based on reviews.

New in v2:

- Fixed misc problems based on reviews.
- Switched to using gdbarch_program_breakpoint_here_p as opposed to
gdbarch_insn_is_breakpoint.
- Fixed matching of brk instructions. Previously the mask was incorrect, which
was showing up as a few failures in the testsuite. Now it is clean.
- New testcase (separate patch).
- Moved program_breakpoint_here () to arch-utils.c and made it the default
implementation of gdbarch_program_breakpoint_here_p.

--

It was reported to me that program breakpoints (permanent ones inserted into
the code itself) other than the one GDB uses for AArch64 (0xd4200000) do not
generate visible stops when continuing, and GDB will continue spinning
infinitely.

This happens because GDB, upon hitting one of those program breakpoints, thinks
the SIGTRAP came from a delayed breakpoint hit...

(gdb) x/i $pc
=> 0x4005c0 <problem_function>: brk     #0x90f
(gdb) c
Continuing.
infrun: clear_proceed_status_thread (process 14198)
infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: proceed: resuming process 14198
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: infrun_async(1)
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun:   14198.14198.0 [process 14198],
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: delayed software breakpoint trap, ignoring
infrun: no stepping, continue
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun:   14198.14198.0 [process 14198],
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: delayed software breakpoint trap, ignoring
infrun: no stepping, continue
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun:   14198.14198.0 [process 14198],
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: delayed software breakpoint trap, ignoring
infrun: no stepping, continue
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun:   14198.14198.0 [process 14198],
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: delayed software breakpoint trap, ignoring
infrun: no stepping, continue
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14198] at 0x4005c0
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun:   14198.14198.0 [process 14198],
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
...

... which is not the case.

If the program breakpoint is one GDB recognizes, then it will stop when it
hits it.

(gdb) x/i $pc
=> 0x4005c0 <problem_function>: brk     #0x0
(gdb) c
Continuing.
infrun: clear_proceed_status_thread (process 14193)
infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: proceed: resuming process 14193
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 14193] at 0x4005c0
infrun: infrun_async(1)
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun:   14193.14193.0 [process 14193],
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: random signal (GDB_SIGNAL_TRAP)
infrun: stop_waiting
infrun: stop_all_threads
infrun: stop_all_threads, pass=0, iterations=0
infrun:   process 14193 not executing
infrun: stop_all_threads, pass=1, iterations=1
infrun:   process 14193 not executing
infrun: stop_all_threads done

Program received signal SIGTRAP, Trace/breakpoint trap.
problem_function () at brk_0.c:7
7        asm("brk %0\n\t" ::"n"(0x0));
infrun: infrun_async(0)

Otherwise GDB will keep trying to resume the inferior and will keep
seeing the SIGTRAP's, without stopping.

To the user it appears GDB has gone into an infinite loop, interruptible only
by Ctrl-C.

Also, windbg seems to use a different variation of AArch64 breakpoint compared
to GDB. This causes problems when debugging Windows on ARM binaries, when
program breakpoints are being used.

The proposed patch creates a new gdbarch method (gdbarch_program_breakpoint_here_p)
that tells GDB whether the underlying instruction is a breakpoint instruction
or not.

This is more general than only checking for the instruction GDB uses as
breakpoint.

The existing logic is still preserved for targets that do not implement this
new gdbarch method.

The end result is like so:

(gdb) x/i $pc
=> 0x4005c0 <problem_function>: brk     #0x90f
(gdb) c
Continuing.
infrun: clear_proceed_status_thread (process 16417)
infrun: proceed (addr=0xffffffffffffffff, signal=GDB_SIGNAL_DEFAULT)
infrun: proceed: resuming process 16417
infrun: resume (step=0, signal=GDB_SIGNAL_0), trap_expected=0, current thread [process 16417] at 0x4005c0
infrun: infrun_async(1)
infrun: prepare_to_wait
infrun: target_wait (-1.0.0, status) =
infrun:   16417.16417.0 [process 16417],
infrun:   status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: handle_inferior_event status->kind = stopped, signal = GDB_SIGNAL_TRAP
infrun: stop_pc = 0x4005c0
infrun: random signal (GDB_SIGNAL_TRAP)
infrun: stop_waiting
infrun: stop_all_threads
infrun: stop_all_threads, pass=0, iterations=0
infrun:   process 16417 not executing
infrun: stop_all_threads, pass=1, iterations=1
infrun:   process 16417 not executing
infrun: stop_all_threads done

Program received signal SIGTRAP, Trace/breakpoint trap.
problem_function () at brk.c:7
7        asm("brk %0\n\t" ::"n"(0x900 + 0xf));
infrun: infrun_async(0)

gdb/ChangeLog:

2020-01-29  Luis Machado  <luis.machado@linaro.org>

	* aarch64-tdep.c (BRK_INSN_MASK): Define to 0xffe0001f.
	(BRK_INSN_MASK): Define to 0xd4200000.
	(aarch64_program_breakpoint_here_p): New function.
	(aarch64_gdbarch_init): Set gdbarch_program_breakpoint_here_p hook.
	* arch-utils.c (default_program_breakpoint_here_p): Moved from
	breakpoint.c.
	* arch-utils.h (default_program_breakpoint_here_p): Moved from
	breakpoint.h
	* breakpoint.c (bp_loc_is_permanent): Changed return type to bool and
	call gdbarch_program_breakpoint_here_p.
	(program_breakpoint_here): Moved to arch-utils.c, renamed to
	default_program_breakpoint_here_p, changed return type to bool and
	simplified.
	* breakpoint.h (program_breakpoint_here): Moved prototype to
	arch-utils.h, renamed to default_program_breakpoint_here_p and changed
	return type to bool.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Regenerate.
	* gdbarch.sh (program_breakpoint_here_p): New method.
	* infrun.c (handle_signal_stop): Call
	gdbarch_program_breakpoint_here_p.
2020-01-29 11:25:10 -03:00
Simon Marchi a12378729f gdb: add declaration for _initialize_gdbarch in gdbarch.sh
In commit

  gdb: add back declarations for _initialize functions
  6c2659886f

I wrongfully edited gdbarch.c, instead of editing gdbarch.sh and
re-generating gdbarch.c.  This patch fixes gdbarch.sh to add a
declaration for _initialize_gdbarch.  gdbarch.c is not changed, as the
output of gdbarch.sh now matches the current state of gdbarch.c.

gdb/ChangeLog:

	* gdbarch.sh: Add declaration for _initialize_gdbarch.
2020-01-21 18:30:25 -05:00
Joel Brobecker e5d78223ea Update copyright year in gdbarch.sh doc/gdb.texinfo and doc/refcard.tex
These are files that need to be updated by hand, because the copyright.py
script isn't able to handle them automatically.

gdb/ChangeLog:

	* gdbarch.sh: Update copyright year range of generated files.

gdb/doc/ChangeLog:

        * gdb.texinfo, refcard.tex: Update copyright year range.
2020-01-01 10:37:10 +04:00
Joel Brobecker b811d2c292 Update copyright year range in all GDB files.
gdb/ChangeLog:

        Update copyright year range in all GDB files.
2020-01-01 10:20:53 +04:00
Tom Tromey d5a22e77b5 Remove gdbarch_bits_big_endian
From what I can tell, set_gdbarch_bits_big_endian has never been used.
That is, all architectures since its introduction have simply used the
default, which is simply check the architecture's byte-endianness.

Because this interferes with the scalar_storage_order code, this patch
removes this gdbarch setting entirely.  In some places,
type_byte_order is used rather than the plain gdbarch.

gdb/ChangeLog
2019-12-04  Tom Tromey  <tromey@adacore.com>

	* ada-lang.c (decode_constrained_packed_array)
	(ada_value_assign, value_assign_to_component): Update.
	* dwarf2loc.c (rw_pieced_value, access_memory)
	(dwarf2_compile_expr_to_ax): Update.
	* dwarf2read.c (dwarf2_add_field): Update.
	* eval.c (evaluate_subexp_standard): Update.
	* gdbarch.c, gdbarch.h: Rebuild.
	* gdbarch.sh (bits_big_endian): Remove.
	* gdbtypes.h (union field_location): Update comment.
	* target-descriptions.c (make_gdb_type): Update.
	* valarith.c (value_bit_index): Update.
	* value.c (struct value) <bitpos>: Update comment.
	(unpack_bits_as_long, modify_field): Update.
	* value.h (value_bitpos): Update comment.

Change-Id: I379b5e0c408ec8742f7a6c6b721108e73ed1b018
2019-12-04 09:31:18 -07:00
Tom Tromey 953cff5630 Change gcc_target_options to return std::string
This patch was inspired by a recent review that recommended using
std::string in a new implementation of the gcc_target_options gdbarch
function.  It changes this function to return std::string rather than
an ordinary xmalloc'd string.

I believe this caught a latent memory leak in compile.c:get_args.

Tested on x86-64 Fedora 29.

gdb/ChangeLog
2019-10-15  Tom Tromey  <tromey@adacore.com>

	* gdbarch.h, gdbarch.c: Rebuild.
	* gdbarch.sh (gcc_target_options): Change return type to
	std::string.
	* compile/compile.c (get_args): Update.
	* nios2-tdep.c (nios2_gcc_target_options): Return std::string.
	* arm-linux-tdep.c (arm_linux_gcc_target_options): Return
	std::string.
	* aarch64-linux-tdep.c (aarch64_linux_gcc_target_options): Return
	std::string.
	* arch-utils.c (default_gcc_target_options): Return std::string.
	* arch-utils.h (default_gcc_target_options): Return std::string.
	* s390-tdep.c (s390_gcc_target_options): Return std::string.

Change-Id: I51f61703426a323089e646da8f22320a2cafbc1f
2019-10-15 11:03:57 -06:00
Alan Hayward aa7ca1bb44 Move [PAC] into a new MI field addr_flags
Add a new print_pc which prints both the PC and a new field addr_flags.
Call this wherever the PC is printed in stack.c.

Add a new gdbarch method get_pc_address_flags to obtain the addr_flag
contents. By default returns an empty string, on AArch64 this returns
PAC if the address has been masked in the frame.

Document this in the manual and NEWS file.

gdb/ChangeLog:

	* NEWS (Other MI changes): New subsection.
	* aarch64-tdep.c (aarch64_get_pc_address_flags): New function.
	(aarch64_gdbarch_init): Add aarch64_get_pc_address_flags.
	* arch-utils.c (default_get_pc_address_flags): New function.
	* arch-utils.h (default_get_pc_address_flags): New declaration.
	* gdbarch.sh: Add get_pc_address_flags.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Likewise.
	* stack.c (print_pc): New function.
	(print_frame_info) (print_frame): Call print_pc.

gdb/doc/ChangeLog:

	* gdb.texinfo (AArch64 Pointer Authentication)
	(GDB/MI Breakpoint Information) (Frame Information): Document
	addr_field.
2019-08-16 10:19:18 +01:00
Andrew Burgess 6b78c3f83c gdb: Remove a non-const reference parameter
Non-const reference parameter should be avoided according to the GDB
coding standard:

  https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#Avoid_non-const_reference_parameters.2C_use_pointers_instead

This commit updates the gdbarch method gdbarch_stap_adjust_register,
and the one implementation i386_stap_adjust_register to avoid using a
non-const reference parameter.

I've also removed the kfail from the testsuite for bug 24541, as this
issue is now resolved.

gdb/ChangeLog:

	PR breakpoints/24541
	* gdbarch.c: Regenerate.
	* gdbarch.h: Regenerate.
	* gdbarch.sh: Adjust return type and parameter types for
	'stap_adjust_register'.
	(i386_stap_adjust_register): Adjust signature and return new
	register name.
	* stap-probe.c (stap_parse_register_operand): Adjust use of
	'gdbarch_stap_adjust_register'.

gdb/testsuite/ChangeLog:

	PR breakpoints/24541
	* gdb.mi/mi-catch-cpp-exceptions.exp: Remove kfail due to 24541.
2019-07-17 16:24:32 +01:00
Sergio Durigan Junior 7d7571f0c1 Adjust i386 registers on SystemTap probes' arguments (PR breakpoints/24541)
This bug has been reported on PR breakpoints/24541, but it is possible
to reproduce it easily by running:

  make check-gdb TESTS=gdb.base/stap-probe.exp RUNTESTFLAGS='--target_board unix/-m32'

The underlying cause is kind of complex, and involves decisions made
by GCC and the sys/sdt.h header file about how to represent a probe
argument that lives in a register in 32-bit programs.  I'll use
Andrew's example on the bug to illustrate the problem.

libstdc++ has a probe named "throw" with two arguments.  On i386, the
probe is:

  stapsdt              0x00000028       NT_STAPSDT (SystemTap probe descriptors)
    Provider: libstdcxx
    Name: throw
    Location: 0x00072c96, Base: 0x00133d64, Semaphore: 0x00000000
    Arguments: 4@%si 4@%di

I.e., the first argument is an unsigned 32-bit value (represented by
the "4@") that lives on %si, and the second argument is an unsigned
32-bit value that lives on %di.  Note the discrepancy between the
argument size reported by the probe (32-bit) and the register size
being used to store the value (16-bit).

However, if you take a look at the disassemble of a program that uses
this probe, you will see:

    00072c80 <__cxa_throw@@CXXABI_1.3>:
       72c80:       57                      push   %edi
       72c81:       56                      push   %esi
       72c82:       53                      push   %ebx
       72c83:       8b 74 24 10             mov    0x10(%esp),%esi
       72c87:       e8 74 bf ff ff          call   6ec00 <__cxa_finalize@plt+0x980>
       72c8c:       81 c3 74 e3 10 00       add    $0x10e374,%ebx
       72c92:       8b 7c 24 14             mov    0x14(%esp),%edi
       72c96:       90                      nop                      <----------------- PROBE IS HERE
       72c97:       e8 d4 a2 ff ff          call   6cf70 <__cxa_get_globals@plt>
       72c9c:       83 40 04 01             addl   $0x1,0x4(%eax)
       72ca0:       83 ec 04                sub    $0x4,%esp
       72ca3:       ff 74 24 1c             pushl  0x1c(%esp)
       72ca7:       57                      push   %edi
       72ca8:       56                      push   %esi
       72ca9:       e8 62 a3 ff ff          call   6d010 <__cxa_init_primary_exception@plt>
       72cae:       8d 70 40                lea    0x40(%eax),%esi
       72cb1:       c7 00 01 00 00 00       movl   $0x1,(%eax)
       72cb7:       89 34 24                mov    %esi,(%esp)
       72cba:       e8 61 96 ff ff          call   6c320 <_Unwind_RaiseException@plt>
       72cbf:       89 34 24                mov    %esi,(%esp)
       72cc2:       e8 c9 84 ff ff          call   6b190 <__cxa_begin_catch@plt>
       72cc7:       e8 d4 b3 ff ff          call   6e0a0 <_ZSt9terminatev@plt>
       72ccc:       66 90                   xchg   %ax,%ax
       72cce:       66 90                   xchg   %ax,%ax

Note how the program is actually using %edi, and not %di, to store the
second argument.  This is the problem here.

GDB will basically read the probe argument, then read the contents of
%di, and then cast this value to uint32_t, which causes the wrong
value to be obtained.  In the gdb.base/stap-probe.exp case, this makes
GDB read the wrong memory location, and not be able to display a test
string.  In Andrew's example, this causes GDB to actually stop at a
"catch throw" when it should actually have *not* stopped.

After some discussion with Frank Eigler and Jakub Jelinek, it was
decided that this bug should be fixed on the client side (i.e., the
program that actually reads the probes), and this is why I'm proposing
this patch.

The idea is simple: we will have a gdbarch method, which, for now, is
only used by i386.  The generic code that deals with register operands
on gdb/stap-probe.c will call this method if it exists, passing the
current parse information, the register name and its number.

The i386 method will then verify if the register size is greater or
equal than the size reported by the stap probe (the "4@" part).  If it
is, we're fine.  Otherwise, it will check if we're dealing with any of
the "extendable" registers (like ax, bx, si, di, sp, etc.).  If we
are, it will change the register name to include the "e" prefix.

I have tested the patch here in many scenarios, and it fixes Andrew's
bug and also the regressions I mentioned before, on
gdb.base/stap-probe.exp.  No regressions where found on other tests.

Comments?

gdb/ChangeLog:
2019-06-27  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR breakpoints/24541
	* gdbarch.c: Regenerate.
	* gdbarch.h: Regenerate.
	* gdbarch.sh: Add 'stap_adjust_register'.
	* i386-tdep.c: Include '<unordered_set>'.
	(i386_stap_adjust_register): New function.
	(i386_elf_init_abi): Register 'i386_stap_adjust_register'.
	* stap-probe.c (stap_parse_register_operand): Call
	'gdbarch_stap_adjust_register'.
2019-06-28 16:28:21 -04:00
Tom Tromey 37eedb3982 Make base class for parser_state
This makes a new base class, expr_builder, for parser_state.  This
separates the state needed to construct an expression from the state
needed by the parsers.

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

	* gdbarch.h, gdbarch.c: Rebuild.
	* gdbarch.sh (dtrace_parse_probe_argument): Change type.
	* stap-probe.h:
	(struct stap_parse_info): Replace "parser_state" with
	"expr_builder".
	* parser-defs.h (struct expr_builder): Rename from "parser_state".
	(parser_state): New class.
	* parse.c (expr_builder): Rename.
	(expr_builder::release): Rename.
	(write_exp_elt, write_exp_elt_opcode, write_exp_elt_sym)
	(write_exp_elt_msym, write_exp_elt_block, write_exp_elt_objfile)
	(write_exp_elt_longcst, write_exp_elt_floatcst)
	(write_exp_elt_type, write_exp_elt_intern, write_exp_string)
	(write_exp_string_vector, write_exp_bitstring)
	(write_exp_msymbol, mark_struct_expression)
	(write_dollar_variable)
	(insert_type_address_space, increase_expout_size): Replace
	"parser_state" with "expr_builder".
	* dtrace-probe.c: Replace "parser_state" with "expr_builder".
	* amd64-linux-tdep.c (amd64_dtrace_parse_probe_argument): Replace
	"parser_state" with "expr_builder".
2019-04-04 19:55:10 -06:00
Tom Tromey a068643d69 Change pid_to_str to return std::string
Currently the target pid_to_str method returns a const char *, so many
implementations have a static buffer that they update.  This patch
changes these methods to return a std::string instead.  I think this
is cleaner and avoids possible gotchas when calling pid_to_str on
different ptids in a single statement.  (Though no such calls exist
currently.)

This also updates various helper functions, and the gdbarch pid_to_str
methods.

I also made a best effort to fix all the callers, but I can't build
some of the *-nat.c files.

Tested by the buildbot.

gdb/ChangeLog
2019-03-13  Tom Tromey  <tromey@adacore.com>

	* i386-gnu-nat.c (i386_gnu_nat_target::fetch_registers)
	(i386_gnu_nat_target::store_registers): Update.
	* target-debug.h (target_debug_print_std_string): New macro.
	* x86-linux-nat.c (x86_linux_nat_target::enable_btrace): Update.
	* windows-tdep.c (display_one_tib): Update.
	* tui/tui-stack.c (tui_make_status_line): Update.
	* top.c (print_inferior_quit_action): Update.
	* thread.c (thr_try_catch_cmd): Update.
	(add_thread_with_info): Update.
	(thread_target_id_str): Update.
	(thr_try_catch_cmd): Update.
	(thread_command): Update.
	(thread_find_command): Update.
	* record-btrace.c (record_btrace_target::info_record)
	(record_btrace_resume_thread, record_btrace_target::resume)
	(record_btrace_cancel_resume, record_btrace_step_thread)
	(record_btrace_target::wait, record_btrace_target::wait)
	(record_btrace_target::wait, record_btrace_target::stop): Update.
	* progspace.c (print_program_space): Update.
	* process-stratum-target.c
	(process_stratum_target::thread_address_space): Update.
	* linux-fork.c (linux_fork_mourn_inferior)
	(detach_checkpoint_command, info_checkpoints_command)
	(linux_fork_context): Update.
	(linux_fork_detach): Update.
	(class scoped_switch_fork_info): Update.
	(delete_checkpoint_command): Update.
	* infrun.c (follow_fork_inferior): Update.
	(follow_fork_inferior): Update.
	(proceed_after_vfork_done): Update.
	(handle_vfork_child_exec_or_exit): Update.
	(follow_exec): Update.
	(displaced_step_prepare_throw): Update.
	(displaced_step_restore): Update.
	(start_step_over): Update.
	(resume_1): Update.
	(clear_proceed_status_thread): Update.
	(proceed): Update.
	(print_target_wait_results): Update.
	(do_target_wait): Update.
	(context_switch): Update.
	(stop_all_threads): Update.
	(restart_threads): Update.
	(finish_step_over): Update.
	(handle_signal_stop): Update.
	(switch_back_to_stepped_thread): Update.
	(keep_going_pass_signal): Update.
	(print_exited_reason): Update.
	(normal_stop): Update.
	* inferior.c (inferior_pid_to_str): Change return type.
	(print_selected_inferior): Update.
	(add_inferior): Update.
	(detach_inferior): Update.
	* dummy-frame.c (fprint_dummy_frames): Update.
	* dcache.c (dcache_info_1): Update.
	* btrace.c (btrace_enable, btrace_disable, btrace_teardown)
	(btrace_fetch, btrace_clear): Update.
	* linux-tdep.c (linux_core_pid_to_str): Change return type.
	* i386-cygwin-tdep.c (i386_windows_core_pid_to_str): Change return
	type.
	* fbsd-tdep.c (fbsd_core_pid_to_str): Change return type.
	* sol2-tdep.h (sol2_core_pid_to_str): Change return type.
	* sol2-tdep.c (sol2_core_pid_to_str): Change return type.
	* gdbarch.c, gdbarch.h: Rebuild.
	* gdbarch.sh (core_pid_to_str): Change return type.
	* windows-nat.c (struct windows_nat_target) <pid_to_str>: Change
	return type.
	(windows_nat_target::pid_to_str): Change return type.
	(windows_delete_thread): Update.
	(windows_nat_target::attach): Update.
	(windows_nat_target::files_info): Update.
	* target-delegates.c: Rebuild.
	* sol-thread.c (class sol_thread_target) <pid_to_str>: Change
	return type.
	(sol_thread_target::pid_to_str): Change return type.
	* remote.c (class remote_target) <pid_to_str>: Change return
	type.
	(remote_target::pid_to_str): Change return type.
	(extended_remote_target::attach, remote_target::remote_stop_ns)
	(remote_target::remote_notif_remove_queued_reply)
	(remote_target::push_stop_reply, remote_target::disable_btrace):
	Update.
	(extended_remote_target::attach): Update.
	* remote-sim.c (struct gdbsim_target) <pid_to_str>: Change return
	type.
	(gdbsim_target::pid_to_str): Change return type.
	* ravenscar-thread.c (struct ravenscar_thread_target)
	<pid_to_str>: Change return type.
	(ravenscar_thread_target::pid_to_str): Change return type.
	* procfs.c (class procfs_target) <pid_to_str>: Change return
	type.
	(procfs_target::pid_to_str): Change return type.
	(procfs_target::attach): Update.
	(procfs_target::detach): Update.
	(procfs_target::fetch_registers): Update.
	(procfs_target::store_registers): Update.
	(procfs_target::wait): Update.
	(procfs_target::files_info): Update.
	* obsd-nat.c (obsd_nat_target::pid_to_str): Change return type.
	* nto-procfs.c (struct nto_procfs_target) <pid_to_str>: Change
	return type.
	(nto_procfs_target::pid_to_str): Change return type.
	(nto_procfs_target::files_info, nto_procfs_target::attach): Update.
	* linux-thread-db.c (class thread_db_target) <pid_to_str>: Change
	return type.
	* linux-nat.c (linux_nat_target::pid_to_str): Change return type.
	(exit_lwp): Update.
	(attach_proc_task_lwp_callback, get_detach_signal)
	(detach_one_lwp, resume_lwp, linux_nat_target::resume)
	(linux_nat_target::resume, wait_lwp, stop_callback)
	(maybe_clear_ignore_sigint, stop_wait_callback, status_callback)
	(save_stop_reason, select_event_lwp, linux_nat_filter_event)
	(linux_nat_wait_1, resume_stopped_resumed_lwps)
	(linux_nat_target::wait, linux_nat_stop_lwp): Update.
	* inf-ptrace.c (inf_ptrace_target::pid_to_str): Change return
	type.
	(inf_ptrace_target::attach): Update.
	(inf_ptrace_target::files_info): Update.
	* go32-nat.c (struct go32_nat_target) <pid_to_str>: Change return
	type.
	(go32_nat_target::pid_to_str): Change return type.
	* gnu-nat.c (gnu_nat_target::pid_to_str): Change return type.
	(gnu_nat_target::wait): Update.
	(gnu_nat_target::wait): Update.
	(gnu_nat_target::resume): Update.
	* fbsd-nat.c (fbsd_nat_target::pid_to_str): Change return type.
	(fbsd_nat_target::wait): Update.
	* darwin-nat.c (darwin_nat_target::pid_to_str): Change return
	type.
	(darwin_nat_target::attach): Update.
	* corelow.c (class core_target) <pid_to_str>: Change return type.
	(core_target::pid_to_str): Change return type.
	* target.c (normal_pid_to_str): Change return type.
	(default_pid_to_str): Likewise.
	(target_pid_to_str): Change return type.
	(target_translate_tls_address): Update.
	(target_announce_detach): Update.
	* bsd-uthread.c (struct bsd_uthread_target) <pid_to_str>: Change
	return type.
	(bsd_uthread_target::pid_to_str): Change return type.
	* bsd-kvm.c (class bsd_kvm_target) <pid_to_str>: Change return
	type.
	(bsd_kvm_target::pid_to_str): Change return type.
	* aix-thread.c (class aix_thread_target) <pid_to_str>: Change
	return type.
	(aix_thread_target::pid_to_str): Change return type.
	* target.h (struct target_ops) <pid_to_str>: Change return type.
	(target_pid_to_str, normal_pid_to_str): Likewise.
	* obsd-nat.h (class obsd_nat_target) <pid_to_str>: Change return
	type.
	* linux-nat.h (class linux_nat_target) <pid_to_str>: Change return
	type.
	* inf-ptrace.h (struct inf_ptrace_target) <pid_to_str>: Change
	return type.
	* gnu-nat.h (struct gnu_nat_target) <pid_to_str>: Change return
	type.
	* fbsd-nat.h (class fbsd_nat_target) <pid_to_str>: Change return
	type.
	* darwin-nat.h (class darwin_nat_target) <pid_to_str>: Change
	return type.
2019-03-13 13:50:13 -06:00
John Baldwin 6e056c8178 Add a new gdbarch method to resolve the address of TLS variables.
Permit TLS variable addresses to be resolved purely by an ABI rather
than requiring a target method.  This doesn't try the target method if
the ABI function is present (even if the ABI function fails) to
simplify error handling.

gdb/ChangeLog:

	* gdbarch.sh (get_thread_local_address): New method.
	* gdbarch.h, gdbarch.c: Regenerate.
	* target.c (target_translate_tls_address): Use
	gdbarch_get_thread_local_address if present instead of
	target::get_thread_local_address.
2019-03-12 13:45:47 -07:00
Andrew Burgess 5561fc304f gdb: Restructure type_align and gdbarch_type_align
This commit restructures the relationship between the type_align
function and the gdbarch_type_align method.

The problem being addressed with this commit is this; previously the
type_align function was structured so that for "basic" types (int,
float, etc) the gdbarch_type_align hook was called, which for
"compound" types (arrays, structs, etc) the common type_align code has
a fixed method for how to extract a "basic" type and would then call
itself on that "basic" type.

The problem is that if an architecture wants to modify the alignment
rules for a "compound" type then this is not currently possible.

In the revised structure, all types pass through the
gdbarch_type_align method.  If this method returns 0 then this
indicates that the architecture has no special rules for this type,
and GDB should apply the default rules for alignment.  However, the
architecture is free to provide an alignment for any type, both
"basic" and "compound".

After this commit the default alignment rules now all live in the
type_align function, the default_type_align only ever returns 0,
meaning apply the default rules.

I've updated the 3 targets (arc, i386, and nios2) that already
override the gdbarch_type_align method to fit the new scheme.

Tested on X86-64/GNU Linux with no regressions.

gdb/ChangeLog:

	* arc-tdep.c (arc_type_align): Provide alignment for basic types,
	return 0 for other types.
	* arch-utils.c (default_type_align): Always return 0.
	* gdbarch.h: Regenerate.
	* gdbarch.sh (type_align): Extend comment.
	* gdbtypes.c (type_align): Add additional comments, always call
	gdbarch_type_align before applying the default rules.
	* i386-tdep.c (i386_type_align): Return 0 as the default rule,
	generic code will then apply a suitable default.
	* nios2-tdep.c (nios2_type_align): Provide alignment for basic
	types, return 0 for other types.
2019-02-27 10:38:15 +02:00
Andrew Burgess c6f4a5d0ed gdb: Update copyright year range generated by gdbarch.sh
The copyright year that gdbarch.sh places into the generated files
gdbarch.{c,h} wasn't updated at the start of the year.  After this
commit the gdbarch.{c,h} files regenerate as the currently are in the
tree.

gdb/ChangeLog:

	* gdbarch.sh: Update the copyright year range that is placed into
	generated files.
2019-02-22 20:17:37 +00:00
Joel Brobecker 42a4f53d2b Update copyright year range in all GDB files.
This commit applies all changes made after running the gdb/copyright.py
script.

Note that one file was flagged by the script, due to an invalid
copyright header
(gdb/unittests/basic_string_view/element_access/char/empty.cc).
As the file was copied from GCC's libstdc++-v3 testsuite, this commit
leaves this file untouched for the time being; a patch to fix the header
was sent to gcc-patches first.

gdb/ChangeLog:

	Update copyright year range in all GDB files.
2019-01-01 10:01:51 +04:00
Andrew Burgess 8bcb520897 gdb: Add default frame methods to gdbarch
Supply default gdbarch methods for gdbarch_dummy_id,
gdbarch_unwind_pc, and gdbarch_unwind_sp.  This patch doesn't actually
convert any targets to use these methods, and so, there will be no
user visible changes after this commit.

The implementations for default_dummy_id and default_unwind_sp are
fairly straight forward, these just take on the pattern used by most
targets.  Once these default methods are in place then most targets
will be able to switch over.

The implementation for default_unwind_pc is also fairly straight
forward, but maybe needs some explanation.

This patch has gone through a number of iterations:

  https://sourceware.org/ml/gdb-patches/2018-03/msg00165.html
  https://sourceware.org/ml/gdb-patches/2018-03/msg00306.html
  https://sourceware.org/ml/gdb-patches/2018-06/msg00090.html
  https://sourceware.org/ml/gdb-patches/2018-09/msg00127.html

and the implementation of default_unwind_pc has changed over this
time.  Originally, I took an implementation like this:

    CORE_ADDR
    default_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
    {
      int pc_regnum = gdbarch_pc_regnum (gdbarch);
      return frame_unwind_register_unsigned (next_frame, pc_regnum);
    }

This is basically a clone of default_unwind_sp, but using $pc.  It was
pointed out that we could potentially do better, and in version 2 the
implementation became:

    CORE_ADDR
    default_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
    {
      struct type *type;
      int pc_regnum;
      CORE_ADDR addr;
      struct value *value;

      pc_regnum = gdbarch_pc_regnum (gdbarch);
      value = frame_unwind_register_value (next_frame, pc_regnum);
      type = builtin_type (gdbarch)->builtin_func_ptr;
      addr = extract_typed_address (value_contents_all (value), type);
      addr = gdbarch_addr_bits_remove (gdbarch, addr);
      release_value (value);
      value_free (value);
      return addr;
    }

The idea was to try split out some of the steps of unwinding the $pc,
steps that are on some (or many) targets no-ops, and so allow targets
that do override these methods, to make use of default_unwind_pc.

This implementation remained in place for version 2, 3, and 4.

However, I realised that I'd made a mistake, most targets simply use
frame_unwind_register_unsigned to unwind the $pc, and this throws an
error if the register value is optimized out or unavailable.  My new
proposed implementation doesn't do this, I was going to end up
breaking many targets.

I considered duplicating the code from frame_unwind_register_unsigned
that throws the errors into my new default_unwind_pc, however, this
felt really overly complex.  So, what I instead went with was to
simply revert back to using frame_unwind_register_unsigned.  Almost
all existing targets already use this. Some of the ones that don't can
be converted to, which means almost all targets could end up using the
default.

One addition I have made over the version 1 implementation is to add a
call to gdbarch_addr_bits_remove.  For most targets this is a no-op,
but for a handful, having this call in place will mean that they can
use the default method.  After all this, the new default_unwind_pc now
looks like this:

    CORE_ADDR
    default_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
    {
      int pc_regnum = gdbarch_pc_regnum (gdbarch);
      CORE_ADDR pc = frame_unwind_register_unsigned (next_frame, pc_regnum);
      pc = gdbarch_addr_bits_remove (gdbarch, pc);
      return pc;
    }

gdb/ChangeLog:

	* gdb/dummy-frame.c (default_dummy_id): Defined new function.
	* gdb/dummy-frame.h (default_dummy_id): Declare new function.
	* gdb/frame-unwind.c (default_unwind_pc): Define new function.
	(default_unwind_sp): Define new function.
	* gdb/frame-unwind.h (default_unwind_pc): Declare new function.
	(default_unwind_sp): Declare new function.
	* gdb/frame.c (frame_unwind_pc): Assume gdbarch_unwind_pc is
	available.
	(get_frame_sp): Assume that gdbarch_unwind_sp is available.
	* gdb/gdbarch.c: Regenerate.
	* gdb/gdbarch.h: Regenerate.
	* gdb/gdbarch.sh: Update definition of dummy_id, unwind_pc, and
	unwind_sp.  Add additional header files to be included in
	generated file.
2018-12-19 20:59:38 +00:00
John Baldwin e9076973c8 Add an optional "alias" attribute to syscall entries.
When setting a syscall catchpoint by name, catch syscalls whose name
or alias matches the requested string.

When the ABI of a system call is changed in the FreeBSD kernel, this
is implemented by leaving a compatibility system call using the old
ABI at the existing "slot" and allocating a new system call for the
version using the new ABI.  For example, new fields were added to the
'struct kevent' used by the kevent() system call in FreeBSD 12.  The
previous kevent() system call in FreeBSD 12 kernels is now called
freebsd11_kevent() and is still used by older binaries compiled
against the older ABI.  The freebsd11_kevent() system call can be
tagged with an "alias" attribute of "kevent" permitting 'catch syscall
kevent' to catch both system calls and providing the expected user
behavior for both old and new binaries.  It also provides the expected
behavior if GDB is compiled on an older host (such as a FreeBSD 11
host).

gdb/ChangeLog:

	* NEWS: Add entry documenting system call aliases.
	* break-catch-syscall.c (catch_syscall_split_args): Pass 'result'
	to get_syscalls_by_name.
	* gdbarch.sh (UNKNOWN_SYSCALL): Remove.
	* gdbarch.h: Regenerate.
	* syscalls/gdb-syscalls.dtd (syscall): Add alias attribute.
	* xml-syscall.c [!HAVE_LIBEXPAT] (get_syscalls_by_name): Rename
	from get_syscall_by_name.  Now accepts a pointer to a vector of
	integers and returns a bool.
	[HAVE_LIBEXPAT] (struct syscall_desc): Add alias member.
	(syscall_create_syscall_desc): Add alias parameter and pass it to
	syscall_desc constructor.
	(syscall_start_syscall): Handle alias attribute.
	(syscall_attr): Add alias attribute.
	(xml_get_syscalls_by_name): Rename from xml_get_syscall_number.
	Now accepts a pointer to a vector of integers and returns a
	bool.  Add syscalls whose alias or name matches the requested
	name.
	(get_syscalls_by_name): Rename from get_syscall_by_name.  Now
	accepts a pointer to a vector of integers and returns a bool.
	* xml-syscall.h (get_syscalls_by_name): Likewise.

gdb/doc/ChangeLog:

	* gdb.texinfo (Set Catchpoints): Add an anchor for 'catch syscall'.
	(Native): Add a FreeBSD subsection.
	(FreeBSD): Document use of system call aliases for compatibility
	system calls.
2018-12-13 11:36:42 -08:00
Alan Hayward cf84fa6bcf Pass return_method to _push_dummy_call
gdb/ChangeLog:

	* aarch64-tdep.c (aarch64_push_dummy_call): Replace arg with
	return_method.
	* alpha-tdep.c (alpha_push_dummy_call): Likewise.
	* amd64-tdep.c (amd64_push_arguments): Likewise.
	(amd64_push_dummy_call): Likewise.
	* amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise.
	* arc-tdep.c (arc_push_dummy_call): Likewise.
	* arm-tdep.c (arm_push_dummy_call): Likewise.
	* avr-tdep.c (avr_push_dummy_call): Likewise.
	* bfin-tdep.c (bfin_push_dummy_call): Likewise.
	* cris-tdep.c (cris_push_dummy_call): Likewise.
	* csky-tdep.c (csky_push_dummy_call): Likewise.
	* frv-tdep.c (frv_push_dummy_call): Likewise.
	* gdbarch.c: Regenerate.
	* gdbarch.h: Regenerate.
	* gdbarch.sh (gdbarch_push_dummy_call): Replace arg with
	return_method.
	* h8300-tdep.c (h8300_push_dummy_call): Likewise.
	* hppa-tdep.c (hppa32_push_dummy_call): Likewise.
	(hppa64_push_dummy_call): Likewise.
	* i386-darwin-tdep.c (i386_darwin_push_dummy_call): Likewise.
	* i386-tdep.c (i386_push_dummy_call): Likewise.
	* ia64-tdep.c (ia64_push_dummy_call): Likewise.
	* infcall.c (call_function_by_hand_dummy): Likewise.
	* iq2000-tdep.c (iq2000_push_dummy_call): Likewise.
	* lm32-tdep.c (lm32_push_dummy_call): Likewise.
	* m32c-tdep.c (m32c_push_dummy_call): Likewise.
	* m32r-tdep.c (m32r_push_dummy_call): Likewise.
	* m68hc11-tdep.c (m68hc11_push_dummy_call): Likewise.
	* m68k-tdep.c (m68k_push_dummy_call): Likewise.
	* mep-tdep.c (mep_push_dummy_call): Likewise.
	* mips-tdep.c (mips_eabi_push_dummy_call): Likewise.
	(mips_n32n64_push_dummy_call): Likewise.
	(mips_o32_push_dummy_call): Likewise.
	(mips_o64_push_dummy_call): Likewise.
	* mn10300-tdep.c (mn10300_push_dummy_call): Likewise.
	* msp430-tdep.c (msp430_push_dummy_call): Likewise.
	* nds32-tdep.c (nds32_push_dummy_call): Likewise.
	* nios2-tdep.c (nios2_push_dummy_call): Likewise.
	* or1k-tdep.c (or1k_push_dummy_call): Likewise.
	* ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call): Likewise.
	(ppc64_sysv_abi_push_dummy_call): Likewise.
	* ppc-tdep.h (ppc_sysv_abi_push_dummy_call): Likewise.
	(ppc64_sysv_abi_push_dummy_call): Likewise.
	* riscv-tdep.c (riscv_push_dummy_call): Likewise.
	* rl78-tdep.c (rl78_push_dummy_call): Likewise.
	* rs6000-aix-tdep.c (rs6000_push_dummy_call): Likewise.
	* rs6000-lynx178-tdep.c (rs6000_lynx178_push_dummy_call): Likewise.
	* rx-tdep.c (rx_push_dummy_call): Likewise.
	* s390-tdep.c (s390_push_dummy_call): Likewise.
	* score-tdep.c (score_push_dummy_call): Likewise.
	* sh-tdep.c (sh_push_dummy_call_fpu): Likewise.
	(sh_push_dummy_call_nofpu): Likewise.
	* sparc-tdep.c (sparc32_store_arguments): Likewise.
	(sparc32_push_dummy_call): Likewise.
	* sparc64-tdep.c (sparc64_store_arguments): Likewise.
	(sparc64_push_dummy_call): Likewise.
	* spu-tdep.c (spu_push_dummy_call): Likewise.
	* tic6x-tdep.c (tic6x_push_dummy_call): Likewise.
	* tilegx-tdep.c (tilegx_push_dummy_call): Likewise.
	* v850-tdep.c (v850_push_dummy_call): Likewise.
	* vax-tdep.c (vax_push_dummy_call): Likewise.
	* xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise.
	* xtensa-tdep.c (xtensa_push_dummy_call): Likewise.
2018-11-16 13:45:38 +00:00
Alan Hayward c5ac5cbb5b Use enum for return method for dummy calls
In call_function_by_hand_dummy, struct_return and hidden_first_param_p
are used to represent a single concept. Replace with an enum.

gdb/ChangeLog:

	* gdbarch.sh (enum function_call_return_method): Add enum.
	* gdbarch.h: Regenerate.
	* infcall.c (call_function_by_hand_dummy): Replace vars with enum.
2018-11-16 13:45:38 +00:00
Simon Marchi f6efe3f842 Introduce gdbarch_num_cooked_regs
The expression

  gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch)

is used quite often to find the number of cooked registers (raw + pseudo
registers).  This patch introduces gdbarch_num_cooked_regs, which does
the equivalent.  It substantially reduces required wrapping in some
places, so should improve readability.

There is a for loop in m68hc11_frame_unwind_cache that had iterated
until (the equivalent of) gdbarch_num_cooked_regs (gdbarch) - 1.  During
review, we concluded that this is most likely an off-by-one mistake, so
I replaced it with gdbarch_num_cooked_regs (gdbarch).

gdb/ChangeLog:

	* gdbarch.sh (gdbarch_num_cooked_regs): New.
	* gdbarch.h: Re-generate.
	* ax-gdb.c (gen_expr): Use gdbarch_num_cooked_regs.
	* dwarf2-frame.c (dwarf2_frame_cache): Likewise.
	* eval.c (evaluate_subexp_standard): Likewise.
	* findvar.c (value_of_register): Likewise.
	(value_of_register_lazy): Likewise.
	(address_from_register): Likewise.
	* frame.c (get_frame_register_bytes): Likewise.
	* gdbarch-selftests.c (register_to_value_test): Likewise.
	* h8300-tdep.c (h8300_register_type): Likewise.
	* i386-tdep.c (i386_dbx_reg_to_regnum): Likewise.
	(i386_svr4_reg_to_regnum): Likewise.
	* infcmd.c (default_print_registers_info): Likewise.
	(registers_info): Likewise.
	(print_vector_info): Likewise.
	(default_print_float_info): Likewise.
	* m68hc11-tdep.c (m68hc11_frame_unwind_cache): Likewise.
	* mdebugread.c (mdebug_reg_to_regnum): Likewise.
	* mi/mi-main.c (mi_cmd_data_list_register_names): Likewise.
	(mi_cmd_data_list_changed_registers): Likewise.
	(mi_cmd_data_list_register_values): Likewise.
	(mi_cmd_data_write_register_values): Likewise.
	(mi_cmd_trace_frame_collected): Likewise.
	* mips-tdep.c (print_gp_register_row): Likewise.
	(mips_print_registers_info): Likewise.
	* nds32-tdep.c (nds32_gdbarch_init): Likewise.
	* regcache.c (init_regcache_descr): Likewise.
	(register_size): Likewise.
	(register_dump::dump): Likewise.
	(cooked_read_test): Likewise.
	(cooked_write_test): Likewise.
	* rs6000-tdep.c (rs6000_register_sim_regno): Likewise.
	(rs6000_gdbarch_init): Likewise.
	* stabsread.c (stab_reg_to_regnum): Likewise.
	* stack.c (info_frame_command): Likewise.
	* target-descriptions.c (tdesc_register_name): Likewise.
	* trad-frame.c (trad_frame_alloc_saved_regs): Likewise.
	* tui/tui-regs.c (tui_show_register_group): Likewise.
	* user-regs.c (user_reg_map_name_to_regnum): Likewise.
	(user_reg_map_regnum_to_name): Likewise.
	(value_of_user_reg): Likewise.
	(maintenance_print_user_registers): Likewise.
	* xtensa-tdep.c (xtensa_find_register_by_name): Likewise.
	(xtensa_register_name): Likewise.
	(xtensa_register_type): Likewise.
	(xtensa_reg_to_regnum): Likewise.
	(xtensa_pseudo_register_read): Likewise.
	(xtensa_pseudo_register_write): Likewise.
2018-10-21 22:29:21 -04:00
Pedro Alves 7ea65f08fa Add comment describing continuable/steppable/non-steppable watchpoints
These weren't described anywhere in the sources.

gdb/ChangeLog:
2018-08-31  Pedro Alves  <palves@redhat.com>

	* gdbarch.sh (have_nonsteppable_watchpoint): Add comment.
	* target.h (Hardware watchpoint interfaces): Describe
	continuable/steppable/non-steppable watchpoints.
	* gdbarch.h, gdbarch.c: Regenerate.
2018-08-31 18:47:36 +01:00
Alan Hayward a616bb9450 Split size in regset section iterators
In the existing code, when using the regset section iteration functions, the
size parameter is used in different ways.

With collect, size is used to create the buffer in which to write the regset.
(see linux-tdep.c::linux_collect_regset_section_cb).

With supply, size is used to confirm the existing regset is the correct size.
If REGSET_VARIABLE_SIZE is set then the regset can be bigger than size.
Effectively, size is the minimum possible size of the regset.
(see corelow.c::get_core_register_section).

There are currently no targets with both REGSET_VARIABLE_SIZE and a collect
function.
In SVE, a corefile can contain one of two formats after the header, both of
which are different sizes. However, when writing a core file, we always want
to write out the full bigger size.

To allow support of collects for REGSET_VARIABLE_SIZE we need two sizes.
This is done by adding supply_size and collect_size.

gdb/

	* aarch64-fbsd-tdep.c
	(aarch64_fbsd_iterate_over_regset_sections): Add supply_size and
	collect_size.
	* aarch64-linux-tdep.c
	(aarch64_linux_iterate_over_regset_sections): Likewise.
	* alpha-linux-tdep.c
	(alpha_linux_iterate_over_regset_sections):
	* alpha-nbsd-tdep.c
	(alphanbsd_iterate_over_regset_sections): Likewise.
	* amd64-fbsd-tdep.c
	(amd64fbsd_iterate_over_regset_sections): Likewise.
	* amd64-linux-tdep.c
	(amd64_linux_iterate_over_regset_sections): Likewise.
	* arm-bsd-tdep.c
	(armbsd_iterate_over_regset_sections): Likewise.
	* arm-fbsd-tdep.c
	(arm_fbsd_iterate_over_regset_sections): Likewise.
	* arm-linux-tdep.c
	(arm_linux_iterate_over_regset_sections): Likewise.
	* corelow.c (get_core_registers_cb): Likewise.
	(core_target::fetch_registers): Likewise.
	* fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise.
	* frv-linux-tdep.c (frv_linux_iterate_over_regset_sections): Likewise.
	* gdbarch.h (void): Regenerate.
	* gdbarch.sh: Add supply_size and collect_size.
	* hppa-linux-tdep.c (hppa_linux_iterate_over_regset_sections): Likewise.
	* hppa-nbsd-tdep.c (hppanbsd_iterate_over_regset_sections): Likewise.
	* hppa-obsd-tdep.c (hppaobsd_iterate_over_regset_sections): Likewise.
	* i386-fbsd-tdep.c (i386fbsd_iterate_over_regset_sections): Likewise.
	* i386-linux-tdep.c (i386_linux_iterate_over_regset_sections): Likewise.
	* i386-tdep.c (i386_iterate_over_regset_sections): Likewise.
	* ia64-linux-tdep.c (ia64_linux_iterate_over_regset_sections): Likewise.
	* linux-tdep.c (linux_collect_regset_section_cb): Likewise.
	* m32r-linux-tdep.c (m32r_linux_iterate_over_regset_sections): Likewise.
	* m68k-bsd-tdep.c (m68kbsd_iterate_over_regset_sections): Likewise.
	* m68k-linux-tdep.c (m68k_linux_iterate_over_regset_sections): Likewise.
	* mips-fbsd-tdep.c (mips_fbsd_iterate_over_regset_sections): Likewise.
	* mips-linux-tdep.c (mips_linux_iterate_over_regset_sections): Likewise.
	* mips-nbsd-tdep.c (mipsnbsd_iterate_over_regset_sections): Likewise.
	* mips64-obsd-tdep.c (mips64obsd_iterate_over_regset_sections): Likewise.
	* mn10300-linux-tdep.c (am33_iterate_over_regset_sections): Likewise.
	* nios2-linux-tdep.c (nios2_iterate_over_regset_sections): Likewise.
	* ppc-fbsd-tdep.c (ppcfbsd_iterate_over_regset_sections): Likewise.
	* ppc-linux-tdep.c (ppc_linux_iterate_over_regset_sections): Likewise.
	* ppc-nbsd-tdep.c (ppcnbsd_iterate_over_regset_sections): Likewise.
	* ppc-obsd-tdep.c (ppcobsd_iterate_over_regset_sections): Likewise.
	* riscv-linux-tdep.c (riscv_linux_iterate_over_regset_sections): Likewise.
	* rs6000-aix-tdep.c (rs6000_aix_iterate_over_regset_sections): Likewise.
	* s390-linux-tdep.c (s390_iterate_over_regset_sections): Likewise.
	* score-tdep.c (score7_linux_iterate_over_regset_sections): Likewise.
	* sh-tdep.c (sh_iterate_over_regset_sections): Likewise.
	* sparc-tdep.c (sparc_iterate_over_regset_sections): Likewise.
	* tilegx-linux-tdep.c (tilegx_iterate_over_regset_sections): Likewise.
	* vax-tdep.c (vax_iterate_over_regset_sections): Likewise.
	* xtensa-tdep.c (xtensa_iterate_over_regset_sections): Likewise.
2018-08-13 10:16:41 +01:00
Maciej W. Rozycki 471b9d1507 GDB PR tdep/8282: MIPS: Wire in `set disassembler-options'
Implement MIPS target support for passing options to the disassembler,
complementing commit 65b48a8140 ("GDB: Add support for the new
set/show disassembler-options commands.").

This includes options that expect an argument, so adjust the generic
code and data structures used so as to handle such options.  So as to
give backends syntax flexibility no specific delimiter has been defined
to separate options from their respective arguments, so it has to be
included as the last character of the option name.  Completion code
however has not been adjusted and consequently option arguments cannot
be completed at this time.

Also the MIPS target has non-empty defaults for the options, so that ABI
names for the general-purpose registers respect our `set mips abi ...'
setting rather than always being determined from the ELF headers of the
binary file selected.  Handle these defaults as implicit options, never
shown to the user and always prepended to the user-specified options, so
that the latters can override the defaults.

The resulting output for the MIPS target is as follows:

(gdb) show disassembler-options
The current disassembler options are ''

The following disassembler options are supported for use with the
'set disassembler-options <option>[,<option>...]' command:

  no-aliases      Use canonical instruction forms.

  msa             Recognize MSA instructions.

  virt            Recognize the virtualization ASE instructions.

  xpa             Recognize the eXtended Physical Address (XPA) ASE
                  instructions.

  ginv            Recognize the Global INValidate (GINV) ASE instructions.

  gpr-names=ABI   Print GPR names according to specified ABI.
                  Default: based on binary being disassembled.

  fpr-names=ABI   Print FPR names according to specified ABI.
                  Default: numeric.

  cp0-names=ARCH  Print CP0 register names according to specified architecture.
                  Default: based on binary being disassembled.

  hwr-names=ARCH  Print HWR names according to specified architecture.
                  Default: based on binary being disassembled.

  reg-names=ABI   Print GPR and FPR names according to specified ABI.

  reg-names=ARCH  Print CP0 register and HWR names according to specified
                  architecture.

  For the options above, the following values are supported for "ABI":
    numeric 32 n32 64

  For the options above, the following values are supported for "ARCH":
    numeric r3000 r3900 r4000 r4010 vr4100 vr4111 vr4120 r4300 r4400 r4600
    r4650 r5000 vr5400 vr5500 r5900 r6000 rm7000 rm9000 r8000 r10000 r12000
    r14000 r16000 mips5 mips32 mips32r2 mips32r3 mips32r5 mips32r6 mips64
    mips64r2 mips64r3 mips64r5 mips64r6 interaptiv-mr2 sb1 loongson2e
    loongson2f loongson3a octeon octeon+ octeon2 octeon3 xlr xlp
(gdb)

which corresponds to what `objdump --help' used to print for the MIPS
target, with minor formatting changes, most notably option argument
lists being wrapped, but also the amount of white space separating
options from the respective descriptions.  The relevant part the new
code is now also used by `objdump --help', which means these formatting
changes apply to both outputs, except for argument list wrapping, which
is GDB-specific.

This also adds a separating new line between the heading and option
lists where descriptions are provided, hence:

(gdb) set architecture s390:31-bit
(gdb) show disassembler-options
The current disassembler options are ''

The following disassembler options are supported for use with the
'set disassembler-options <option>[,<option>...]' command:

  esa         Disassemble in ESA architecture mode
  zarch       Disassemble in z/Architecture mode
  insnlength  Print unknown instructions according to length from first two bits
(gdb)

but:

(gdb) set architecture powerpc:common
(gdb) show disassembler-options
The current disassembler options are ''

The following disassembler options are supported for use with the
'set disassembler-options <option>[,<option>...]' command:
  403, 405, 440, 464, 476, 601, 603, 604, 620, 7400, 7410, 7450, 7455, 750cl,
  821, 850, 860, a2, altivec, any, booke, booke32, cell, com, e200z4, e300,
  e500, e500mc, e500mc64, e5500, e6500, e500x2, efs, efs2, power4, power5,
  power6, power7, power8, power9, ppc, ppc32, 32, ppc64, 64, ppc64bridge,
  ppcps, pwr, pwr2, pwr4, pwr5, pwr5x, pwr6, pwr7, pwr8, pwr9, pwrx, raw, spe,
  spe2, titan, vle, vsx
(gdb)

Existing affected target backends have been adjusted accordingly.

This has been verified manually with:

(gdb) set architecture arm
(gdb) set architecture powerpc:common
(gdb) set architecture s390:31-bit

to cause no issues with the `show disassembler-options' and `set
disassembler-options' commands.  A test case for the MIPS target has
also been provided, covering the default settings with ABI overrides as
well as disassembler option overrides.

2018-07-02  Maciej W. Rozycki  <macro@mips.com>
            Simon Marchi  <simon.marchi@polymtl.ca>

	include/
	PR tdep/8282
	* dis-asm.h (disasm_option_arg_t): New typedef.
	(disasm_options_and_args_t): Likewise.
	(disasm_options_t): Add `arg' member, document members.
	(disassembler_options_mips): New prototype.
	(disassembler_options_arm, disassembler_options_powerpc)
	(disassembler_options_s390): Update prototypes.

	opcodes/
	PR tdep/8282
	* mips-dis.c (mips_option_arg_t): New enumeration.
	(mips_options): New variable.
	(disassembler_options_mips): New function.
	(print_mips_disassembler_options): Reimplement in terms of
	`disassembler_options_mips'.
	* arm-dis.c (disassembler_options_arm): Adapt to using the
	`disasm_options_and_args_t' structure.
	* ppc-dis.c (disassembler_options_powerpc): Likewise.
	* s390-dis.c (disassembler_options_s390): Likewise.

	gdb/
	PR tdep/8282
	* disasm.h (gdb_disassembler): Add
	`m_disassembler_options_holder'. member
	* disasm.c (get_all_disassembler_options): New function.
	(gdb_disassembler::gdb_disassembler): Use it.
	(gdb_buffered_insn_length_init_dis): Likewise.
	(gdb_buffered_insn_length): Adjust accordingly.
	(set_disassembler_options): Handle options with arguments.
	(show_disassembler_options_sfunc): Likewise.  Add a leading new
	line if showing options with descriptions.
	(disassembler_options_completer): Adapt to using the
	`disasm_options_and_args_t' structure.
	* mips-tdep.c (mips_disassembler_options): New variable.
	(mips_disassembler_options_o32): Likewise.
	(mips_disassembler_options_n32): Likewise.
	(mips_disassembler_options_n64): Likewise.
	(gdb_print_insn_mips): Don't set `disassembler_options'.
	(gdb_print_insn_mips_n32, gdb_print_insn_mips_n64): Remove
	functions.
	(mips_gdbarch_init): Always set `gdbarch_print_insn' to
	`gdb_print_insn_mips'.  Set `gdbarch_disassembler_options',
	`gdbarch_disassembler_options_implicit' and
	`gdbarch_valid_disassembler_options'.
	* arm-tdep.c (_initialize_arm_tdep): Adapt to using the
	`disasm_options_and_args_t' structure.
	* gdbarch.sh (disassembler_options_implicit): New `gdbarch'
	method.
	(valid_disassembler_options): Switch from `disasm_options_t' to
	the `disasm_options_and_args_t' structure.
	* NEWS: Document `set disassembler-options' support for the MIPS
	target.
	* gdbarch.h: Regenerate.
	* gdbarch.c: Regenerate.

	gdb/doc/
	PR tdep/8282
	* gdb.texinfo (Source and Machine Code): Document `set
	disassembler-options' support for the MIPS target.

	gdb/testsuite/
	PR tdep/8282
	* gdb.arch/mips-disassembler-options.exp: New test.
	* gdb.arch/mips-disassembler-options.s: New test source.
2018-07-02 23:57:21 +01:00
Pedro Alves 00431a78b2 Use thread_info and inferior pointers more throughout
This is more preparation bits for multi-target support.

In a multi-target scenario, we need to address the case of different
processes/threads running on different targets that happen to have the
same PID/PTID.  E.g., we can have both process 123 in target 1, and
process 123 in target 2, while they're in reality different processes
running on different machines.  Or maybe we've loaded multiple
instances of the same core file.  Etc.

To address this, in my WIP multi-target branch, threads and processes
are uniquely identified by the (process_stratum target_ops *, ptid_t)
and (process_stratum target_ops *, pid) tuples respectively.  I.e.,
each process_stratum instance has its own thread/process number space.

As you can imagine, that requires passing around target_ops * pointers
in a number of functions where we're currently passing only a ptid_t
or an int.  E.g., when we look up a thread_info object by ptid_t in
find_thread_ptid, the ptid_t alone isn't sufficient.

In many cases though, we already have the thread_info or inferior
pointer handy, but we "lose" it somewhere along the call stack, only
to look it up again by ptid_t/pid.  Since thread_info or inferior
objects know their parent target, if we pass around thread_info or
inferior pointers when possible, we avoid having to add extra
target_ops parameters to many functions, and also, we eliminate a
number of by ptid_t/int lookups.

So that's what this patch does.  In a bit more detail:

- Changes a number of functions and methods to take a thread_info or
  inferior pointer instead of a ptid_t or int parameter.

- Changes a number of structure fields from ptid_t/int to inferior or
  thread_info pointers.

- Uses the inferior_thread() function whenever possible instead of
  inferior_ptid.

- Uses thread_info pointers directly when possible instead of the
  is_running/is_stopped etc. routines that require a lookup.

- A number of functions are eliminated along the way, such as:

  int valid_gdb_inferior_id (int num);
  int pid_to_gdb_inferior_id (int pid);
  int gdb_inferior_id_to_pid (int num);
  int in_inferior_list (int pid);

- A few structures and places hold a thread_info pointer across
  inferior execution, so now they take a strong reference to the
  (refcounted) thread_info object to avoid the thread_info pointer
  getting stale.  This is done in enable_thread_stack_temporaries and
  in the infcall.c code.

- Related, there's a spot in infcall.c where using a RAII object to
  handle the refcount would be handy, so a gdb::ref_ptr specialization
  for thread_info is added (thread_info_ref, in gdbthread.h), along
  with a gdb_ref_ptr policy that works for all refcounted_object types
  (in common/refcounted-object.h).

gdb/ChangeLog:
2018-06-21  Pedro Alves  <palves@redhat.com>

	* ada-lang.h (ada_get_task_number): Take a thread_info pointer
	instead of a ptid_t.  All callers adjusted.
	* ada-tasks.c (ada_get_task_number): Likewise.  All callers
	adjusted.
	(print_ada_task_info, display_current_task_id, task_command_1):
	Adjust.
	* breakpoint.c (watchpoint_in_thread_scope): Adjust to use
	inferior_thread.
	(breakpoint_kind): Adjust.
	(remove_breakpoints_pid): Rename to ...
	(remove_breakpoints_inf): ... this.  Adjust to take an inferior
	pointer.  All callers adjusted.
	(bpstat_clear_actions): Use inferior_thread.
	(get_bpstat_thread): New.
	(bpstat_do_actions): Use it.
	(bpstat_check_breakpoint_conditions, bpstat_stop_status): Adjust
	to take a thread_info pointer.  All callers adjusted.
	(set_longjmp_breakpoint_for_call_dummy, set_momentary_breakpoint)
	(breakpoint_re_set_thread): Use inferior_thread.
	* breakpoint.h (struct inferior): Forward declare.
	(bpstat_stop_status): Update.
	(remove_breakpoints_pid): Delete.
	(remove_breakpoints_inf): New.
	* bsd-uthread.c (bsd_uthread_target::wait)
	(bsd_uthread_target::update_thread_list): Use find_thread_ptid.
	* btrace.c (btrace_add_pc, btrace_enable, btrace_fetch)
	(maint_btrace_packet_history_cmd)
	(maint_btrace_clear_packet_history_cmd): Adjust.
	(maint_btrace_clear_cmd, maint_info_btrace_cmd): Adjust to use
	inferior_thread.
	* cli/cli-interp.c: Include "inferior.h".
	* common/refcounted-object.h (struct
	refcounted_object_ref_policy): New.
	* compile/compile-object-load.c: Include gdbthread.h.
	(store_regs): Use inferior_thread.
	* corelow.c (core_target::close): Use current_inferior.
	(core_target_open): Adjust to use first_thread_of_inferior and use
	the current inferior.
	* ctf.c (ctf_target::close): Adjust to use current_inferior.
	* dummy-frame.c (dummy_frame_id) <ptid>: Delete, replaced by ...
	<thread>: ... this new field.  All references adjusted.
	(dummy_frame_pop, dummy_frame_discard, register_dummy_frame_dtor):
	Take a thread_info pointer instead of a ptid_t.
	* dummy-frame.h (dummy_frame_push, dummy_frame_pop)
	(dummy_frame_discard, register_dummy_frame_dtor): Take a
	thread_info pointer instead of a ptid_t.
	* elfread.c: Include "inferior.h".
	(elf_gnu_ifunc_resolver_stop, elf_gnu_ifunc_resolver_return_stop):
	Use inferior_thread.
	* eval.c (evaluate_subexp): Likewise.
	* frame.c (frame_pop, has_stack_frames, find_frame_sal): Use
	inferior_thread.
	* gdb_proc_service.h (struct thread_info): Forward declare.
	(struct ps_prochandle) <ptid>: Delete, replaced by ...
	<thread>: ... this new field.  All references adjusted.
	* gdbarch.h, gdbarch.c: Regenerate.
	* gdbarch.sh (get_syscall_number): Replace 'ptid' parameter with a
	'thread' parameter.  All implementations and callers adjusted.
	* gdbthread.h (thread_info) <set_running>: New method.
	(delete_thread, delete_thread_silent): Take a thread_info pointer
	instead of a ptid.
	(global_thread_id_to_ptid, ptid_to_global_thread_id): Delete.
	(first_thread_of_process): Delete, replaced by ...
	(first_thread_of_inferior): ... this new function.  All callers
	adjusted.
	(any_live_thread_of_process): Delete, replaced by ...
	(any_live_thread_of_inferior): ... this new function.  All callers
	adjusted.
	(switch_to_thread, switch_to_no_thread): Declare.
	(is_executing): Delete.
	(enable_thread_stack_temporaries): Update comment.
	<enable_thread_stack_temporaries>: Take a thread_info pointer
	instead of a ptid_t.  Incref the thread.
	<~enable_thread_stack_temporaries>: Decref the thread.
	<m_ptid>: Delete
	<m_thr>: New.
	(thread_stack_temporaries_enabled_p, push_thread_stack_temporary)
	(get_last_thread_stack_temporary)
	(value_in_thread_stack_temporaries, can_access_registers_thread):
	Take a thread_info pointer instead of a ptid_t.  All callers
	adjusted.
	* infcall.c (get_call_return_value): Use inferior_thread.
	(run_inferior_call): Work with thread pointers instead of ptid_t.
	(call_function_by_hand_dummy): Work with thread pointers instead
	of ptid_t.  Use thread_info_ref.
	* infcmd.c (proceed_thread_callback): Access thread's state
	directly.
	(ensure_valid_thread, ensure_not_running): Use inferior_thread,
	access thread's state directly.
	(continue_command): Use inferior_thread.
	(info_program_command): Use find_thread_ptid and access thread
	state directly.
	(proceed_after_attach_callback): Use thread state directly.
	(notice_new_inferior): Take a thread_info pointer instead of a
	ptid_t.  All callers adjusted.
	(exit_inferior): Take an inferior pointer instead of a pid.  All
	callers adjusted.
	(exit_inferior_silent): New.
	(detach_inferior): Delete.
	(valid_gdb_inferior_id, pid_to_gdb_inferior_id)
	(gdb_inferior_id_to_pid, in_inferior_list): Delete.
	(detach_inferior_command, kill_inferior_command): Use
	find_inferior_id instead of valid_gdb_inferior_id and
	gdb_inferior_id_to_pid.
	(inferior_command): Use inferior and thread pointers.
	* inferior.h (struct thread_info): Forward declare.
	(notice_new_inferior): Take a thread_info pointer instead of a
	ptid_t.  All callers adjusted.
	(detach_inferior): Delete declaration.
	(exit_inferior, exit_inferior_silent): Take an inferior pointer
	instead of a pid.  All callers adjusted.
	(gdb_inferior_id_to_pid, pid_to_gdb_inferior_id, in_inferior_list)
	(valid_gdb_inferior_id): Delete.
	* infrun.c (follow_fork_inferior, proceed_after_vfork_done)
	(handle_vfork_child_exec_or_exit, follow_exec): Adjust.
	(struct displaced_step_inferior_state) <pid>: Delete, replaced by
	...
	<inf>: ... this new field.
	<step_ptid>: Delete, replaced by ...
	<step_thread>: ... this new field.
	(get_displaced_stepping_state): Take an inferior pointer instead
	of a pid.  All callers adjusted.
	(displaced_step_in_progress_any_inferior): Adjust.
	(displaced_step_in_progress_thread): Take a thread pointer instead
	of a ptid_t.  All callers adjusted.
	(displaced_step_in_progress, add_displaced_stepping_state): Take
	an inferior pointer instead of a pid.  All callers adjusted.
	(get_displaced_step_closure_by_addr): Adjust.
	(remove_displaced_stepping_state): Take an inferior pointer
	instead of a pid.  All callers adjusted.
	(displaced_step_prepare_throw, displaced_step_prepare)
	(displaced_step_fixup): Take a thread pointer instead of a ptid_t.
	All callers adjusted.
	(start_step_over): Adjust.
	(infrun_thread_ptid_changed): Remove bit updating ptids in the
	displaced step queue.
	(do_target_resume): Adjust.
	(fetch_inferior_event): Use inferior_thread.
	(context_switch, get_inferior_stop_soon): Take an
	execution_control_state pointer instead of a ptid_t.  All callers
	adjusted.
	(switch_to_thread_cleanup): Delete.
	(stop_all_threads): Use scoped_restore_current_thread.
	* inline-frame.c: Include "gdbthread.h".
	(inline_state) <inline_state>: Take a thread pointer instead of a
	ptid_t.  All callers adjusted.
	<ptid>: Delete, replaced by ...
	<thread>: ... this new field.
	(find_inline_frame_state): Take a thread pointer instead of a
	ptid_t.  All callers adjusted.
	(skip_inline_frames, step_into_inline_frame)
	(inline_skipped_frames, inline_skipped_symbol): Take a thread
	pointer instead of a ptid_t.  All callers adjusted.
	* inline-frame.h (skip_inline_frames, step_into_inline_frame)
	(inline_skipped_frames, inline_skipped_symbol): Likewise.
	* linux-fork.c (delete_checkpoint_command): Adjust to use thread
	pointers directly.
	* linux-nat.c (get_detach_signal): Likewise.
	* linux-thread-db.c (thread_from_lwp): New 'stopped' parameter.
	(thread_db_notice_clone): Adjust.
	(thread_db_find_new_threads_silently)
	(thread_db_find_new_threads_2, thread_db_find_new_threads_1): Take
	a thread pointer instead of a ptid_t.  All callers adjusted.
	* mi/mi-cmd-var.c: Include "inferior.h".
	(mi_cmd_var_update_iter): Update to use thread pointers.
	* mi/mi-interp.c (mi_new_thread): Update to use the thread's
	inferior directly.
	(mi_output_running_pid, mi_inferior_count): Delete, bits factored
	out to ...
	(mi_output_running): ... this new function.
	(mi_on_resume_1): Adjust to use it.
	(mi_user_selected_context_changed): Adjust to use inferior_thread.
	* mi/mi-main.c (proceed_thread): Adjust to use thread pointers
	directly.
	(interrupt_thread_callback): : Adjust to use thread and inferior
	pointers.
	* proc-service.c: Include "gdbthread.h".
	(ps_pglobal_lookup): Adjust to use the thread's inferior directly.
	* progspace-and-thread.c: Include "inferior.h".
	* progspace.c: Include "inferior.h".
	* python/py-exitedevent.c (create_exited_event_object): Adjust to
	hold a reference to an inferior_object.
	* python/py-finishbreakpoint.c (bpfinishpy_init): Adjust to use
	inferior_thread.
	* python/py-inferior.c (struct inferior_object): Give the type a
	tag name instead of a typedef.
	(python_on_normal_stop): No need to check if the current thread is
	listed.
	(inferior_to_inferior_object): Change return type to
	inferior_object.  All callers adjusted.
	(find_thread_object): Delete, bits factored out to ...
	(thread_to_thread_object): ... this new function.
	* python/py-infthread.c (create_thread_object): Use
	inferior_to_inferior_object.
	(thpy_is_stopped): Use thread pointer directly.
	(gdbpy_selected_thread): Use inferior_thread.
	* python/py-record-btrace.c (btpy_list_object) <ptid>: Delete
	field, replaced with ...
	<thread>: ... this new field.  All users adjusted.
	(btpy_insn_or_gap_new): Drop const.
	(btpy_list_new): Take a thread pointer instead of a ptid_t.  All
	callers adjusted.
	* python/py-record.c: Include "gdbthread.h".
	(recpy_insn_new, recpy_func_new): Take a thread pointer instead of
	a ptid_t.  All callers adjusted.
	(gdbpy_current_recording): Use inferior_thread.
	* python/py-record.h (recpy_record_object) <ptid>: Delete
	field, replaced with ...
	<thread>: ... this new field.  All users adjusted.
	(recpy_element_object) <ptid>: Delete
	field, replaced with ...
	<thread>: ... this new field.  All users adjusted.
	(recpy_insn_new, recpy_func_new): Take a thread pointer instead of
	a ptid_t.  All callers adjusted.
	* python/py-threadevent.c: Include "gdbthread.h".
	(get_event_thread): Use thread_to_thread_object.
	* python/python-internal.h (struct inferior_object): Forward
	declare.
	(find_thread_object, find_inferior_object): Delete declarations.
	(thread_to_thread_object, inferior_to_inferior_object): New
	declarations.
	* record-btrace.c: Include "inferior.h".
	(require_btrace_thread): Use inferior_thread.
	(record_btrace_frame_sniffer)
	(record_btrace_tailcall_frame_sniffer): Use inferior_thread.
	(get_thread_current_frame): Use scoped_restore_current_thread and
	switch_to_thread.
	(get_thread_current_frame): Use thread pointer directly.
	(record_btrace_replay_at_breakpoint): Use thread's inferior
	pointer directly.
	* record-full.c: Include "inferior.h".
	* regcache.c: Include "gdbthread.h".
	(get_thread_arch_regcache): Use the inferior's address space
	directly.
	(get_thread_regcache, registers_changed_thread): New.
	* regcache.h (get_thread_regcache(thread_info *thread)): New
	overload.
	(registers_changed_thread): New.
	(remote_target) <remote_detach_1>: Swap order of parameters.
	(remote_add_thread): <remote_add_thread>: Return the new thread.
	(get_remote_thread_info(ptid_t)): New overload.
	(remote_target::remote_notice_new_inferior): Use thread pointers
	directly.
	(remote_target::process_initial_stop_replies): Use
	thread_info::set_running.
	(remote_target::remote_detach_1, remote_target::detach)
	(extended_remote_target::detach): Adjust.
	* stack.c (frame_show_address): Use inferior_thread.
	* target-debug.h (target_debug_print_thread_info_pp): New.
	* target-delegates.c: Regenerate.
	* target.c (default_thread_address_space): Delete.
	(memory_xfer_partial_1): Use current_inferior.
	(target_detach): Use current_inferior.
	(target_thread_address_space): Delete.
	(generic_mourn_inferior): Use current_inferior.
	* target.h (struct target_ops) <thread_address_space>: Delete.
	(target_thread_address_space): Delete.
	* thread.c (init_thread_list): Use ALL_THREADS_SAFE.  Use thread
	pointers directly.
	(delete_thread_1, delete_thread, delete_thread_silent): Take a
	thread pointer instead of a ptid_t.  Adjust all callers.
	(ptid_to_global_thread_id, global_thread_id_to_ptid): Delete.
	(first_thread_of_process): Delete, replaced by ...
	(first_thread_of_inferior): ... this new function.  All callers
	adjusted.
	(any_thread_of_process): Rename to ...
	(any_thread_of_inferior): ... this, and take an inferior pointer.
	(any_live_thread_of_process): Rename to ...
	(any_live_thread_of_inferior): ... this, and take an inferior
	pointer.
	(thread_stack_temporaries_enabled_p, push_thread_stack_temporary)
	(value_in_thread_stack_temporaries)
	(get_last_thread_stack_temporary): Take a thread pointer instead
	of a ptid_t.  Adjust all callers.
	(thread_info::set_running): New.
	(validate_registers_access): Use inferior_thread.
	(can_access_registers_ptid): Rename to ...
	(can_access_registers_thread): ... this, and take a thread
	pointer.
	(print_thread_info_1): Adjust to compare thread pointers instead
	of ptids.
	(switch_to_no_thread, switch_to_thread): Make extern.
	(scoped_restore_current_thread::~scoped_restore_current_thread):
	Use m_thread pointer directly.
	(scoped_restore_current_thread::scoped_restore_current_thread):
	Use inferior_thread.
	(thread_command): Use thread pointer directly.
	(thread_num_make_value_helper): Use inferior_thread.
	* top.c (execute_command): Use inferior_thread.
	* tui/tui-interp.c: Include "inferior.h".
	* varobj.c (varobj_create): Use inferior_thread.
	(value_of_root_1): Use find_thread_global_id instead of
	global_thread_id_to_ptid.
2018-06-21 17:09:31 +01:00
Omair Javaid 5969f0dba7 Unset gdbarch significant_addr_bit by default
This patch fixes a bug introduced by fix to AArch64 pointer tagging.

In our fix for tagged pointer support our agreed approach was to sign
extend user-space address after clearing tag bits. This is not same
for all architectures and this patch allows sign extension for
addresses on targets which specifically set significant_addr_bit.

More information about patch that caused the issues and discussion
around tagged pointer support can be found in links below:

https://sourceware.org/ml/gdb-patches/2018-05/msg00000.html
https://sourceware.org/ml/gdb-patches/2017-12/msg00159.html

gdb/ChangeLog:

2018-05-31  Omair Javaid  <omair.javaid@linaro.org>

	PR gdb/23210
	* gdbarch.sh (significant_addr_bit): Default to zero when
	not set by target architecture.
	* gdbarch.c: Re-generated.
	* utils.c (address_significant): Update.
2018-05-31 07:31:21 +05:00
Simon Marchi 284a0e3cbf Introduce obstack_new, poison other "typed" obstack functions
Since we use obstacks with objects that are not default constructible,
we sometimes need to manually call the constructor by hand using
placement new:

  foo *f = obstack_alloc (obstack, sizeof (foo));
  f = new (f) foo;

It's possible to use allocate_on_obstack instead, but there are types
that we sometimes want to allocate on an obstack, and sometimes on the
regular heap.  This patch introduces a utility to make this pattern
simpler if allocate_on_obstack is not an option:

  foo *f = obstack_new<foo> (obstack);

Right now there's only one usage (in tdesc_data_init).

To help catch places where we would forget to call new when allocating
such an object on an obstack, this patch also poisons some other methods
of allocating an instance of a type on an obstack:

  - OBSTACK_ZALLOC/OBSTACK_CALLOC
  - XOBNEW/XOBNEW
  - GDBARCH_OBSTACK_ZALLOC/GDBARCH_OBSTACK_CALLOC

Unfortunately, there's no way to catch wrong usages of obstack_alloc.

By pulling on that string though, it tripped on allocating struct
template_symbol using OBSTACK_ZALLOC.  The criterion currently used to
know whether it's safe to "malloc" an instance of a struct is whether it
is a POD.  Because it inherits from struct symbol, template_symbol is
not a POD.  This criterion is a bit too strict however, it should still
safe to allocate memory for a template_symbol and memset it to 0.  We
didn't use is_trivially_constructible as the criterion in the first
place only because it is not available in gcc < 5.  So here I considered
two alternatives:

1. Relax that criterion to use std::is_trivially_constructible and add a
   bit more glue code to make it work with gcc < 5
2. Continue pulling on the string and change how the symbol structures
   are allocated and initialized

I managed to do both, but I decided to go with #1 to keep this patch
simpler and more focused.  When building with a compiler that does not
have is_trivially_constructible, the check will just not be enforced.

gdb/ChangeLog:

	* common/traits.h (HAVE_IS_TRIVIALLY_COPYABLE): Define if
	compiler supports std::is_trivially_constructible.
	* common/poison.h: Include obstack.h.
	(IsMallocable): Define to is_trivially_constructible if the
	compiler supports it, define to true_type otherwise.
	(xobnew): New.
	(XOBNEW): Redefine.
	(xobnewvec): New.
	(XOBNEWVEC): Redefine.
	* gdb_obstack.h (obstack_zalloc): New.
	(OBSTACK_ZALLOC): Redefine.
	(obstack_calloc): New.
	(OBSTACK_CALLOC): Redefine.
	(obstack_new): New.
	* gdbarch.sh: Include gdb_obstack in gdbarch.h.
	(gdbarch_obstack): New declaration in gdbarch.h, definition in
	gdbarch.c.
	(GDBARCH_OBSTACK_CALLOC, GDBARCH_OBSTACK_ZALLOC): Use
	obstack_calloc/obstack_zalloc.
	(gdbarch_obstack_zalloc): Remove.
	* target-descriptions.c (tdesc_data_init): Use obstack_new.
2018-05-20 21:06:36 -04:00
Tom Tromey e11fb955fb Remove long_long_align_bit gdbarch attribute
This removes the long_long_align_bit gdbarch attribute in favor of
type_align.  This uncovered two possible issues.

First, arc-tdep.c claimed that long long alignment was 32 bits, but as
discussed on the list, ARC has a maximum alignment of 32 bits, so I've
added an arc_type_align function to account for this.

Second, jit.c, the sole user of long_long_align_bit, was confusing
"long long" with uint64_t.  The relevant structure is defined in the
JIT API part of the manual as:

     struct jit_code_entry
     {
       struct jit_code_entry *next_entry;
       struct jit_code_entry *prev_entry;
       const char *symfile_addr;
       uint64_t symfile_size;
     };

I've changed this code to use uint64_t.

2018-04-30  Tom Tromey  <tom@tromey.com>

	* jit.c (jit_read_code_entry): Use type_align.
	* i386-tdep.c (i386_gdbarch_init): Don't call
	set_gdbarch_long_long_align_bit.
	* gdbarch.sh: Remove long_long_align_bit.
	* gdbarch.c, gdbarch.h: Rebuild.
	* arc-tdep.c (arc_type_align): New function.
	(arc_gdbarch_init): Use arc_type_align.  Don't call
	set_gdbarch_long_long_align_bit.
2018-04-30 11:25:32 -06:00
Tom Tromey 2b4424c35b Add initial type alignment support
This adds some basic type alignment support to gdb.  It changes struct
type to store the alignment, and updates dwarf2read.c to handle
DW_AT_alignment.  It also adds a new gdbarch method and updates
i386-tdep.c.

None of this new functionality is used anywhere yet, so tests will
wait until the next patch.

2018-04-30  Tom Tromey  <tom@tromey.com>

	* i386-tdep.c (i386_type_align): New function.
	(i386_gdbarch_init): Update.
	* gdbarch.sh (type_align): New method.
	* gdbarch.c, gdbarch.h: Rebuild.
	* arch-utils.h (default_type_align): Declare.
	* arch-utils.c (default_type_align): New function.
	* gdbtypes.h (TYPE_ALIGN_BITS): New define.
	(struct type) <align_log2>: New field.
	<instance_flags>: Now a bitfield.
	(TYPE_RAW_ALIGN): New macro.
	(type_align, type_raw_align, set_type_align): Declare.
	* gdbtypes.c (type_align, type_raw_align, set_type_align): New
	functions.
	* dwarf2read.c (quirk_rust_enum): Set type alignment.
	(get_alignment, maybe_set_alignment): New functions.
	(read_structure_type, read_enumeration_type, read_array_type)
	(read_set_type, read_tag_pointer_type, read_tag_reference_type)
	(read_subrange_type, read_base_type): Set type alignment.
2018-04-30 11:25:30 -06:00
Markus Metzger 1d509aa625 infrun: step through indirect branch thunks
With version 7.3 GCC supports new options

   -mindirect-branch=<choice>
   -mfunction-return=<choice>

The choices are:

    keep                behaves as before
    thunk               jumps through a thunk
    thunk-external      jumps through an external thunk
    thunk-inline        jumps through an inlined thunk

For thunk and thunk-external, GDB would, on a call to the thunk, step into
the thunk and then resume to its caller assuming that this is an
undebuggable function.  On a return thunk, GDB would stop inside the
thunk.

Make GDB step through such thunks instead.

Before:
    Temporary breakpoint 1, main ()
        at gdb.base/step-indirect-call-thunk.c:37
    37        x = apply (inc, 41);
    (gdb) s
    apply (op=0x80483e6 <inc>, x=41)
        at gdb.base/step-indirect-call-thunk.c:29
    29        return op (x);
    (gdb)
    30      }

After:
    Temporary breakpoint 1, main ()
        at gdb.base/step-indirect-call-thunk.c:37
    37        x = apply (inc, 41);
    (gdb) s
    apply (op=0x80483e6 <inc>, x=41)
        at gdb.base/step-indirect-call-thunk.c:29
    29        return op (x);
    (gdb)
    inc (x=41) at gdb.base/step-indirect-call-thunk.c:23
    23        return x + 1;

This is independent of the step-mode.  In order to step into the thunk,
you would need to use stepi.

When stepping over an indirect call thunk, GDB would first step through
the thunk, then recognize that it stepped into a sub-routine and resume to
the caller (of the thunk).  Not sure whether this is worth optimizing.

Thunk detection is implemented via gdbarch.  I implemented the methods for
IA.  Other architectures may run into unexpected fails.

The tests assume a fixed number of instruction steps to reach a thunk.
This depends on the compiler as well as the architecture.  They may need
adjustments when we add support for more architectures.  Or we can simply
drop those tests that cover being able to step into thunks using
instruction stepping.

When using an older GCC, the tests will fail to build and will be reported
as untested:

    Running .../gdb.base/step-indirect-call-thunk.exp ...
    gdb compile failed, \
    gcc: error: unrecognized command line option '-mindirect-branch=thunk'
    gcc: error: unrecognized command line option '-mfunction-return=thunk'

                    === gdb Summary ===

    # of untested testcases         1

gdb/
	* infrun.c (process_event_stop_test): Call
	gdbarch_in_indirect_branch_thunk.
	* gdbarch.sh (in_indirect_branch_thunk): New.
	* gdbarch.c: Regenerated.
	* gdbarch.h: Regenerated.
	* x86-tdep.h: New.
	* x86-tdep.c: New.
	* Makefile.in (ALL_TARGET_OBS): Add x86-tdep.o.
	(HFILES_NO_SRCDIR): Add x86-tdep.h.
	(ALLDEPFILES): Add x86-tdep.c.
	* arch-utils.h (default_in_indirect_branch_thunk): New.
	* arch-utils.c (default_in_indirect_branch_thunk): New.
	* i386-tdep: Include x86-tdep.h.
	(i386_in_indirect_branch_thunk): New.
	(i386_elf_init_abi): Set in_indirect_branch_thunk gdbarch
	function.
	* amd64-tdep: Include x86-tdep.h.
	(amd64_in_indirect_branch_thunk): New.
	(amd64_init_abi): Set in_indirect_branch_thunk gdbarch function.

testsuite/
	* gdb.base/step-indirect-call-thunk.exp: New.
	* gdb.base/step-indirect-call-thunk.c: New.
	* gdb.reverse/step-indirect-call-thunk.exp: New.
	* gdb.reverse/step-indirect-call-thunk.c: New.
2018-04-13 10:44:47 +02:00
Pedro Alves 0bee6dd4aa Apply "Convert observers to C++" edit to gdbarch.sh
Regenerating gdbarch.c results in:

  --- gdbarch.c   2018-03-26 23:18:52.905548891 +0100
  +++ new-gdbarch.c       2018-04-09 15:32:30.006712207 +0100
  @@ -44,7 +44,7 @@
   #include "reggroups.h"
   #include "osabi.h"
   #include "gdb_obstack.h"
  -#include "observable.h"
  +#include "observer.h"
   #include "regcache.h"
   #include "objfiles.h"
   #include "auxv.h"
  @@ -5457,7 +5457,7 @@
     gdb_assert (new_gdbarch != NULL);
     gdb_assert (new_gdbarch->initialized_p);
     current_inferior ()->gdbarch = new_gdbarch;
  -  gdb::observers::architecture_changed.notify (new_gdbarch);
  +  observer_notify_architecture_changed (new_gdbarch);
     registers_changed ();
   }


Clearly commit 76727919ce ("Convert observers to C++") edited
gdbarch.c directly instead of gdbarch.sh.  This fixes it.

gdb/ChangeLog:
2018-04-09  Pedro Alves  <palves@redhat.com>

	* gdbarch.sh: Include "observable.h" instead of "observer.h".
	(set_target_gdbarch): Call
	gdb::observers::architecture_changed.notify instead of
	observer_notify_architecture_changed.
2018-04-09 15:34:48 +01:00
Tom Tromey 281d762b1a Remove cleanups from check_fast_tracepoint_sals
This changes the gdbarch fast_tracepoint_valid_at method to use a
std::string as its out parameter, and then updates all the uses.  This
allows removing a cleanup from breakpoint.c.

Regression tested by the buildbot.

ChangeLog
2018-02-24  Tom Tromey  <tom@tromey.com>

	* i386-tdep.c (i386_fast_tracepoint_valid_at): "msg" now a
	std::string.
	* gdbarch.sh (fast_tracepoint_valid_at): Change "msg" to a
	std::string*.
	* gdbarch.c: Rebuild.
	* gdbarch.h: Rebuild.
	* breakpoint.c (check_fast_tracepoint_sals): Use std::string.
	* arch-utils.h (default_fast_tracepoint_valid_at): Update.
	* arch-utils.c (default_fast_tracepoint_valid_at): "msg" now a
	std::string*.
2018-02-24 10:01:11 -07:00
Yao Qi c113ed0ca2 Pass readable_regcache to gdbarch method read_pc
We can pass readable_regcache to gdbarch method read_pc where it is
allowed to do read from regcache.

gdb:

2018-02-21  Yao Qi  <yao.qi@linaro.org>

	* avr-tdep.c (avr_read_pc): Change parameter type to
	readable_regcache.
	* gdbarch.sh (read_pc): Likewise.
	* gdbarch.c: Re-generated.
	* gdbarch.h: Re-generated.
	* hppa-tdep.c (hppa_read_pc): Change parameter type to
	readable_regcache.
	* ia64-tdep.c (ia64_read_pc): Likewise.
	* mips-tdep.c (mips_read_pc): Likewise.
	* spu-tdep.c (spu_read_pc): Likewise.
2018-02-21 11:20:03 +00:00
Yao Qi 849d0ba802 class readable_regcache and pass readable_regcache to gdbarch pseudo_register_read and pseudo_register_read_value
pseudo registers are either from raw registers or memory, so
gdbarch methods pseudo_register_read and pseudo_register_read_value
should have regcache object which only have read methods.  In other
words, we should disallow writing to regcache in these two gdbarch
methods.  In order to apply this restriction, this patch adds a new
class readable_regcache, derived from reg_buffer, and it only has
raw_read and cooked_read methods.  regcache is derived from
readable_regcache.  This patch also passes readable_regcache instead of
regcache to gdbarch methods pseudo_register_read and
pseudo_register_read_value.

This patch moves raw_read* and cooked_read* methods to readable_regcache,
which is straightforward.  One thing not straightforward is that I split
regcache::xfer_part to readable_regcache::read_part and regcache::write_part,
because readable_regcache can only have methods to read.

readable_regcache is an abstract base class, and it has a pure virtual
function raw_update, because I don't want readable_regcache know where
these raw registers are from.  They can be from either the target
(readwrite regcache) or the regcache itself (readonly regcache).

gdb:

2018-02-21  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c (aarch64_pseudo_register_read_value): Change
	parameter type to 'readable_regcache *'.
	* amd64-tdep.c (amd64_pseudo_register_read_value): Likewise.
	* arm-tdep.c (arm_neon_quad_read): Likewise.
	(arm_pseudo_read): Likewise.
	* avr-tdep.c (avr_pseudo_register_read): Likewise.
	* bfin-tdep.c (bfin_pseudo_register_read): Likewise.
	* frv-tdep.c (frv_pseudo_register_read): Likewise.
	* gdbarch.c: Re-generated.
	* gdbarch.h: Re-generated.
	* gdbarch.sh (pseudo_register_read): Change parameter type to
	'readable_regcache *'.
	(pseudo_register_read_value): Likewise.
	* h8300-tdep.c (pseudo_from_raw_register): Likewise.
	(h8300_pseudo_register_read): Likewise.
	* hppa-tdep.c (hppa_pseudo_register_read): Likewise.
	* i386-tdep.c (i386_mmx_regnum_to_fp_regnum): Likewise.
	(i386_pseudo_register_read_into_value): Likewise.
	(i386_pseudo_register_read_value): Likewise.
	* i386-tdep.h (i386_pseudo_register_read_into_value): Update
	declaration.
	* ia64-tdep.c (ia64_pseudo_register_read): Likewise.
	* m32c-tdep.c (m32c_raw_read): Likewise.
	(m32c_read_flg): Likewise.
	(m32c_banked_register): Likewise.
	(m32c_banked_read): Likewise.
	(m32c_sb_read): Likewise.
	(m32c_part_read): Likewise.
	(m32c_cat_read): Likewise.
	(m32c_r3r2r1r0_read): Likewise.
	(m32c_pseudo_register_read): Likewise.
	* m68hc11-tdep.c (m68hc11_pseudo_register_read): Likewise.
	* mep-tdep.c (mep_pseudo_cr32_read): Likewise.
	(mep_pseudo_cr64_read): Likewise.
	(mep_pseudo_register_read): Likewise.
	* mips-tdep.c (mips_pseudo_register_read): Likewise.
	* msp430-tdep.c (msp430_pseudo_register_read): Likewise.
	* nds32-tdep.c (nds32_pseudo_register_read): Likewise.
	* regcache.c (regcache::raw_read): Move it to readable_regcache.
	(regcache::cooked_read): Likewise.
	(regcache::cooked_read_value): Likewise.
	(regcache_cooked_read_signed):
	(regcache::cooked_read): Likewise.
	* regcache.h (readable_regcache): New class.
	(regcache): Inherit readable_regcache.  Move some methods to
	readable_regcache.
	* rl78-tdep.c (rl78_pseudo_register_read): Change
	parameter type to 'readable_regcache *'.
	* rs6000-tdep.c (do_regcache_raw_read): Remove.
	(e500_pseudo_register_read): Change parameter type to
	'readable_regcache *'.
	(dfp_pseudo_register_read): Likewise.
	(vsx_pseudo_register_read): Likewise.
	(efpr_pseudo_register_read): Likewise.
	* s390-tdep.c (s390_pseudo_register_read): Likewise.
	* sh-tdep.c (sh_pseudo_register_read): Likewise.
	* sh64-tdep.c (pseudo_register_read_portions): Likewise.
	(sh64_pseudo_register_read): Likewise.
	* sparc-tdep.c (sparc32_pseudo_register_read): Likewise.
	* sparc64-tdep.c (sparc64_pseudo_register_read): Likewise.
	* spu-tdep.c (spu_pseudo_register_read_spu): Likewise.
	(spu_pseudo_register_read): Likewise.
	* xtensa-tdep.c	(xtensa_register_read_masked): Likewise.
	(xtensa_pseudo_register_read): Likewise.
2018-02-21 11:20:03 +00:00
Joel Brobecker e2882c8578 Update copyright year range in all GDB files
gdb/ChangeLog:

        Update copyright year range in all GDB files
2018-01-02 07:38:06 +04:00
Yao Qi a738ea1d41 Clear non-significant bits of address on memory access
ARMv8 supports tagged address, that is, the top one byte in address
is ignored.  It is always enabled on aarch64-linux.  See
https://www.kernel.org/doc/Documentation/arm64/tagged-pointers.txt

The tag in the tagged address is modeled as non-significant bits in
address, so this patch adds a new gdbarch method significant_addr_bit and
clear the non-significant bits (the top byte in ARMv8) of the virtual
address at the point before passing address to target cache layer.  IOW,
the address used in the target cache layer is already cleared.

Before this patch,
(gdb) x/x 0x0000000000411030
0x411030 <global>:	0x00000000
(gdb) x/x 0xf000000000411030
0xf000000000411030:	Cannot access memory at address 0xf000000000411030

After this patch,

(gdb) x/x 0x0000000000411030
0x411030 <global>:	0x00000000
(gdb) x/x 0xf000000000411030
0xf000000000411030:	0x00000000

Note that I used address_significant in paddress, but it causes a
regression gdb.base/long_long.exp, because gdb clears the non-significant
bits in address, but test still expects them.

p/a val.oct^M
$24 = 0x2ee53977053977^M
(gdb) FAIL: gdb.base/long_long.exp: p/a val.oct

so I defer the change there.

gdb:

2017-12-08  Yao Qi  <yao.qi@linaro.org>

	* aarch64-tdep.c (aarch64_gdbarch_init): Install gdbarch
	significant_addr_bit.
	* gdbarch.sh (significant_addr_bit): New.
	* gdbarch.c, gdbarch.h: Re-generated.
	* target.c (memory_xfer_partial): Call address_significant.
	* utils.c (address_significant): New function.
	* utils.h (address_significant): Declare.

2017-12-08  Yao Qi  <yao.qi@linaro.org>

gdb/testsuite:

	* gdb.arch/aarch64-tagged-pointer.c: New file.
	* gdb.arch/aarch64-tagged-pointer.exp: New file.
2017-12-08 17:27:03 +00:00
Simon Marchi c2508e905f Remove simple_displaced_step_copy_insn
Nothing uses this function.  Remove it, and adjust comments referring to
it.

gdb/ChangeLog:

	* arch-utils.h (simple_displaced_step_copy_insn): Remove.
	* arch-utils.c (simple_displaced_step_copy_insn): Remove.
	* gdbarch.sh (displaced_step_copy_insn): Adjust comment.
	* gdbarch.h: Regenerate.
	* i386-linux-tdep.c (i386_linux_displaced_step_copy_insn):
	Adjust comment.
	* i386-tdep.c (i386_displaced_step_copy_insn): Adjust comment.
	(i386_displaced_step_fixup): Adjust comment.
	* rs6000-tdep.c (ppc_displaced_step_copy_insn): Adjust comment.
2017-10-12 21:42:23 -04:00
Maciej W. Rozycki fe22022617 GDB: Remove Linux core PRPSINFO note writer override
Revert parts of commit b3ac9c7756 ("Put more info in NT_PRPSINFO Linux
notes"), <https://sourceware.org/ml/binutils/2013-02/msg00024.html>, and
remove support for a Linux core PRPSINFO note writer override, now that
all variants are handled automatically within BFD itself.

	gdb/
	* linux-tdep.c (linux_make_corefile_notes): Remove call to
	`gdbarch_elfcore_write_linux_prpsinfo'.
	* gdbarch.sh (elfcore_write_linux_prpsinfo): Remove architecture
	method.
	(elf_internal_linux_prpsinfo): Remove declaration.
	* gdbarch.h: Regenerate.
	* gdbarch.c: Regenerate.
2017-10-11 15:01:41 +01:00
Maciej W. Rozycki db8dd1601e gdbarch: Remove duplicate `struct objfile' declaration
Remove a duplicate `struct objfile' declaration mistakenly added with
commit 3e29f34a4e ("MIPS: Keep the ISA bit in compressed code
addresses").

	gdb/
	* gdbarch.sh (objfile): Remove duplicate declaration.
	* gdbarch.h: Regenerate.
2017-10-03 23:46:28 +01:00
John Baldwin 481695ed5f Remove unnecessary function prototypes.
These prototypes were required when compiling GDB as C but are not
required for C++.

gdb/ChangeLog:

	* aarch64-linux-nat.c: Remove _initialize_aarch64_linux_nat
	prototype.
	* aarch64-linux-tdep.c: Remove _initialize_aarch64_linux_tdep
	prototype.
	* aarch64-newlib-tdep.c: Remove _initialize_aarch64_newlib_tdep
	prototype.
	* aarch64-tdep.c: Remove _initialize_aarch64_tdep prototype.
	* ada-exp.y: Remove _initialize_ada_exp prototype.
	* ada-lang.c: Remove _initialize_ada_language prototype.
	* ada-tasks.c: Remove _initialize_tasks prototype.
	* addrmap.c: Remove _initialize_addrmap prototype.
	* agent.c: Remove _initialize_agent prototype.
	* aix-thread.c: Remove _initialize_aix_thread prototype.
	* alpha-bsd-nat.c: Remove _initialize_alphabsd_nat prototype.
	* alpha-linux-nat.c: Remove _initialize_alpha_linux_nat prototype.
	* alpha-linux-tdep.c: Remove _initialize_alpha_linux_tdep
	prototype.
	* alpha-nbsd-tdep.c: Remove _initialize_alphanbsd_tdep prototype.
	* alpha-obsd-tdep.c: Remove _initialize_alphaobsd_tdep prototype.
	* alpha-tdep.c: Remove _initialize_alpha_tdep prototype.
	* amd64-darwin-tdep.c: Remove _initialize_amd64_darwin_tdep
	prototype.
	* amd64-dicos-tdep.c: Remove _initialize_amd64_dicos_tdep
	prototype.
	* amd64-fbsd-nat.c: Remove _initialize_amd64fbsd_nat prototype.
	* amd64-fbsd-tdep.c: Remove _initialize_amd64fbsd_tdep prototype.
	* amd64-linux-nat.c: Remove _initialize_amd64_linux_nat prototype.
	* amd64-linux-tdep.c: Remove _initialize_amd64_linux_tdep
	prototype.
	* amd64-nbsd-nat.c: Remove _initialize_amd64nbsd_nat prototype.
	* amd64-nbsd-tdep.c: Remove _initialize_amd64nbsd_tdep prototype.
	* amd64-obsd-nat.c: Remove _initialize_amd64obsd_nat prototype.
	* amd64-obsd-tdep.c: Remove _initialize_amd64obsd_tdep prototype.
	* amd64-sol2-tdep.c: Remove _initialize_amd64_sol2_tdep prototype.
	* amd64-tdep.c: Remove _initialize_amd64_tdep prototype.
	* amd64-windows-nat.c: Remove _initialize_amd64_windows_nat
	prototype.
	* amd64-windows-tdep.c: Remove _initialize_amd64_windows_tdep
	prototype.
	* annotate.c: Remove _initialize_annotate prototype.
	* arc-newlib-tdep.c: Remove _initialize_arc_newlib_tdep prototype.
	* arc-tdep.c: Remove _initialize_arc_tdep prototype.
	* arch-utils.c: Remove _initialize_gdbarch_utils prototype.
	* arm-linux-nat.c: Remove _initialize_arm_linux_nat prototype.
	* arm-linux-tdep.c: Remove _initialize_arm_linux_tdep prototype.
	* arm-nbsd-tdep.c: Remove _initialize_arm_netbsd_tdep prototype.
	* arm-obsd-tdep.c: Remove _initialize_armobsd_tdep prototype.
	* arm-symbian-tdep.c: Remove _initialize_arm_symbian_tdep
	prototype.
	* arm-tdep.c: Remove _initialize_arm_tdep prototype.
	* arm-wince-tdep.c: Remove _initialize_arm_wince_tdep prototype.
	* auto-load.c: Remove _initialize_auto_load prototype.
	* auxv.c: Remove _initialize_auxv prototype.
	* avr-tdep.c: Remove _initialize_avr_tdep prototype.
	* ax-gdb.c: Remove _initialize_ax_gdb prototype.
	* bfin-linux-tdep.c: Remove _initialize_bfin_linux_tdep prototype.
	* bfin-tdep.c: Remove _initialize_bfin_tdep prototype.
	* break-catch-sig.c: Remove _initialize_break_catch_sig prototype.
	* break-catch-syscall.c: Remove _initialize_break_catch_syscall
	prototype.
	* break-catch-throw.c: Remove _initialize_break_catch_throw
	prototype.
	* breakpoint.c: Remove _initialize_breakpoint prototype.
	* bsd-uthread.c: Remove _initialize_bsd_uthread prototype.
	* btrace.c: Remove _initialize_btrace prototype.
	* charset.c: Remove _initialize_charset prototype.
	* cli/cli-cmds.c: Remove _initialize_cli_cmds prototype.
	* cli/cli-dump.c: Remove _initialize_cli_dump prototype.
	* cli/cli-interp.c: Remove _initialize_cli_interp prototype.
	* cli/cli-logging.c: Remove _initialize_cli_logging prototype.
	* cli/cli-script.c: Remove _initialize_cli_script prototype.
	* coff-pe-read.c: Remove _initialize_coff_pe_read prototype.
	* coffread.c: Remove _initialize_coffread prototype.
	* compile/compile.c: Remove _initialize_compile prototype.
	* complaints.c: Remove _initialize_complaints prototype.
	* completer.c: Remove _initialize_completer prototype.
	* copying.awk: Remove _initialize_copying prototype.
	* copying.c: Regenerate.
	* core-regset.c: Remove _initialize_core_regset prototype.
	* corefile.c: Remove _initialize_core prototype.
	* corelow.c: Remove _initialize_corelow prototype.
	* cp-abi.c: Remove _initialize_cp_abi prototype.
	* cp-namespace.c: Remove _initialize_cp_namespace prototype.
	* cp-support.c: Remove _initialize_cp_support prototype.
	* cp-valprint.c: Remove _initialize_cp_valprint prototype.
	* cris-linux-tdep.c: Remove _initialize_cris_linux_tdep prototype.
	* cris-tdep.c: Remove _initialize_cris_tdep prototype.
	* ctf.c: Remove _initialize_ctf prototype.
	* d-lang.c: Remove _initialize_d_language prototype.
	* darwin-nat-info.c: Remove _initialize_darwin_info_commands
	prototype.
	* darwin-nat.c: Remove _initialize_darwin_inferior prototype.
	* dbxread.c: Remove _initialize_dbxread prototype.
	* dcache.c: Remove _initialize_dcache prototype.
	* demangle.c: Remove _initialize_demangler prototype.
	* disasm-selftests.c: Remove _initialize_disasm_selftests
	prototype.
	* disasm.c: Remove _initialize_disasm prototype.
	* dtrace-probe.c: Remove _initialize_dtrace_probe prototype.
	* dummy-frame.c: Remove _initialize_dummy_frame prototype.
	* dwarf2-frame-tailcall.c: Remove _initialize_tailcall_frame
	prototype.
	* dwarf2-frame.c: Remove _initialize_dwarf2_frame prototype.
	* dwarf2expr.c: Remove _initialize_dwarf2expr prototype.
	* dwarf2loc.c: Remove _initialize_dwarf2loc prototype.
	* dwarf2read.c: Remove _initialize_dwarf2_read prototype.
	* elfread.c: Remove _initialize_elfread prototype.
	* exec.c: Remove _initialize_exec prototype.
	* extension.c: Remove _initialize_extension prototype.
	* f-lang.c: Remove _initialize_f_language prototype.
	* f-valprint.c: Remove _initialize_f_valprint prototype.
	* fbsd-nat.c: Remove _initialize_fbsd_nat prototype.
	* fbsd-tdep.c: Remove _initialize_fbsd_tdep prototype.
	* filesystem.c: Remove _initialize_filesystem prototype.
	* findcmd.c: Remove _initialize_mem_search prototype.
	* fork-child.c: Remove _initialize_fork_child prototype.
	* frame-base.c: Remove _initialize_frame_base prototype.
	* frame-unwind.c: Remove _initialize_frame_unwind prototype.
	* frame.c: Remove _initialize_frame prototype.
	* frv-linux-tdep.c: Remove _initialize_frv_linux_tdep prototype.
	* frv-tdep.c: Remove _initialize_frv_tdep prototype.
	* ft32-tdep.c: Remove _initialize_ft32_tdep prototype.
	* gcore.c: Remove _initialize_gcore prototype.
	* gdb_bfd.c: Remove _initialize_gdb_bfd prototype.
	* gdbarch.c: Regenerate.
	* gdbarch.sh: Remove _initialize_gdbarch prototype.
	* gdbtypes.c: Remove _initialize_gdbtypes prototype.
	* gnu-nat.c: Remove _initialize_gnu_nat prototype.
	* gnu-v2-abi.c: Remove _initialize_gnu_v2_abi prototype.
	* gnu-v3-abi.c: Remove _initialize_gnu_v3_abi prototype.
	* go-lang.c: Remove _initialize_go_language prototype.
	* go32-nat.c: Remove _initialize_go32_nat prototype.
	* guile/guile.c: Remove _initialize_guile prototype.
	* h8300-tdep.c: Remove _initialize_h8300_tdep prototype.
	* hppa-linux-nat.c: Remove _initialize_hppa_linux_nat prototype.
	* hppa-linux-tdep.c: Remove _initialize_hppa_linux_tdep prototype.
	* hppa-nbsd-nat.c: Remove _initialize_hppanbsd_nat prototype.
	* hppa-nbsd-tdep.c: Remove _initialize_hppanbsd_tdep prototype.
	* hppa-obsd-nat.c: Remove _initialize_hppaobsd_nat prototype.
	* hppa-obsd-tdep.c: Remove _initialize_hppaobsd_tdep prototype.
	* hppa-tdep.c: Remove _initialize_hppa_tdep prototype.
	* i386-bsd-nat.c: Remove _initialize_i386bsd_nat prototype.
	* i386-cygwin-tdep.c: Remove _initialize_i386_cygwin_tdep
	prototype.
	* i386-darwin-tdep.c: Remove _initialize_i386_darwin_tdep
	prototype.
	* i386-dicos-tdep.c: Remove _initialize_i386_dicos_tdep prototype.
	* i386-fbsd-nat.c: Remove _initialize_i386fbsd_nat prototype.
	* i386-fbsd-tdep.c: Remove _initialize_i386fbsd_tdep prototype.
	* i386-gnu-nat.c: Remove _initialize_i386gnu_nat prototype.
	* i386-gnu-tdep.c: Remove _initialize_i386gnu_tdep prototype.
	* i386-linux-nat.c: Remove _initialize_i386_linux_nat prototype.
	* i386-linux-tdep.c: Remove _initialize_i386_linux_tdep prototype.
	* i386-nbsd-nat.c: Remove _initialize_i386nbsd_nat prototype.
	* i386-nbsd-tdep.c: Remove _initialize_i386nbsd_tdep prototype.
	* i386-nto-tdep.c: Remove _initialize_i386nto_tdep prototype.
	* i386-obsd-nat.c: Remove _initialize_i386obsd_nat prototype.
	* i386-obsd-tdep.c: Remove _initialize_i386obsd_tdep prototype.
	* i386-sol2-nat.c: Remove _initialize_amd64_sol2_nat prototype.
	* i386-sol2-tdep.c: Remove _initialize_amd64_sol2_tdep prototype.
	* i386-tdep.c: Remove _initialize_i386_tdep prototype.
	* i386-windows-nat.c: Remove _initialize_i386_windows_nat
	prototype.
	* ia64-libunwind-tdep.c: Remove _initialize_libunwind_frame
	prototype.
	* ia64-linux-nat.c: Remove _initialize_ia64_linux_nat prototype.
	* ia64-linux-tdep.c: Remove _initialize_ia64_linux_tdep prototype.
	* ia64-tdep.c: Remove _initialize_ia64_tdep prototype.
	* ia64-vms-tdep.c: Remove _initialize_ia64_vms_tdep prototype.
	* infcall.c: Remove _initialize_infcall prototype.
	* infcmd.c: Remove _initialize_infcmd prototype.
	* inferior.c: Remove _initialize_inferiors prototype.
	* inflow.c: Remove _initialize_inflow prototype.
	* infrun.c: Remove _initialize_infrun prototype.
	* interps.c: Remove _initialize_interpreter prototype.
	* iq2000-tdep.c: Remove _initialize_iq2000_tdep prototype.
	* jit.c: Remove _initialize_jit prototype.
	* language.c: Remove _initialize_language prototype.
	* linux-fork.c: Remove _initialize_linux_fork prototype.
	* linux-nat.c: Remove _initialize_linux_nat prototype.
	* linux-tdep.c: Remove _initialize_linux_tdep prototype.
	* linux-thread-db.c: Remove _initialize_thread_db prototype.
	* lm32-tdep.c: Remove _initialize_lm32_tdep prototype.
	* m2-lang.c: Remove _initialize_m2_language prototype.
	* m32c-tdep.c: Remove _initialize_m32c_tdep prototype.
	* m32r-linux-nat.c: Remove _initialize_m32r_linux_nat prototype.
	* m32r-linux-tdep.c: Remove _initialize_m32r_linux_tdep prototype.
	* m32r-tdep.c: Remove _initialize_m32r_tdep prototype.
	* m68hc11-tdep.c: Remove _initialize_m68hc11_tdep prototype.
	* m68k-bsd-nat.c: Remove _initialize_m68kbsd_nat prototype.
	* m68k-bsd-tdep.c: Remove _initialize_m68kbsd_tdep prototype.
	* m68k-linux-nat.c: Remove _initialize_m68k_linux_tdep prototype.
	* m68k-linux-tdep.c: Remove _initialize_m68k_linux_tdep prototype.
	* m68k-tdep.c: Remove _initialize_m68k_tdep prototype.
	* m88k-bsd-nat.c: Remove _initialize_m68kbsd_nat prototype.
	* m88k-tdep.c: Remove _initialize_m68kbsd_tdep prototype.
	* machoread.c: Remove _initialize_machoread prototype.
	* macrocmd.c: Remove _initialize_macrocmd prototype.
	* macroscope.c: Remove _initialize_macroscope prototype.
	* maint.c: Remove _initialize_maint_cmds prototype.
	* mdebugread.c: Remove _initialize_mdebugread prototype.
	* memattr.c: Remove _initialize_mem prototype.
	* mep-tdep.c: Remove _initialize_mep_tdep prototype.
	* mi/mi-cmd-env.c: Remove _initialize_mi_cmd_env prototype.
	* mi/mi-cmds.c: Remove _initialize_mi_cmds prototype.
	* mi/mi-interp.c: Remove _initialize_mi_interp prototype.
	* mi/mi-main.c: Remove _initialize_mi_main prototype.
	* microblaze-linux-tdep.c: Remove
	_initialize_microblaze_linux_tdep prototype.
	* microblaze-tdep.c: Remove _initialize_microblaze_tdep prototype.
	* mips-fbsd-nat.c: Remove _initialize_mips_fbsd_nat prototype.
	* mips-fbsd-tdep.c: Remove _initialize_mips_fbsd_tdep prototype.
	* mips-linux-nat.c: Remove _initialize_mips_linux_nat prototype.
	* mips-linux-tdep.c: Remove _initialize_mips_linux_tdep prototype.
	* mips-nbsd-nat.c: Remove _initialize_mipsnbsd_nat prototype.
	* mips-nbsd-tdep.c: Remove _initialize_mipsnbsd_tdep prototype.
	* mips-sde-tdep.c: Remove _initialize_mips_sde_tdep prototype.
	* mips-tdep.c: Remove _initialize_mips_tdep prototype.
	* mips64-obsd-nat.c: Remove _initialize_mips64obsd_nat prototype.
	* mips64-obsd-tdep.c: Remove _initialize_mips64obsd_tdep
	prototype.
	* mipsread.c: Remove _initialize_mipsread prototype.
	* mn10300-linux-tdep.c: Remove _initialize_mn10300_linux_tdep
	prototype.
	* mn10300-tdep.c: Remove _initialize_mn10300_tdep prototype.
	* moxie-tdep.c: Remove _initialize_moxie_tdep prototype.
	* msp430-tdep.c: Remove _initialize_msp430_tdep prototype.
	* mt-tdep.c: Remove _initialize_mt_tdep prototype.
	* nds32-tdep.c: Remove _initialize_nds32_tdep prototype.
	* nios2-linux-tdep.c: Remove _initialize_nios2_linux_tdep
	prototype.
	* nios2-tdep.c: Remove _initialize_nios2_tdep prototype.
	* nto-procfs.c: Remove _initialize_procfs prototype.
	* nto-tdep.c: Remove _initialize_nto_tdep prototype.
	* objc-lang.c: Remove _initialize_objc_language prototype.
	* objfiles.c: Remove _initialize_objfiles prototype.
	* observer.c: Remove observer_test_first_notification_function,
	observer_test_second_notification_function,
	observer_test_third_notification_function, and
	_initialize_observer prototypes.
	* opencl-lang.c: Remove _initialize_opencl_language prototypes.
	* osabi.c: Remove _initialize_gdb_osabi prototype.
	* osdata.c: Remove _initialize_osdata prototype.
	* p-valprint.c: Remove _initialize_pascal_valprint prototype.
	* parse.c: Remove _initialize_parse prototype.
	* ppc-fbsd-nat.c: Remove _initialize_ppcfbsd_nat prototype.
	* ppc-fbsd-tdep.c: Remove _initialize_ppcfbsd_tdep prototype.
	* ppc-linux-nat.c: Remove _initialize_ppc_linux_nat prototype.
	* ppc-linux-tdep.c: Remove _initialize_ppc_linux_tdep prototype.
	* ppc-nbsd-nat.c: Remove _initialize_ppcnbsd_nat prototype.
	* ppc-nbsd-tdep.c: Remove _initialize_ppcnbsd_tdep prototype.
	* ppc-obsd-nat.c: Remove _initialize_ppcobsd_nat prototype.
	* ppc-obsd-tdep.c: Remove _initialize_ppcobsd_tdep prototype.
	* printcmd.c: Remove _initialize_printcmd prototype.
	* probe.c: Remove _initialize_probe prototype.
	* proc-api.c: Remove _initialize_proc_api prototype.
	* proc-events.c: Remove _initialize_proc_events prototype.
	* proc-service.c: Remove _initialize_proc_service prototype.
	* procfs.c: Remove _initialize_procfs prototype.
	* psymtab.c: Remove _initialize_psymtab prototype.
	* python/python.c: Remove _initialize_python prototype.
	* ravenscar-thread.c: Remove _initialize_ravenscar prototype.
	* record-btrace.c: Remove _initialize_record_btrace prototype.
	* record-full.c: Remove _initialize_record_full prototype.
	* record.c: Remove _initialize_record prototype.
	* regcache.c: Remove _initialize_regcache prototype.
	* reggroups.c: Remove _initialize_reggroup prototype.
	* remote-notif.c: Remove _initialize_notif prototype.
	* remote-sim.c: Remove _initialize_remote_sim prototype.
	* remote.c: Remove _initialize_remote prototype.
	* reverse.c: Remove _initialize_reverse prototype.
	* rl78-tdep.c: Remove _initialize_rl78_tdep prototype.
	* rs6000-aix-tdep.c: Remove _initialize_rs6000_aix_tdep prototype.
	* rs6000-lynx178-tdep.c: Remove _initialize_rs6000_lynx178_tdep
	prototype.
	* rs6000-nat.c: Remove _initialize_rs6000_nat prototype.
	* rs6000-tdep.c: Remove _initialize_rs6000_tdep prototype.
	* rust-exp.y: Remove _initialize_rust_exp prototype.
	* rx-tdep.c: Remove _initialize_rx_tdep prototype.
	* s390-linux-nat.c: Remove _initialize_s390_nat prototype.
	* s390-linux-tdep.c: Remove _initialize_s390_tdep prototype.
	* score-tdep.c: Remove _initialize_score_tdep prototype.
	* selftest-arch.c: Remove _initialize_selftests_foreach_arch
	prototype.
	* ser-go32.c: Remove _initialize_ser_dos prototype.
	* ser-mingw.c: Remove _initialize_ser_windows prototype.
	* ser-pipe.c: Remove _initialize_ser_pipe prototype.
	* ser-tcp.c: Remove _initialize_ser_tcp prototype.
	* ser-unix.c: Remove _initialize_ser_hardwire prototype.
	* serial.c: Remove _initialize_serial prototype.
	* sh-linux-tdep.c: Remove _initialize_sh_linux_tdep prototype.
	* sh-nbsd-nat.c: Remove _initialize_shnbsd_nat prototype.
	* sh-nbsd-tdep.c: Remove _initialize_shnbsd_tdep prototype.
	* sh-tdep.c: Remove _initialize_sh_tdep prototype.
	* skip.c: Remove _initialize_step_skip prototype.
	* sol-thread.c: Remove _initialize_sol_thread prototype.
	* solib-aix.c: Remove _initialize_solib_aix prototype.
	* solib-darwin.c: Remove _initialize_darwin_solib prototype.
	* solib-dsbt.c: Remove _initialize_dsbt_solib prototype.
	* solib-frv.c: Remove _initialize_frv_solib prototype.
	* solib-spu.c: Remove _initialize_spu_solib prototype.
	* solib-svr4.c: Remove _initialize_svr4_solib prototype.
	* solib-target.c: Remove _initialize_solib_target prototype.
	* solib.c: Remove _initialize_solib prototype.
	* source.c: Remove _initialize_source prototype.
	* sparc-linux-nat.c: Remove _initialize_sparc_linux_nat prototype.
	* sparc-linux-tdep.c: Remove _initialize_sparc_linux_tdep
	prototype.
	* sparc-nat.c: Remove _initialize_sparc_nat prototype.
	* sparc-nbsd-nat.c: Remove _initialize_sparcnbsd_nat prototype.
	* sparc-nbsd-tdep.c: Remove _initialize_sparcnbsd_tdep prototype.
	* sparc-obsd-tdep.c: Remove _initialize_sparc32obsd_tdep
	prototype.
	* sparc-sol2-nat.c: Remove _initialize_sparc_sol2_nat prototype.
	* sparc-sol2-tdep.c: Remove _initialize_sparc_sol2_tdep prototype.
	* sparc-tdep.c: Remove _initialize_sparc_tdep prototype.
	* sparc64-fbsd-nat.c: Remove _initialize_sparc64fbsd_nat
	prototype.
	* sparc64-fbsd-tdep.c: Remove _initialize_sparc64fbsd_tdep
	prototype.
	* sparc64-linux-nat.c: Remove _initialize_sparc64_linux_nat
	prototype.
	* sparc64-linux-tdep.c: Remove _initialize_sparc64_linux_tdep
	prototype.
	* sparc64-nat.c: Remove _initialize_sparc64_nat prototype.
	* sparc64-nbsd-nat.c: Remove _initialize_sparc64nbsd_nat
	prototype.
	* sparc64-nbsd-tdep.c: Remove _initialize_sparc64nbsd_tdep
	prototype.
	* sparc64-obsd-nat.c: Remove _initialize_sparc64obsd_nat
	prototype.
	* sparc64-obsd-tdep.c: Remove _initialize_sparc64obsd_tdep
	prototype.
	* sparc64-sol2-tdep.c: Remove _initialize_sparc64_sol2_tdep
	prototype.
	* spu-linux-nat.c: Remove _initialize_spu_nat prototype.
	* spu-multiarch.c: Remove _initialize_spu_multiarch prototype.
	* spu-tdep.c: Remove _initialize_spu_tdep prototype.
	* stabsread.c: Remove _initialize_stabsread prototype.
	* stack.c: Remove _initialize_stack prototype.
	* stap-probe.c: Remove _initialize_stap_probe prototype.
	* std-regs.c: Remove _initialize_frame_reg prototype.
	* symfile-debug.c: Remove _initialize_symfile_debug prototype.
	* symfile-mem.c: Remove _initialize_symfile_mem prototype.
	* symfile.c: Remove _initialize_symfile prototype.
	* symmisc.c: Remove _initialize_symmisc prototype.
	* symtab.c: Remove _initialize_symtab prototype.
	* target-dcache.c: Remove _initialize_target_dcache prototype.
	* target-descriptions.c: Remove _initialize_target_descriptions
	prototype.
	* thread.c: Remove _initialize_thread prototype.
	* tic6x-linux-tdep.c: Remove _initialize_tic6x_linux_tdep
	prototype.
	* tic6x-tdep.c: Remove _initialize_tic6x_tdep prototype.
	* tilegx-linux-nat.c: Remove _initialize_tile_linux_nat prototype.
	* tilegx-linux-tdep.c: Remove _initialize_tilegx_linux_tdep
	prototype.
	* tilegx-tdep.c: Remove _initialize_tilegx_tdep prototype.
	* tracefile-tfile.c: Remove _initialize_tracefile_tfile prototype.
	* tracefile.c: Remove _initialize_tracefile prototype.
	* tracepoint.c: Remove _initialize_tracepoint prototype.
	* tui/tui-hooks.c: Remove _initialize_tui_hooks prototype.
	* tui/tui-interp.c: Remove _initialize_tui_interp prototype.
	* tui/tui-layout.c: Remove _initialize_tui_layout prototype.
	* tui/tui-regs.c: Remove _initialize_tui_regs prototype.
	* tui/tui-stack.c: Remove _initialize_tui_stack prototype.
	* tui/tui-win.c: Remove _initialize_tui_win prototype.
	* tui/tui.c: Remove _initialize_tui prototype.
	* typeprint.c: Remove _initialize_typeprint prototype.
	* user-regs.c: Remove _initialize_user_regs prototype.
	* utils.c: Remove _initialize_utils prototype.
	* v850-tdep.c: Remove _initialize_v850_tdep prototype.
	* valarith.c: Remove _initialize_valarith prototype.
	* valops.c: Remove _initialize_valops prototype.
	* valprint.c: Remove _initialize_valprint prototype.
	* value.c: Remove _initialize_values prototype.
	* varobj.c: Remove _initialize_varobj prototype.
	* vax-bsd-nat.c: Remove _initialize_vaxbsd_nat prototype.
	* vax-nbsd-tdep.c: Remove _initialize_vaxnbsd_tdep prototype.
	* vax-tdep.c: Remove _initialize_vax_tdep prototype.
	* windows-nat.c: Remove _initialize_windows_nat,
	_initialize_check_for_gdb_ini, and _initialize_loadable
	prototypes.
	* windows-tdep.c: Remove _initialize_windows_tdep prototype.
	* xcoffread.c: Remove _initialize_xcoffread prototype.
	* xml-support.c: Remove _initialize_xml_support prototype.
	* xstormy16-tdep.c: Remove _initialize_xstormy16_tdep prototype.
	* xtensa-linux-nat.c: Remove _initialize_xtensa_linux_nat
	prototype.
	* xtensa-linux-tdep.c: Remove _initialize_xtensa_linux_tdep
	prototype.
	* xtensa-tdep.c: Remove _initialize_xtensa_tdep prototype.
2017-09-09 11:02:37 -07:00