tfile_fetch_registers currently wrongly fetches registers using
gdb order instead of g packet order. On x86_64 with AVX, this causes
problems with ymm*h and orig_rax registers: gdb has ymm*h first, while
g packet has orig_rax first.
gdb/ChangeLog:
* tracefile-tfile.c (tfile_fetch_registers): Use g packet order
instead of gdb order.
gdb/doc/ChangeLog:
* gdb.texinfo (Trace File Format): Remove misleading information
about register block ordering.
This resulted in the last register being considered unavailable.
On plain x86_64 (without AVX), this happened to be orig_rax.
gdb/ChangeLog:
* tracefile-tfile.c (tfile_fetch_registers): Fix off-by-one in bounds
check.
Now that the GDB 7.11 branch has been created, we can
bump the version number.
gdb/ChangeLog:
GDB 7.11 branch created (9ef9e6a6a0):
* version.in: Bump version to 7.11.50.DATE-git.
One of the last checks update_breakpoints_after_exec does while looping
over the list of breakpoints is check that the breakpoint has a valid
location spec. It uses event_location_empty_p to check if the location spec
is "empty", and if it is, the breakpoint is deleted.
momentary_breakpoint types rely on setting the breakpoint structure's
location spec to NULL, thereby causing an update to delete the breakpoint.
However, event_location_empty_p assumed that locations were never NULL.
As a result, GDB would crash dereferencing a NULL pointer whenever
update_breakpoints_after_exec would encounter a momentary_breakpoint.
This patch creates a new wrapper/helper function which tests that the given
breakpoint's location spec is non-NULL and if it is not "empty"
or "unspecified."
gdb/ChangeLog
PR breakpoints/19546
* breakpoint.c (breakpoint_event_location_empty_p): New function.
(update_breakpoints_after_exec, bkpt_re_set): Use this new function
instead of event_location_empty_p.
gdb/testsuite/ChangeLog
PR breakpoints/19546
* gdb.base/infcall-exec.c: New file.
* gdb.base/infcall-exec2.c: New file.
* gdb.base/infcall-exec.exp: New file.
MI is currently using string_to_event_location to enable the use of legacy
linespecs, but using this function (until this patchset) had the (as yet
unnoticed) side effect of allowing both MI and CLI representation for
explicit locations.
This patch simply changes MI to use the same legacy linespec functions
that the python and guile interpreters use. This eliminates the CLI syntax
for explicit locations (in MI).
gdb/ChangeLog
* mi/mi-cmd-break.c (mi_cmd_break_insert_1): Use
string_to_event_location_basic instead of string_to_event_location.
This patch, analogous to the previous python patch, implements proper
legacy linespec support in guile code using the newly introduced
string_to_event_location_basic.
gdb/ChangeLog
* guile/scm-breakpoint.c (gdbscm_register_breakpoint_x): Skip
leading whitespace and use string_to_event_location_basic instead
of new_linespec_location.
gdb/testsuite/ChangeLog
* gdb.guile/scm-breakpoint.exp (test_bkpt_address): New procedure.
(toplevel): Call test_bkpt_address.
Now that "legacy" linespecs benefit from consolidated support in
string_to_event_location_basic, python's Breakpoint command should use this
function to turn strings into event locations.
As a result, this patch fixes python/19506. Before:
(gdb) python gdb.Breakpoint("*main")
Traceback (most recent call last):
File "<string>", line 1, in <module>
RuntimeError: Function "*main" not defined.
Error while executing Python code.
After:
(gdb) python gdb.Breakpoint("*main")
Breakpoint 1 at 0x4005fb: file ../../../src/gdb/testsuite/gdb.python/py-breakpoint.c, line 32.
gdb/ChangeLog
PR python/19506
* python/py-breakpoint.c (bppy_init): Use
string_to_event_location_basic instead of new_linespec_location.
gdb/testsuite/ChangeLog
PR python/19506
* gdb.python/py-breakpoint.exp (test_bkpt_address): New procedure.
(toplevel): Call test_bkpt_address.
This patch refactors string_to_event_location, breaking it into two
separate functions:
1) string_to_event_location_basic
A "basic" string parser that implements support for "legacy" linespecs
(linespec, address, and probe locations). This function is intended to
be used by any UI wishing/needing to support this legacy behavior.
2) string_to_event_location
This is now intended as a CLI-only function which adds explicit location
parsing in a CLI-appropriate manner (in the form of traditional option/value
pairs).
Together these patches serve to simplify string-to-event location parsing
for all existing non-CLI interfaces (MI, guile, and python).
gdb/ChangeLog
* location.c (string_to_explicit_location): Note that "-p" is
reserved for probe locations and return NULL for any input
that starts with that.
(string_to_event_location): Move "legacy" linespec code to ...
(string_to_event_location_basic): ... here.
* location.h (string_to_event_location): Update comment.
(string_to_event_location_basic): New function.
Using AC_OUTPUT with arguments has been deprecated for some time in
autoconf, even in version 2.64, which we are using. This change should
not affect functionality.
I also removed the "exit 0"'s, they shouldn't be necessary.
gdb/ChangeLog:
* configure.ac: Use AC_CONFIG_FILES instead of passing arguments
to AC_OUTPUT. Remove "exit 0" at the end.
* configure: Regenerate.
gdb/testsuite/ChangeLog:
* configure.ac: Use AC_CONFIG_FILES instead of passing arguments
to AC_OUTPUT.
* configure: Regenerate.
gdb/gdbserver/ChangeLog:
* configure.ac: Use AC_CONFIG_FILES instead of passing arguments
to AC_OUTPUT.
* configure: Regenerate.
PR19548 shows that we still have problems related to 13fd3ff343:
[PR17431: following execs with "breakpoint always-inserted on"]
https://sourceware.org/ml/gdb-patches/2014-09/msg00733.html
The problem this time is that we currently update the global location
list and try to insert breakpoint locations after re-setting _each_
breakpoint in turn.
Say:
- We have _more_ than one breakpoint set. Let's assume 2.
- There's a breakpoint with a pre-exec address that ends up being an
unmapped address after the exec.
- That breakpoint is NOT the first in the breakpoint list.
Then when handling an exec, and we re-set the first breakpoint in the
breakpoint list, we mistakently try to install the old pre-exec /
un-re-set locations of the other breakpoint, which fails:
(gdb) continue
Continuing.
process 28295 is executing new program: (...)/execl-update-breakpoints2
Error in re-setting breakpoint 1: Warning:
Cannot insert breakpoint 2.
Cannot access memory at address 0x1000764
Breakpoint 1, main (argc=1, argv=0x7fffffffd368) at /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.base/execl-update-breakpoints.c:34
34 len = strlen (argv[0]);
(gdb)
Fix this by deferring the global location list update till after all
breakpoints are re-set.
Tested on x86_64 Fedora 20, native and gdbserver.
gdb/ChangeLog:
2016-02-09 Pedro Alves <palves@redhat.com>
PR breakpoints/19548
* breakpoint.c (create_overlay_event_breakpoint): Don't update
global location list here.
(create_longjmp_master_breakpoint)
(create_std_terminate_master_breakpoint)
(create_exception_master_breakpoint, create_jit_event_breakpoint)
(update_breakpoint_locations):
(breakpoint_re_set): Update global location list after all
breakpoints are re-set.
gdb/testsuite/ChangeLog:
2016-02-09 Pedro Alves <palves@redhat.com>
PR breakpoints/19548
* gdb.base/execl-update-breakpoints.c (some_function): New
function.
(main): Call it.
* gdb.base/execl-update-breakpoints.exp: Add a second breakpoint.
Tighten expected GDB output.
I built remote.c with -Wunused, to check a function I was working on,
turns out there is a bunch of unused variables.
gdb/ChangeLog:
* remote.c (remote_register_number_and_offset): Remove unused
variable(s).
(remote_thread_always_alive): Likewise.
(remote_update_thread_list): Likewise.
(process_initial_stop_replies): Likewise.
(remote_start_remote): Likewise.
(remote_check_symbols): Likewise.
(discard_pending_stop_replies): Likewise.
(process_stop_reply): Likewise.
(putpkt_binary): Likewise.
(getpkt): Likewise.
(remote_add_target_side_condition): Likewise.
(remote_insert_breakpoint): Likewise.
(remote_supports_stopped_by_sw_breakpoint): Likewise.
(remote_supports_stopped_by_hw_breakpoint): Likewise.
(remote_xfer_partial): Likewise.
(remote_read_btrace): Likewise.
(remote_async_serial_handler): Likewise.
(remote_thread_events): Likewise.
(_initialize_remote): Likewise.
This patch removes some dead code.
I noticed that varobj_delete was always called with dellist == NULL, so
I started removing that parameter. That allows removing a good chunk of
the code in varobj_delete, making it almost trivial. We can also remove
the resultp parameters in that whole trail. In turn, this shows that
struct cpstack, cppush and cppop were only used fo that mechanism, so
they can be removed as well.
I also moved the function comment to the header file to comply with
today's guideline, even though the rest of the file does not respect it
(yet).
gdb/ChangeLog:
* varobj.h (varobj_delete): Remove dellist parameter, update and
move documentation here.
* varobj.c (struct cpstack, cppush, cppop): Remove.
(delete_variable): Remove resultp (first) parameter.
(delete_variable_1): Likewise.
(varobj_delete): Remove dellist parameter and unused code.
(update_dynamic_varobj_children): Adjust varobj_delete call.
(update_type_if_necessary): Likewise.
(varobj_set_visualizer): Likewise.
(varobj_update): Likewise.
(value_of_root): Likewise.
(varobj_invalidate_iter): Likewise.
* mi/mi-cmd-var.c (mi_cmd_var_delete): Likewise.
Hi,
I see this error when GDB connects with qemu,
(gdb) n
....
Sending packet: $vCont;c#a8...Ack
Packet received: Ffstat,00000001,f6fff038
Cannot execute this command while the target is running.
Use the "interrupt" command to stop the target
and then try again.
looks we don't set rs->waiting_for_stop_reply to zero
before handle fileio request,
#10 0x00000000005edb64 in target_write (len=64, offset=4143968312, buf=0x7fffffffd570 "\375\377\377\377", annex=0x0, object=TARGET_OBJECT_MEMORY,
ops=<optimised out>) at /home/yao/SourceCode/gnu/gdb/git/gdb/target.c:1922
#11 target_write_memory (memaddr=memaddr@entry=4143968312, myaddr=myaddr@entry=0x7fffffffd6a0 "", len=len@entry=64)
at /home/yao/SourceCode/gnu/gdb/git/gdb/target.c:1500
#12 0x00000000004b2b41 in remote_fileio_func_fstat (buf=0x127b258 "") at /home/yao/SourceCode/gnu/gdb/git/gdb/remote-fileio.c:1037
#13 0x00000000004b1878 in do_remote_fileio_request (uiout=<optimised out>, buf_arg=buf_arg@entry=0x127b240)
at /home/yao/SourceCode/gnu/gdb/git/gdb/remote-fileio.c:1204
#14 0x00000000005b8c7c in catch_exceptions_with_msg (func_uiout=<optimised out>, func=func@entry=0x4b1800 <do_remote_fileio_request>,
func_args=func_args@entry=0x127b240, gdberrmsg=gdberrmsg@entry=0x0, mask=mask@entry=RETURN_MASK_ALL)
at /home/yao/SourceCode/gnu/gdb/git/gdb/exceptions.c:187
#15 0x00000000005b8dea in catch_exceptions (uiout=<optimised out>, func=func@entry=0x4b1800 <do_remote_fileio_request>, func_args=func_args@entry=0x127b240,
mask=mask@entry=RETURN_MASK_ALL) at /home/yao/SourceCode/gnu/gdb/git/gdb/exceptions.c:167
#16 0x00000000004b2fff in remote_fileio_request (buf=0x127b240 "Xf6fff038,0:", ctrlc_pending_p=0) at /home/yao/SourceCode/gnu/gdb/git/gdb/remote-fileio.c:1255
#17 0x0000000000496f12 in remote_wait_as (ptid=..., status=0x7fffffffdb20, options=1) at /home/yao/SourceCode/gnu/gdb/git/gdb/remote.c:6997
however, we did set rs->waiting_for_stop_reply to zero before Luis's
patch https://sourceware.org/ml/gdb-patches/2015-10/msg00336.html
In fact, Luis's patch v1
https://sourceware.org/ml/gdb-patches/2015-08/msg00809.html is about
setting rs->waiting_for_stop_reply back to one after
remote_fileio_request, which is correct. However during the review, the
patch is changed and ends up with "not setting rs->waiting_for_stop_reply
to zero".
I manually test GDB, but I don't have a way to run regression tests.
gdb:
2016-02-04 Yao Qi <yao.qi@linaro.org>
* remote.c (remote_wait_as): Set rs->waiting_for_stop_reply to
0 before handling 'F' and set it back afterwards.
This is unused since 54eb231c4b, where
static arrays of ui_out_levels were replaced with vectors.
gdb/ChangeLog:
* ui-out.c (MAX_UI_OUT_LEVELS): Remove.
New bnds fields will be always present for x86 architecture.
Fixup for compatibility layer 32bits has to be fixed.
It was added the nat_siginfo to serving as intermediate step
between kernel provided siginfo and the fix up routine.
When executing compat_siginfo_from_siginfo or
compat_x32_siginfo_from_siginfo first the buffer read from the kernel are
converted into the nat_signfo for homogenization, then the fields of
nat_siginfo are use to set the compat and compat_x32 siginfo fields.
In other to make this conversion independent of the system where gdb
is compiled the most complete version of the siginfo, named as native
siginfo, is used internally as an intermediate step.
Conversion using nat_siginfo is exemplified below:
compat_siginfo_from_siginfo or compat_x32_siginfo_from_siginfo:
buffer (from the kernel) -> nat_siginfo -> 32 / X32 siginfo
(memcpy) (field by field)
siginfo_from_compat_x32_siginfo or siginfo_from_compat_siginfo:
32 / X32 siginfo -> nat_siginfo -> buffer (to the kernel)
(field by field) (memcpy)
Caveat: No support for MPX on x32.
2016-02-02 Walfred Tedeschi <walfred.tedeschi@intel.com>
gdb/ChangeLog:
* amd64-linux-siginfo.c (nat_siginfo_t, nat_sigval_t, nat_timeval):
New types.
(compat_siginfo): New bound fields added.
(compat_x32_siginfo): New field added.
(cpt_si_addr_lsb): New define.
(compat_siginfo_from_siginfo): Use nat_siginfo.
(siginfo_from_compat_siginfo): Use nat_siginfo.
(compat_x32_siginfo_from_siginfo): Likewise.
(siginfo_from_compat_x32_siginfo): Likewise.
Both Linux and glibc have introduced bound related fields in the
segmentation fault fields of the siginfo_t type. Add the new fields
to our x86's siginfo_t type too.
Kernel patch:
http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=ee1b58d36aa1b5a79eaba11f5c3633c88231da83
Glibc patch:
d4358b51c2
2016-02-02 Walfred Tedeschi <walfred.tedeschi@intel.com>
gdb/ChangeLog:
* linux-tdep.c (linux_get_siginfo_type): Add the _addr_bnd
structure to the siginfo if extra_fields contains
LINUX_SIGINFO_FIELD_ADDR_BND.
Use linux_get_siginfo_type_with_fields for adding bound fields on
segmentation fault for i386/amd64 siginfo.
2016-02-02 Walfred Tedeschi <walfred.tedeschi@intel.com>
gdb/ChangeLog:
* linux-tdep.h (linux_get_siginfo_type_with_fields): Make extern.
* linux-tdep.c (linux_get_siginfo_type_with_fields): Make extern.
* i386-linux-tdep.h (x86_linux_get_siginfo_type): New
function.
* amd64-linux-tdep.c (amd64_linux_init_abi_common): Add
x86_linux_get_siginfo_type for the amd64 abi.
* i386-linux-tdep.c (x86_linux_get_siginfo_type): New
function.
(i386_linux_init_abi): Add new function at the i386 ABI
initialization.
First add new structure and function to allow architecture customization
for the siginfo structure.
2016-01-15 Walfred Tedeschi <walfred.tedeschi@intel.com>
gdb/ChangeLog:
* linux-tdep.h (linux_siginfo_extra_field_values): New enum values.
(linux_siginfo_extra_fields): New enum type.
* linux-tdep.c (linux_get_siginfo_type_with_fields): New function.
(linux_get_siginfo_type): Use new function.
For languages with dynamic types, an incorrect program, or uninitialised
variables within a program, could result in an incorrect, overly large
type being associated with a value. Currently, attempting to print such
a variable will result in gdb trying to allocate an overly large buffer.
If this large memory allocation fails then the result can be gdb either
terminating, or (due to memory contention) becoming unresponsive for the
user.
A new user visible variable in gdb helps guard against such problems,
two new commands are available:
set max-value-size
show max-value-size
The 'max-value-size' is the maximum size of memory in bytes that gdb
will allocate for the contents of a value. Any attempt to allocate a
value with a size greater than this will result in an error. The
initial default for this limit is set at 64k, this is based on a similar
limit that exists within the ada specific code.
It is possible for the user to set max-value-size to unlimited, in which
case the old behaviour is restored.
gdb/ChangeLog:
* value.c (max_value_size): New variable.
(MIN_VALUE_FOR_MAX_VALUE_SIZE): New define.
(show_max_value_size): New function.
(check_type_length_before_alloc): New function.
(allocate_value_contents): Call check_type_length_before_alloc.
(set_value_enclosing_type): Likewise.
(_initialize_values): Add set/show handler for max-value-size.
* NEWS: Mention new set/show command.
gdb/doc/ChangeLog:
* gdb.texinfo (Value Sizes): New section.
(Data): Add the 'Value Sizes' node to the menu.
gdb/testsuite/ChangeLog:
* gdb.base/max-value-size.c: New file.
* gdb.base/max-value-size.exp: New file.
* gdb.base/huge.exp: Disable max-value-size for this test.
A few typos. The comment about varobj_create has been misplaced since
the dawn of time.
gdb/ChangeLog:
* varobj.h (struct varobj): Fix typos in comments.
(struct lang_varobj_ops): Likewise.
* varobj.c (VAROBJ_TABLE_SIZE): Likewise.
(varobj_create): Move misplaced comment.
Two small changes so everything builds with latest GCC and its
-Wmisleading-indentation.
In the aarch64-tdep.c case, the two misindented lines should actually be
part of the for loop. It looks like the indentation is all done using
spaces in that file though... I fixed it (changed for tabs + spaces) for
the lines I touched.
In the xcoffread.c case, we can simply remove the braces and fix the
indentation.
gdb/ChangeLog:
* aarch64-tdep.c (aarch64_record_asimd_load_store): Add braces
to for include additional lines.
* xcoffread.c (scan_xcoff_symtab): Remove unnecessary braces.
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.
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.
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.
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.
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.
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.
Give the function a better name (drop "maybe_") and update the header
comment.
gdb/ChangeLog:
* disasm.c (maybe_add_dis_line_entry): Rename to...
(add_dis_line_entry): ...this, and update header comment.
(do_mixed_source_and_assembly): Now use add_dis_line_entry.
Currently, even when built with --enable-build-with-cxx, gdb uses
CFLAGS instead of CXXFLAGS. This commit fixes it.
CXXFLAGS set in the environment when configure was run is now honored
in the generated gdb/Makefile, and you can also override CXXFLAGS in
the command like at make time, with the usual 'make CXXFLAGS="..."'
Objects built with a C compiler (e.g., gnulib) still honor CFLAGS
instead.
gdb/ChangeLog:
2016-01-21 Pedro Alves <palves@redhat.com>
* Makefile.in (COMPILER_CFLAGS): New.
(CXXFLAGS): Get it from configure.
(INTERNAL_CFLAGS_BASE, INTERNAL_LDFLAGS): Use COMPILER_CFLAGS
instead of CFLAGS.
* build-with-cxx.m4 (GDB_AC_BUILD_WITH_CXX): Set and AC_SUBST
COMPILER_CFLAGS.
* configure: Regenerate.
gdb/gdbserver/ChangeLog:
2016-01-21 Pedro Alves <palves@redhat.com>
* Makefile.in (COMPILER_CFLAGS, CXXFLAGS): New.
(INTERNAL_CFLAGS_BASE): Use COMPILER_CFLAGS instead of CFLAGS.
* configure: Regenerate.
A relatively recent patch support for explicit locations, and part
of that patch cleaned up the way we parse breakpoint locations.
Unfortunatly, a small regression crept in for "*<EXPR>" breakpoint
locations. In particular, on PIE programs, one can see the issue by
doing the following, with any program:
(gdb) b *main
Breakpoint 1 at 0x51a: file hello.c, line 3.
(gdb) run
Starting program: /[...]/hello
Error in re-setting breakpoint 1: Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x51a
Warning:
Cannot insert breakpoint 1.
Cannot access memory at address 0x51a
Just for the record, this regression was introduced by:
commit a06efdd6ef
Date: Tue Aug 11 17:09:35 2015 -0700
Subject: Explicit locations: introduce address locations
What happens is that the patch makes the implicit assumption that
the address computed the first time is static, as if it was designed
to only support litteral expressions (Eg. "*0x1234"). This allows
the shortcut of not re-computing the breakpoint location's address
when re-setting breakpoints.
However, this does not work in general, as demonstrated in the example
above.
This patch plugs that hole simply by saving the original expression
used to compute the address as part of the address location, so as
to then re-evaluate that expression during breakpoint re-set.
gdb/ChangeLog:
* location.h (new_address_location): Add new parameters
"addr_string" and "addr_string_len".
(get_address_string_location): Add declaration.
* location.c (new_address_location): Add new parameters
"addr_string" and "addr_string_len". If not NULL, store
a copy of the addr_string in the new location as well.
(get_address_string_location): New function.
(string_to_event_location): Update call to new_address_location.
* linespec.c (event_location_to_sals) <ADDRESS_LOCATION>:
Save the event location in the parser's state before
passing it to convert_address_location_to_sals.
* breakpoint.c (create_thread_event_breakpoint): Update call
to new_address_location.
(init_breakpoint_sal): Get the event location's string, if any,
and use it to update call to new_address_location.
* python/py-finishbreakpoint.c (bpfinishpy_init):
Update call to new_address_location.
* spu-tdep.c (spu_catch_start): Likewise.
* config/djgpp/fnchange.lst: Add entries for
gdb/testsuite/gdb.base/break-fun-addr1.c and
gdb/testsuite/gdb.base/break-fun-addr2.c.
gdb/testsuite/ChangeLog:
* gdb.base/break-fun-addr.exp: New file.
* gdb.base/break-fun-addr1.c: New file.
* gdb.base/break-fun-addr2.c: New file.
This patch fixes the following regression introduced by commit d0e59a68
step^M
39 } /* handler */^M
1: x/i $pc^M
=> 0x8740 <handler+80>: sub sp, r11, #0^M
(gdb) step^M
^M
Program received signal SIGSEGV, Segmentation fault.^M
setitimer () at ../sysdeps/unix/syscall-template.S:81^M
81 ../sysdeps/unix/syscall-template.S: No such file or directory.^M
1: x/i $pc^M
=> 0xb6eff9c0 <setitimer>: push {r7}^M
(gdb) FAIL: gdb.base/sigstep.exp: continue to handler, si+advance in handler, step from handler: leave handler
in my test setting, program is compiled in arm mode, but the glibc
is built in thumb mode, so when we do 'step' to step over syscall
instruction svc for SIGRETURN, GDB should set breakpoint for arm mode
in the program, even though the current program in glibc is in thumb
mode. Current GDB doesn't consider the case that the mode of program
SIGRETURN goes to can be different from current program mode.
In fact, GDB has taken care of this arm/thumb mode changes already,
see
/* Copy the value of next pc of sigreturn and rt_sigrturn into PC,
return 1. In addition, set IS_THUMB depending on whether we
will return to ARM or Thumb code. Return 0 if it is not a
rt_sigreturn/sigreturn syscall. */
static int
arm_linux_sigreturn_return_addr (struct frame_info *frame,
unsigned long svc_number,
CORE_ADDR *pc, int *is_thumb)
but in the commit d0e59a68
> - arm_linux_sigreturn_return_addr (frame, svc_number, &return_addr, &is_thumb);
> + if (svc_number == ARM_SIGRETURN || svc_number == ARM_RT_SIGRETURN)
> + next_pc = arm_linux_sigreturn_next_pc (regcache, svc_number);
the IS_THUMB setting is lost, so it is a regression.
gdb:
2016-01-21 Yao Qi <yao.qi@linaro.org>
* arm-linux-tdep.c (arm_linux_sigreturn_next_pc): Add parameter
is_thumb and set it according to CPSR saved on the stack.
(arm_linux_get_next_pcs_syscall_next_pc): Pass is_thumb to
arm_linux_sigreturn_next_pc.
gdb/gdbserver:
2016-01-21 Yao Qi <yao.qi@linaro.org>
* linux-arm-low.c (arm_sigreturn_next_pc): Add parameter
is_thumb and set it according to CPSR saved on the stack.
(get_next_pcs_syscall_next_pc): Pass is_thumb to
arm_sigreturn_next_pc.
The lambda function used to sort the enumerator list does not work
properly. This list consists of tuples, (enum label, enum value). The
key function returns x.enumval. enumval not being defined for a tuple,
we see this exception in the test log:
Python Exception <class 'AttributeError'> 'tuple' object has no attribute 'enumval'
The function should return the second item of the tuple, which is the
enumval.
The pretty-printer still worked mostly correctly, except that the
enumeration values were not sorted. The test still passed because the
enumeration values are already sorted where they are defined. The test
also passed despite the exception being printed, because the right output
was printed after the exception:
print (enum flag_enum) (FLAG_1)
Python Exception <type 'exceptions.AttributeError'> 'tuple' objecthas no attribute 'enumval':M
$7 = 0x1 [FLAG_1]
(gdb) PASS: gdb.python/py-pp-maint.exp: print FLAG_1
New in v2:
- Improved test case, I stole Pedro's example directly. It verifies
that the sorting of enumerators by value works, by checking that
printing FOO_MASK appears as FOO_1 | FOO_2 | FOO_3.
I noticed that I could change the regexps to almost anything and the
tests would still pass. I think it was because of the | in there. I
made them more robust by using string_to_regexp. I used curly braces
{ } instead of quoting marks " " for strings, so that I could use
square brackets [ ] in them without having to escape them all. I also
removed the "message" part of the tests, since they are redundant with
the command, and it's just more maintenance to have to update them.
Tested with Python 2.7 and 3.5.
gdb/ChangeLog:
* python/lib/gdb/printing.py (FlagEnumerationPrinter.__call__):
Fix enumerators sort key function.
gdb/testsuite/ChangeLog:
* gdb.python/py-pp-maint.exp: Change/add enum flag tests.
* gdb.python/py-pp-maint.c (enum flag_enum): Use more complex
enum flag values.
(GNU Coding Standard...)
gdb/ChangeLog:
* printcmd.c (print_scalar_formatted): move binary operator from
end of line to beginning of next line. Adjust formatting
accordingly.
gdb/ChangeLog:
* fbsd-tdep.c (find_stop_signal): Remove.
(struct fbsd_collect_regset_section_cb) <lwp>: New field.
<stop_signal>: New field.
<abort_iteration>: New field.
(fbsd_collect_regset_section_cb): Use new fields.
(fbsd_collect_thread_registers): New function.
(struct fbsd_corefile_thread_data): New structure.
(fbsd_corefile_thread): New function.
(fbsd_make_corefile_notes): Use new function to dump notes for each
non-exited thread in a process.