This is a stylistic patch to make it so the checker can analyze
print_command_1. This amounts to installing an outer cleanup and
unconditionally invoking it.
* printcmd.c (print_command_1): Unconditionally call do_cleanups.
Fix some bugs pointed out by the cleanup checker. This one just fixes
some simple CLI reports, where CLI commands know that their caller
will do cleanups. This an older style with few instances, so it is
simpler to fix them up than to teach the checker about it.
* cli/cli-cmds.c (cd_command, alias_command): Call do_cleanups.
* cli/cli-dump.c (restore_binary_file): Call do_cleanups.
* interps.c (interpreter_exec_cmd): Call do_cleanups.
* source.c (show_substitute_path_command): Call do_cleanups.
(unset_substitute_path_command, set_substitute_path_command):
Likewise.
* symfile.c (load_command): Call do_cleanups.
This patch adds the cleanup checker. This is a Python plugin for GCC
that checks some rules for cleanup handling. In particular it tries
to notice when cleanups are left dangling at the end of a function.
It does this by applying a few simple rules.
First, it understands that a function whose return type is "struct
cleanup *" is a "cleanup constructor". Such functions are expected to
return the first cleanup that they make.
Then, it has the notion of a "master cleanup". The checker keeps a
stack of all cleanups made in a basic block. The first element is
pushed on the stack is the master cleanup -- the one that must later
be passed to either do_cleanups or discard_cleanups.
It is not perfect -- some constructs confuse it. So, part of this
series rewrites some code in gdb so that it is analyzable. I'll note
these spots and you can decide whether or not this is a good idea.
This patch also changes gcc-with-excheck to give it options. Now you
must use either -Xc (for the cleanup checker) or -Xx (for the
exception checker).
* contrib/cleanup_check.py: New file.
* contrib/gcc-with-excheck: Add option parsing.
* mi/mi-cmds.c (mi_cmds): Define MI command
'-exec-arguments' by macro DEF_MI_CMD_CLI_1 instead of
DEF_MI_CMD_CLI.
gdb/testsuite/
* gdb.mi/mi-cmd-param-changed.exp (test_command_param_changed):
Add a test that no MI notification is emitted when executing
-exec-arguments.
* write.c (resolve_reloc_expr_symbols): On REL targets don't
convert relocs who have no relocatable field either. Rephrase
the conditional so that the PC-relative check is only applied
for REL targets.
gas/testsuite/
* gas/mips/jalr3.d: New test.
* gas/mips/jalr3-n32.d: New test.
* gas/mips/jalr3-n64.d: New test.
* gas/mips/jalr3.s: New test source.
* gas/mips/mips.exp: Run the new tests.
ld/testsuite/
* ld-mips-elf/jalr3.dd: New test.
* ld-mips-elf/jalr3.ld: New test linker script.
* ld-mips-elf/mips-elf.exp: Run the new test.
alternate debug info source.
(dwarf_debug_sections): Add entries for alternate .debug_str and
.debug_info sections.
(dwarf_debug_section_enum): Likewise.
(read_alt_indirect_string): New function. Handles a
DW_FORM_GNU_strp_alt attribute.
(read_alt_indirect_ref): New function. Handles a
DW_FORM_GNU_ref_alt attribute.
(read_attribute_value): Process DW_FORM_GNU_ref_alt and
DW_FORM_GNU_strp_alt.
(find_abstract_instance_name): Handle DW_FORM_GNU_ref_alt
attributes.
(_bfd_dwarf2_cleanup_debug_info): Free alternate debug info
sources.
* opncls.c (GNU_DEBUGALTLINK): Define.
(bfd_get_alt_debug_link_info): New function.
(separate_alt_debug_file_exists): New function.
(find_separate_debug_file): Add parameters for fetch and check
functions.
(bfd_follow_gnu_debugaltlink): New function.
* bfd-in2.h: Regenerate.
I noticed that gdb.multi/multi-arch.exp wasn't passing with
extended-remote GDBserver with my pending multi-process+multi-arch
series anymore on current mainline, while it used to pass before:
(gdb) run
Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout
Process /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.multi/ma-hangout created; pid = 32067
Warning:
Cannot insert breakpoint 2.
Error accessing memory address 0x4005c2: Unknown error -1.
Cannot insert breakpoint -1.
Temporarily disabling shared library breakpoints:
breakpoint #-1
(gdb) FAIL: gdb.multi/multi-arch.exp: starting inferior 2
Investigating manually, I found an easy way to reproduce. You just
need breakpoints on distinct inferiors, and a way to have GDB install
them in one go:
(gdb) set breakpoint always-inserted on
(gdb) info breakpoints
Num Type Disp Enb Address What
2 breakpoint del n <MULTIPLE>
2.1 y 0x00000000004005c2 in main at ../../../src/gdb/testsuite/gdb.multi/hello.c:40 inf 1
2.2 y 0x08048475 in main at ../../../src/gdb/testsuite/gdb.multi/hangout.c:22 inf 2
(gdb) enable 2
Warning:
Cannot insert breakpoint 2.
Error accessing memory address 0x4005c2: Unknown error -1.
And turning on remote debugging, we see:
(gdb) set debug remote 1
(gdb) disable 2
(gdb) enable 2
Sending packet: $Z0,4005c2,1#71...Packet received: E01
Sending packet: $Z0,8048475,1#87...Packet received: OK
Warning:
Cannot insert breakpoint 2.
Error accessing memory address 0x4005c2: Unknown error -1.
Notice that each of those Z0 breakpoints should be set in different
processes. However, no Hg packet to select a process has been sent in
between, so GDBserver tries to plant both on the same process that
happens to be current. The first Z0 then not so surprisingly fails.
IOW, the blame is on GDB, for telling GDBserver to plant both
breakpoints in the same process.
remote.c has a lazy scheme where it keeps a local cache of the
remote's selected general thread, and delays updating it on the remote
side until necessary (memory/register reads/writes, etc.). This is
done to reduce RSP traffic. The bug is that the Zx breakpoint
insert/remove methods weren't committing the selected thread/process
back to the remote side:
Breakpoint 3, remote_insert_breakpoint (gdbarch=0x1383ae0, bp_tgt=0x140c2b0) at ../../src/gdb/remote.c:8148
8148 if (remote_protocol_packets[PACKET_Z0].support != PACKET_DISABLE)
(top-gdb) p inferior_ptid
$3 = {pid = 3670, lwp = 0, tid = 3670}
(top-gdb) p general_thread
$4 = {pid = 3671, lwp = 0, tid = 3671}
IOW, a call to set_general_process is missing.
I did some auditing over remote.c, and added calls to all places I
found missing it.
This only used to work by chance before. breakpoint.c switches to a
thread of the target process before installing a breakpoint location.
That calls switch_to_thread. Before:
2012-07-27 Yao Qi <yao@codesourcery.com>
* thread.c (switch_to_thread): Don't call registers_changed.
that caused the register caches to all be flushed and refetched before
installing the breakpoint location. Given fetching registers commits
the remote general thread (with Hg), masking out the latent bug.
Tested on x86_64 Fedora 17 with GDBserver.
gdb/
2013-05-29 Pedro Alves <palves@redhat.com>
* remote.c (remote_insert_breakpoint, remote_remove_breakpoint)
(remote_insert_watchpoint, remote_remove_watchpoint)
(remote_insert_hw_breakpoint, remote_remove_hw_breakpoint)
(remote_verify_memory, compare_sections_command)
(remote_search_memory): Set the general process/thread on the
remote side.
The aarch64-without-fpu description is unused.
Linux requires an FPU, so the AArch64 native port always returns the
with-fpu variant:
static const struct target_desc *
aarch64_linux_read_description (struct target_ops *ops)
{
initialize_tdesc_aarch64 ();
return tdesc_aarch64;
}
When the target doesn't report a target description at all, we
fallback to a register set with an FPU:
aarch64_gdbarch_init ()
...
if (!tdesc_has_registers (tdesc))
tdesc = tdesc_aarch64;
This just removes the dead description.
Tested by building on x86_64 Fedora 17 with --enable=targets=all.
gdb/
2013-05-29 Pedro Alves <palves@redhat.com>
* aarch64-tdep.c: Don't include "features/aarch64-without-fpu.c".
(_initialize_aarch64_tdep): Don't call
initialize_tdesc_aarch64_without_fpu.
* features/Makefile (WHICH): Remove reference to
aarch64-without-fpu.
* features/aarch64-without-fpu.c: Delete file.
* regformats/aarch64-without-fpu.dat: Delete file.
* config/tc-mips.c (macro) <ld>: Don't use $zero for address
calculation.
gas/testsuite/
* gas/mips/ld-zero.d: New test.
* gas/mips/ld-zero-2.d: New test.
* gas/mips/ld-zero-3.d: New test.
* gas/mips/ld-zero-q.d: New test.
* gas/mips/ld-zero-u.d: New test.
* gas/mips/ecoff@ld-zero-3.d: New test.
* gas/mips/micromips@ld-zero-2.d: New test.
* gas/mips/micromips@ld-zero-3.d: New test.
* gas/mips/ld-zero.s: New test source.
* gas/mips/ld-zero-2.s: New test source.
* gas/mips/ld-zero-3.s: New test source.
* gas/mips/ld-zero-q.s: New test source.
* gas/mips/ld-zero-u.s: New test source.
* gas/mips/mips.exp: Run the new tests.
The GDBserver Aarch64 port includes the aarch64-without-fpu
description in the build, but doesn't actually use it anywhere. As
Linux always requires an FPU, just remove the dead code.
gdb/gdbserver/
2013-05-28 Pedro Alves <palves@redhat.com>
* Makefile.in (clean): Remove reference to aarch64-without-fpu.c.
(aarch64-without-fpu.c): Delete rule.
* configure.srv (aarch64*-*-linux*): Remove references to
aarch64-without-fpu.o and aarch64-without-fpu.xml.
* linux-aarch64-low.c (init_registers_aarch64_without_fpu): Remove
declaration.
2013-05-28 Marcus Shawcroft <marcus.shawcroft@arm.com>
* config/tc-aarch64.c (md_apply_fix): Move value range checking
inside fx_done condition.
2013-05-28 Marcus Shawcroft <marcus.shawcroft@arm.com>
* gas/aarch64/adr_1.d: New file.
* gas/aarch64/adr_1.s: New file.
* gas/aarch64/b_1.d: New file.
* gas/aarch64/b_1.s: New file.
* gas/aarch64/beq_1.d: New file.
* gas/aarch64/beq_1.s: New file.
* gas/aarch64/ldr_1.d: New file.
* gas/aarch64/ldr_1.s: New file.
* gas/aarch64/tbz_1.d: New file.
* gas/aarch64/tbz_1.s: New file.
The current hard coded limit of open files in bfd/cache.c is 10. This
is pretty low these days. Binaries are often linked against much more
than 10 files (and sometimes against more than 100 shared libraries).
When debugging with GDB some files are opened and closed multiple
times because of this low limit. If possible make the BFD cache file
limit depend on the actual open file limit of the process so more BFD
files can be open at the same time.
* cache.c (BFD_CACHE_MAX_OPEN): Remove define.
(max_open_files): New static int initialized to zero.
(bfd_cache_max_open): New static function to set and return
max_open_files.
(bfd_cache_init): Use bfd_cache_max_open.
(bfd_open_file): Likewise.
* configure.in (AC_CHECK_HEADERS): Add sys/resource.h.
(AC_CHECK_FUNCS): Add getrlimit.
* configure: Regenerated.
* config.in: Likewise.
* sysdep.h: Check and include sys/resource.h for getrlimit.
* s390-opc.txt (flogr): Require a register pair destination.
gas/testsuite/
* gas/s390/zarch-z9-109-err.s, gas/s390/zarch-z9-109-err.l: New test.
* gas/s390/s390.exp: Run it.
PR testsuite/12649
* gdb.mi/mi-dprintf.exp (mi_continue_dprintf) (mi 2nd dprintf): Replace
$mi_gdb_prompt expectation by mi_expect_stop.
(mi 1st dprintf, agent, mi 2nd dprintf, agent)
(mi info dprintf second time): Replace them by mi_send_resuming_command
and mi_expect_stop.
* tracepoint.c (TFILE_PID): Remove.
(tfile_open): Don't add thread and inferior.
(tfile_close): Don't set 'inferior_ptid'. Don't call
exit_inferior_silent.
(tfile_thread_alive): Remove.
(init_tfile_ops): Don't set field 'to_thread_alive' of
tfile_ops.
gdb/testsuite/
* gdb.trace/tfile.exp: Test inferior and thread.
This bit:
+ p1 = strchr (p, ':');
+ decode_address (&resume_info[i].step_range_end, p, p1 - p);
should not expect the ':' to be there. An action without a ptid is
valid:
"If an action is specified with no thread-id, then it is applied to any
threads that don't have a specific action specified"
This is handled further below:
if (p[0] == 0)
{
resume_info[i].thread = minus_one_ptid;
default_action = resume_info[i];
/* Note: we don't increment i here, we'll overwrite this entry
the next time through. */
}
else if (p[0] == ':')
A stub that doesn't support and report to gdb thread ids at all (like
metal metal targets) only will always only see a single default action
with no ptid.
Use unpack_varlen_hex instead of decode_address. The former doesn't
need to be told where the hex number ends, and it actually returns
that info instead, which we can use for validation.
Tested on x86_64 Fedora 17.
gdb/gdbserver/
2013-05-24 Pedro Alves <palves@redhat.com>
* server.c (handle_v_cont) <vCont;r>: Use unpack_varlen_hex
instead of strchr/decode_address. Error if the range isn't split
with a ','. Don't assume there's be a ':' in the action.
* gdb.base/range-stepping.exp: Skip the rest of tests if the
test fails.
* lib/range-stepping-support.exp (exec_cmd_expect_vCont_count):
Return 0 if the test passes, otherwise return 1.
Building gdb with --host=i586-pc-msdosdjgpp ends up with:
i586-pc-msdosdjgpp-gcc -g -O2 -I../../src/gdb/config/djgpp -I. -I../../src/gdb -I../../src/gdb/common -I../../src/gdb/config -DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H -I../../src/gdb/../include/opcode -I../../src/gdb/../opcodes/.. -I../../src/gdb/../readline/.. -I../bfd -I../../src/gdb/../bfd -I../../src/gdb/../include -I../libdecnumber -I../../src/gdb/../libdecnumber -I./../intl -I../../src/gdb/gnulib/import -Ibuild-gnulib/import -Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral -Wpointer-sign -Wno-unused -Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wmissing-prototypes -Wdeclaration-after-statement -Wempty-body -Werror -c -o filestuff.o -MT filestuff.o -MMD -MP -MF .deps/filestuff.Tpo ../../src/gdb/common/filestuff.c
../../src/gdb/common/filestuff.c:38:24: fatal error: sys/socket.h: No such file or directory
There are no sockets on djgpp. This #ifdef's out the bits in the file
that use sockets, depending on whether winsock or sys/socket.h is
available.
As alternative approach, given ser-tcp.c, ser-pipe.c, etc. are split
into separate files, and which to use is selected by configure.ac:
dnl Figure out which of the many generic ser-*.c files the _host_ supports.
SER_HARDWIRE="ser-base.o ser-unix.o ser-pipe.o ser-tcp.o"
case ${host} in
*go32* ) SER_HARDWIRE=ser-go32.o ;;
*djgpp* ) SER_HARDWIRE=ser-go32.o ;;
*mingw32*) SER_HARDWIRE="ser-base.o ser-tcp.o ser-mingw.o" ;;
esac
AC_SUBST(SER_HARDWIRE)
... I considered splitting filestuff.c similarly. But I quickly gave
up on the idea, as it looked like a lot more complication over this
approach, for no real gain. Plus, there are uses of these functions
outside the ser*.c framework.
gdbserver's configure.ac is already checking for sys/socket.h.
gdb/
2013-05-23 Pedro Alves <palves@redhat.com>
* common/filestuff.c [USE_WIN32API]: Define HAVE_SOCKETS.
[HAVE_SYS_SOCKET_H]: Define HAVE_SOCKETS.
(socket_mark_cloexec, gdb_socketpair_cloexec, gdb_socket_cloexec):
Only define if HAVE_SOCKETS is defined.
* configure.ac: Check for sys/socket.h.
* config.in, configure: Regenerate.
Building gdb on GNU/Linux, for --host=i586-pc-msdosdjgpp, I get:
../../src/gdb/dwarf2read.c: In function 'create_dwp_hash_table':
../../src/gdb/dwarf2read.c:8626:7: error: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t' [-Werror=format]
../../src/gdb/dwarf2read.c:8632:7: error: format '%u' expects argument of type 'unsigned int', but argument 2 has type 'uint32_t' [-Werror=format]
../../src/gdb/dwarf2read.c: In function 'create_dwo_in_dwp':
../../src/gdb/dwarf2read.c:8754:6: error: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t' [-Werror=format]
../../src/gdb/dwarf2read.c: In function 'open_and_init_dwp_file':
../../src/gdb/dwarf2read.c:9248:6: error: format '%u' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int' [-Werror=format]
../../src/gdb/dwarf2read.c:9248:6: error: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'long unsigned int' [-Werror=format]
And:
$ grep uint32_t /usr/i586-pc-msdosdjgpp/sys-include/*
/usr/i586-pc-msdosdjgpp/sys-include/stdint.h:typedef unsigned long uint32_t;
As decided on the discussion at
<http://sourceware.org/ml/gdb-patches/2013-05/msg00788.html>, use
pulongest rather than PRIu32.
Tested on F17. Also confirmed GDB still builds OK with
--host=i686-w64-mingw32.
gdb/
2013-05-23 Pedro Alves <palves@redhat.com>
* dwarf2read.c (create_dwp_hash_table, create_dwo_in_dwp)
(open_and_init_dwp_file): Use %s/pulongest instead of %u for
printing uint32_t variables.
This adds tests to verify range stepping is used as expected, by
inspecting the RSP traffic, looking for vCont;s and vCont;r packets.
gdb/testsuite/
2013-05-23 Yao Qi <yao@codesourcery.com>
Pedro Alves <palves@redhat.com>
* gdb.base/range-stepping.c: New file.
* gdb.base/range-stepping.exp: New file.
* gdb.trace/range-stepping.c: New file.
* gdb.trace/range-stepping.exp: New file.
* lib/range-stepping-support.exp: New file.
This patch adds support for range stepping to GDBserver, teaching it
about vCont;r.
It'd be easy to enable this for all hardware single-step targets
without needing the linux_target_ops hook, however, at least PPC needs
special care, due to the fact that PPC atomic sequences can't be
hardware single-stepped through, a thing which GDBserver doesn't know
about. So this leaves the support limited to x86/x86_64.
gdb/
2013-05-23 Pedro Alves <palves@redhat.com>
* NEWS: Mention GDBserver range stepping support.
gdb/gdbserver/
2013-05-23 Yao Qi <yao@codesourcery.com>
Pedro Alves <palves@redhat.com>
* linux-low.c (lwp_in_step_range): New function.
(linux_wait_1): If the thread was range stepping and stopped
outside the stepping range, report the stop to GDB. Otherwise,
continue stepping. Add range stepping debug output.
(linux_set_resume_request): Copy the step range from the resume
request to the lwp.
(linux_supports_range_stepping): New.
(linux_target_ops) <supports_range_stepping>: Set to
linux_supports_range_stepping.
* linux-low.h (struct linux_target_ops)
<supports_range_stepping>: New field.
(struct lwp_info) <step_range_start, step_range_end>: New fields.
* linux-x86-low.c (x86_supports_range_stepping): New.
(the_low_target) <supports_range_stepping>: Set to
x86_supports_range_stepping.
* server.c (handle_v_cont): Handle 'r' action.
(handle_v_requests): Append ";r" if the target supports range
stepping.
* target.h (struct thread_resume) <step_range_start,
step_range_end>: New fields.
(struct target_ops) <supports_range_stepping>:
New field.
(target_supports_range_stepping): New macro.