rawmemchr is a dependency of strchrnul, so it should be explicitly
listed.
gdb/ChangeLog:
* gnulib/import/Makefile.am: Regenerate.
* gnulib/import/Makefile.in: Regenerate.
* gnulib/import/m4/gnulib-cache.m4: Regenerate.
* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add rawmemchr.
For a forthcoming patch, I need a "skip_to_colon" function. I noticed
there are two skip_to_semicolon (one in gdb and one in gdbserver). I
thought we could put it in common/, and generalize it for any character.
It turns out that the strchrnul function does exactly that. I imported
the corresponding module from gnulib, for those systems that do not have
it.
There are probably more places where this function can be used instead
of doing the work by hand (I am looking at
remote-utils.c::look_up_one_symbol).
gdb/ChangeLog:
* remote.c (skip_to_semicolon): Remove.
(remote_parse_stop_reply): Use strchrnul instead of
skip_to_semicolon.
* gnulib/update-gnulib.sh (IMPORTED_GNULIB_MODULES): Add
strchrnul.
* gnulib/aclocal.m4: Regenerate.
* gnulib/config.in: Regenerate.
* gnulib/configure: Regenerate.
* gnulib/import/Makefile.am: Regenerate.
* gnulib/import/Makefile.in: Regenerate.
* gnulib/import/m4/gnulib-cache.m4: Regenerate.
* gnulib/import/m4/gnulib-comp.m4: Regenerate.
* gnulib/import/m4/rawmemchr.m4: New file.
* gnulib/import/m4/strchrnul.m4: New file.
* gnulib/import/rawmemchr.c: New file.
* gnulib/import/rawmemchr.valgrind: New file.
* gnulib/import/strchrnul.c: New file.
* gnulib/import/strchrnul.valgrind: New file.
gdb/gdbserver/ChangeLog:
* server.c (skip_to_semicolon): Remove.
(process_point_options): Use strchrnul instead of
skip_to_semicolon.
In vla.f90, this single line of source is compiled to many instructions,
vla2(:, :, :) = 1311 ! vla2-allocated
it is quite slow (about several minutes in my testing) to step over this
source line without range stepping. This patch is to increase the timeout
value by 15 times, which is a magic number to make sure timeout disappears
in my testing with a slow arm-linux board.
gdb/testsuite:
2016-01-28 Yao Qi <yao.qi@linaro.org>
* gdb.fortran/vla-value.exp: Wrap test with with_timeout_factor.
I see GDB crashes in dprintf.exp on aarch64-linux testing,
(gdb) PASS: gdb.base/dprintf.exp: agent: break 29
set dprintf-style agent^M
(gdb) PASS: gdb.base/dprintf.exp: agent: set dprintf style to agent
continue^M
Continuing.
ASAN:SIGSEGV
=================================================================
==22475==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000008 (pc 0x000000494820 sp 0x7fff389b83a0 bp 0x62d000082417 T0)
#0 0x49481f in remote_add_target_side_commands /home/yao/SourceCode/gnu/gdb/git/gdb/remote.c:9190^M
#1 0x49e576 in remote_add_target_side_commands /home/yao/SourceCode/gnu/gdb/git/gdb/remote.c:9174^M
#2 0x49e576 in remote_insert_breakpoint /home/yao/SourceCode/gnu/gdb/git/gdb/remote.c:9240^M
#3 0x5278b7 in insert_bp_location /home/yao/SourceCode/gnu/gdb/git/gdb/breakpoint.c:2734^M
#4 0x52ac09 in insert_breakpoint_locations /home/yao/SourceCode/gnu/gdb/git/gdb/breakpoint.c:3159^M
#5 0x52ac09 in update_global_location_list /home/yao/SourceCode/gnu/gdb/git/gdb/breakpoint.c:12686
the root cause of this problem in this case is about linespec and
symtab which produces additional incorrect location and a NULL is added to
bp_tgt->tcommands. I posted a patch
https://sourceware.org/ml/gdb-patches/2015-12/msg00321.html to fix it
in linespec (the fix causes regression), but GDB still shouldn't add
NULL into bp_tgt->tcommands. The logic of build_target_command_list
looks odd to me. If we get something wrong in parse_cmd_to_aexpr (it
returns NULL), we shouldn't continue, instead we should set flag
null_command_or_parse_error. This is what this patch does. In the
meantime, we find build_target_condition_list has the same problem, so
fix it too.
gdb:
2016-01-28 Yao Qi <yao.qi@linaro.org>
* breakpoint.c (build_target_command_list): Don't call continue
if aexpr is NULL.
(build_target_condition_list): Likewise.
Nowadays, get_next_pcs in linux_target_ops has two parameters PC
and REGCACHE. Parameter PC looks redundant because it can be go
from REGCACHE. The patch is to remove PC from the arguments for
various functions.
gdb:
2016-01-26 Yao Qi <yao.qi@linaro.org>
* arch/arm-get-next-pcs.c (thumb_deal_with_atomic_sequence_raw):
Remove argument pc. Get pc by regcache_read_pc. Callers updated.
(arm_deal_with_atomic_sequence_raw): Likewise.
(thumb_get_next_pcs_raw): Likewise.
(arm_get_next_pcs_raw): Likewise.
(arm_get_next_pcs): Remove argument pc. Callers updated.
* arch/arm-get-next-pcs.h (arm_get_next_pcs): Update declaration.
gdb/gdbserver:
2016-01-26 Yao Qi <yao.qi@linaro.org>
* linux-arm-low.c (arm_gdbserver_get_next_pcs): Remove argument pc.
* linux-low.c (install_software_single_step_breakpoints): Don't
call regcache_read_pc.
* linux-low.h (struct linux_target_ops) <get_next_pcs>: Remove
argument pc.
In install_software_single_step_breakpoints, we've got the regcache
of current_thread, so we don't have to bother get_pc to get pc,
instead we can get pc from regcache directly. Note that the callers
of install_software_single_step_breakpoints have already switched
current_thread to LWP.
Since the pc is got from regcache_read_pc, in the next patch, we can
get pc inside the implementation of *the_low_target.get_next_pcs and
stop passing pc to *the_low_target.get_next_pcs.
gdb/gdbserver:
2016-01-26 Yao Qi <yao.qi@linaro.org>
* linux-low.c (install_software_single_step_breakpoints): Call
regcache_read_pc instead of get_pc.
Nowadays, GDBserver disables async io (by ignoring SIGIO) when process
a serial event, and enables async io (by installing signal handler) when
resume the inferior and wait. GDBserver may miss SIGIO (by interrupt)
and doesn't process SIGIO in time, which is shown by
gdb.base/interrupt-noterm.exp. In the test, GDB sends "continue &" and
then "interrupt". if '\003' arrives at a period between GDBserver
receives vCont;c and enables async io, SIGIO is ignored because signal
handler isn't installed. GDBserver waits for the inferior and can not
notice '\003' until it returns from wait.
This patch changes the code to install SIGIO handler early, but block
and unblock SIGIO as needed. In this way, we don't remove SIGIO
handler, so SIGIO can't be ignored. However, GDBserver needs to
remove the signal handler when connection is closed.
gdb/gdbserver:
2016-01-26 Yao Qi <yao.qi@linaro.org>
* remote-utils.c (remote_close) [!USE_WIN32API]: Ignore SIGIO.
(unblock_async_io): Rename to ...
(block_unblock_async_io): ... it. New function.
(enable_async_io): Don't install SIGIO handler. Unblock it
instead.
(disable_async_io): Don't ignore SIGIO. Block it instead.
(initialize_async_io): Install SIGIO handler. Don't call
unblock_async_io.
GDBserver may read some packet together with '\003' in one go. We've
already checked '\003' first when reading packet by my patch,
Check input interrupt first when reading packet
https://sourceware.org/ml/gdb-patches/2016-01/msg00057.html
but if we don't check '\003' *after* each packet, the interrupt will
be processed next time GDBserver reads from the buffer, so that the
interrupt isn't processed in time. For example, GDB sends vCont;c and
interrupt (see gdb.base/interrupt-noterm.exp), we'll resume the
inferior and wait once packet vCont;c is seen. If we don't check the
interrupt character after vCont;c packet, interrupt character will stay
in the buffer unattended until GDBserver returns from the wait, which
may take a while. Note that since we've read '\003' from file
descriptor, SIGIO signal handler input_interrupt doesn't help either.
This issue can be exposed by hacking the end of getpkt like
@@ -1041,6 +1050,9 @@ getpkt (char *buf)
}
}
+ if (readchar_bufcnt > 0)
+ gdb_assert (*readchar_bufp != '\003');
+
return bp - buf;
}
and this can trigger internal error,
(gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt
Remote connection closed^M
(gdb) FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT
Remote debugging from host 10.2.206.40^M
/home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/remote-utils.c:1054: A problem internal to GDBserver has been detected.^M
getpkt: Assertion `*readchar_bufp != '\003'' failed.^M
This patch is to peek the buffer, if it is '\003', consume it and call
*the_target->request_interrupt.
gdb/gdbserver:
2016-01-26 Yao Qi <yao.qi@linaro.org>
* remote-utils.c (getpkt): If the buffer isn't empty, and the
first character is '\003', call *the_target->request_interrupt.
Use OPTION_MXXX for -mxxx option in x86 assembler.
* config/tc-i386.c (OPTION_OMIT_LOCK_PREFIX): Renamed to ...
(OPTION_MOMIT_LOCK_PREFIX): This.
(md_longopts): Updated.
(md_parse_option): Likewise.
GCC6 will warn about misleading indentation issues like:
gdb/ada-lang.c: In function ‘ada_evaluate_subexp’:
ada-lang.c:11423:9: error: statement is indented as if it were guarded by...
arg1 = unwrap_value (arg1);
^~~~
gdb/ada-lang.c:11421:7: note: ...this ‘else’ clause, but it is not
else
^~~~
In this case it would be a bug except for the fact the if clause already
returned early. So this misindented statement really only got executed
for the else case. But it could easily mislead a reader, so adding a
proper else block is the correct solution.
In case of c-typeprint.c (c_type_print_base) the if statement is indeed
misleadingly indented, but not a bug. Just indent correctly. The inflow.c
(terminal_ours_1) misindented block comes from the removal of an if clause
in commit d9d2d8b which looks correct. Just introduce an else to fixup the
indentation of the block. The linux-record.c misleadingly indented return
statements are just that. Misleading to the reader, but not actual bugs.
Just unindent them so they don't look like they fall under the wrong if
clause.
When .data and .bss sections are empty .noinit section is placed at data
region's start. This will be incorrect for devices that has different
data start address than data region start in linker script.
The patch updates .noinit section's VMA to end of .bss section. So, .noinit
section will be placed at .data section address (-Tdata=<address>) when .data
and .bss sections are empty.
ld/
* scripttempl/avr.sc (.noinit): Force .noinit VMA to end of .bss VMA.
* scripttempl/avrtiny.sc (.noinit): Likewise.
They were added by
PATCH: Multithreaded debugging for gdbserver
https://sourceware.org/ml/gdb-patches/2002-06/msg00157.html
but as a no-op, and the last usage of them was removed by
[gdbserver/RFC/RFA] Implement multiprocess extensions, add linux multiproces support.
https://sourceware.org/ml/gdb-patches/2009-03/msg00667.html
This patch is to remove them.
gdb/gdbserver:
2016-01-25 Yao Qi <yao.qi@linaro.org>
* remote-utils.c (new_thread_notify): Remove.
(dead_thread_notify): Likewise.
* remote-utils.h (new_thread_notify): Remove declaration.
(dead_thread_notify): Likewise.
If you have "set follow-fork child" set, then if you do "info threads"
right after a fork, and before the child reports any other event to
GDB core, you'll see:
(gdb) info threads
Id Target Id Frame
* 1.1 Thread 0x7ffff7fc1740 (LWP 31875) "fork-plus-threa" (running)
2.1 process 31879 "fork-plus-threa" Selected thread is running.
(gdb)
The "Selected thread is running." bit is a bogus error. That was GDB
trying to fetch the current frame of thread 2.1, because the external
runnning state is "stopped", and then throwing an error because the
thread is actually running.
This actually affects all-stop + schedule-multiple as well.
The problem here is that on a fork event, GDB doesn't update the
external parent/child running states.
New comprehensive test included. The "kill inferior 1" / "kill
inferior 2" bits also trip on PR gdb/19494 (hang killing unfollowed
fork children), which was fixed by the previous patch.
gdb/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR threads/19461
* infrun.c (handle_inferior_event_1) <fork/vfork>: Update
parent/child running states.
gdb/testsuite/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR threads/19461
* gdb.base/fork-running-state.c: New file.
* gdb.base/fork-running-state.exp: New file.
linux_nat_kill relies on get_last_target_status to determine whether
the current inferior is stopped at a unfollowed fork/vfork event.
This is bad because many things can happen ever since we caught the
fork/vfork event... This commit rewrites that code to instead walk
the thread list looking for unfollowed fork events, similarly to what
was done for remote.c.
New test included. The main idea of the test is make sure that when
the program stops for a fork catchpoint, and the user kills the
parent, gdb also kills the unfollowed fork child. Since the child
hasn't been added as an inferior at that point, we need some other
portable way to detect that the child is gone. The test uses a pipe
for that. The program forks twice, so you have grandparent, child and
grandchild. The grandchild inherits the write side of the pipe. The
grandparent hangs reading from the pipe, since nothing ever writes to
it. If, when GDB kills the child, it also kills the grandchild, then
the grandparent's pipe read returns 0/EOF and the test passes.
Otherwise, if GDB doesn't kill the grandchild, then the pipe read
never returns and the test times out, like:
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=fork: exit-kind=kill: fork: kill parent (timeout)
FAIL: gdb.base/catch-fork-kill.exp: fork-kind=vfork: exit-kind=kill: vfork: kill parent (timeout)
No regressions on x86_64 Fedora 20. New test passes with gdbserver as
well.
gdb/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* linux-nat.c (kill_one_lwp): New, factored out from ...
(kill_callback): ... this.
(kill_wait_callback): New, factored out from ...
(kill_wait_one_lwp): ... this.
(kill_unfollowed_fork_children): New function.
(linux_nat_kill): Use it.
gdb/testsuite/ChangeLog:
2016-01-25 Pedro Alves <palves@redhat.com>
PR gdb/19494
* gdb.base/catch-fork-kill.c: New file.
* gdb.base/catch-fork-kill.exp: New file.
These two tests collect 64 words from $sp onwards, hoping that's enough
to capture a few whole stack frames. Unfortunately, that's not enough
for s390, which tends to have large frame sizes - minimum 24 words on
s390, 20 on s390x (which just barely passes). Bump it to 128 words,
let's hope no machine needs more.
Tested on x86_64, s390, s390x.
gdb/testsuite/ChangeLog:
* gdb.trace/backtrace.exp: Bump stack collection fudge factor.
* gdb.trace/entry-values.exp: Bump stack collection fudge factor.
Just mask higher bits off, which returns the same set of 3-bit register
encodings of { 0, 1, 2, 3, 4, 5, 6, 7 } for the allowed 5-bit encodings
of { 16, 17, 2, 3, 4, 5, 6, 7 }. Input has already been validated with
OP16_VALID_REG.
bfd/
* elfxx-mips.c (BZ16_REG_FIELD): Simplify calculation.
The test constructs fake DWARF info for a C structure involving bitfields.
DWARF bitfields are always counted from LSB, while the order in which
bitfields are allocated in a C struct depends on the target endianness -
thus the generated DWARF marks different bitfields as unavailable when
target is big endian. Accordingly, we need different expected outputs.
Tested on s390 and s390x, no regression on x86_64.
gdb/testsuite/ChangeLog:
* gdb.trace/unavailable-dwarf-piece.exp: Fix bitfield handling on big
endian targets.
Missed one message in bd0a71fa16, since it
didn't trigger on s390x or amd64 (fast tracepoint out of range due to
shared library usage), noticed on s390.
Pushed as obvious.
gdb/testsuite/ChangeLog:
* gdb.trace/pending.exp: Fix expected message on continue.
Pedro Alves:
Looks like you forgot to amend before pushing though -- the version
checked in still had "Thread 1".
gdb/testsuite/ChangeLog
2016-01-22 Jan Kratochvil <jan.kratochvil@redhat.com>
Pedro Alves <palves@redhat.com>
Fix testsuite compatibility with Guile.
* gdb.gdb/selftest.exp (send ^C to child process): Drop expected Thread
number.
The PR threads/19422 patchset added a new regression.
Additionally below it there was already a regression if --with-guile (which is
default if Guile is found) was used.
racy case #1:
(xgdb) PASS: gdb.gdb/selftest.exp: Set xgdb_prompt
^M
Thread 1 "xgdb" received signal SIGINT, Interrupt.^M
0x00007ffff583bfdd in poll () from /lib64/libc.so.6^M
(gdb) FAIL: gdb.gdb/selftest.exp: send ^C to child process
signal SIGINT^M
Continuing with signal SIGINT.^M
^C^M
Thread 1 "xgdb" received signal SIGINT, Interrupt.^M
0x00007ffff5779da0 in sigprocmask () from /lib64/libc.so.6^M
(gdb) PASS: gdb.gdb/selftest.exp: send SIGINT signal to child process
backtrace^M
errstring=errstring@entry=0x7e0e6c "", mask=mask@entry=RETURN_MASK_ALL) at exceptions.c:240^M
errstring=errstring@entry=0x7e0e6c "", mask=mask@entry=RETURN_MASK_ALL) at exceptions.c:240^M
(gdb) PASS: gdb.gdb/selftest.exp: backtrace through signal handler
racy case #2:
(xgdb) PASS: gdb.gdb/selftest.exp: Set xgdb_prompt
^M
Thread 1 "xgdb" received signal SIGINT, Interrupt.^M
0x00007ffff583bfdd in poll () from /lib64/libc.so.6^M
(gdb) FAIL: gdb.gdb/selftest.exp: send ^C to child process
signal SIGINT^M
Continuing with signal SIGINT.^M
^C^M
Thread 2 "xgdb" received signal SIGINT, Interrupt.^M
[Switching to Thread 0x7ffff3b7f700 (LWP 13227)]^M
0x00007ffff6b88b10 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0^M
(gdb) PASS: gdb.gdb/selftest.exp: send SIGINT signal to child process
backtrace^M
(gdb) FAIL: gdb.gdb/selftest.exp: backtrace through signal handler
Pedro Alves:
Not all targets support thread names, and even those that do, not all
use the program name as default thread name -- I think that's only true
for GNU/Linux, actually. So I think it's best to not expect that, like:
-re "(Thread .*|Program) received signal SIGINT.*$gdb_prompt $" {
gdb/testsuite/ChangeLog
2016-01-22 Jan Kratochvil <jan.kratochvil@redhat.com>
Fix testsuite compatibility with Guile.
* gdb.gdb/selftest.exp (send ^C to child process): Accept also Thread.
(thread 1): New test for backtrace through signal handler.
The prior format led to confusing messages when threads were created
or added such as "[New process 14757, LWP 100537]". The new format
reports this as "[New LWP 100434 of process 15652]".
gdb/ChangeLog:
* fbsd-nat.c (fbsd_pid_to_str): Adjust string format.
Noticed and tested on 31-bit s390. This bug caused completely broken
fast tracepoints.
gdb/gdbserver/ChangeLog:
* tracepoint.c (write_inferior_data_ptr): Cast to uintptr_t, so that
it works properly on big-endian machines where sizeof (CORE_ADDR)
!= sizeof (void *).
This patch unbuffer the output of the program so that the test harness
can count the number of "done" from output correctly.
gdb/testsuite:
2016-01-22 Yao Qi <yao.qi@linaro.org>
PR testsuite/19491
* gdb.base/multi-forks.c: Include
../lib/unbuffer_output.c
(main): Call gdb_unbuffer_output.
I see the following test fail on native arm-linux gdb testing...
(gdb) PASS: gdb.base/killed-outside.exp: registers: get pid of inferior
Executing on target: kill -9 2346 (timeout = 300)
spawn kill -9 2346^M
flushregs^M
Register cache flushed.^M
warning: Unable to fetch general registers.^M
PC not available^M
(gdb) PASS: gdb.base/killed-outside.exp: registers: flushregs
info threads^M
Id Target Id Frame ^M
* 1 process 2346 "killed-outside" (gdb) FAIL: gdb.base/killed-outside.exp: registers: info threads (timeout)
since the inferior disappeared, ptrace will fail. In that case, the
exception should be thrown, so that the caller can handle that.
gdb:
2016-01-22 Yao Qi <yao.qi@linaro.org>
* arm-linux-nat.c (fetch_fpregs): Call perror_with_name
instead of warning.
(store_fpregs, fetch_regs, store_regs): Likewise.
(fetch_wmmx_regs, store_wmmx_regs): Likewise.
(fetch_vfp_regs, store_vfp_regs): Likewise.
String collection always used ref32 to fetch the string pointer. Make it
use gen_fetch instead.
As a side effect, this patch changes dup+const+trace+pop sequence used
for collecting the string's address to a trace_quick opcode. This
results in a shorter agent expression.
This appeared to work on x86_64 since it's a little-endian platform, and
malloc (used in gdb.trace/collection.exp) returns addresses in low 4GB.
Noticed and tested on s390x-ibm-linux-gnu, also tested on
i686-unknown-linux-gnu and x86_64-unknown-linux-gnu.
gdb/ChangeLog:
* ax-gdb.c (gen_traced_pop): Use gen_fetch for string collection.