aboutsummaryrefslogtreecommitdiff
path: root/gdb
AgeCommit message (Collapse)AuthorFilesLines
2016-02-01gdb.texinfo (Value Sizes): Fix typo.Doug Evans2-1/+5
2016-02-01gdb.texinfo (Skipping Over Functions and Files): Fix typo.Doug Evans2-1/+5
2016-02-01gdb.base/skip.exp: Clean up multiple references to same test name.Doug Evans2-11/+18
2016-02-01Mention PR remote/19496 in gdb/testsuite/ChangeLog entryPedro Alves1-0/+1
2016-02-01Test gdb.threads/forking-threads-plus-breakpoint.exp with displaced stepping offPedro Alves2-5/+67
This exposes the internal error Don mentioned in PR19496: (1) internal error -- gdb/target.c:2713: internal-error: Can't determine the current address space of thread More analysis here: https://sourceware.org/ml/gdb-patches/2016-01/msg00685.html The (now kfailed) internal error looks like: continue & Continuing. (gdb) PASS: gdb.threads/forking-threads-plus-breakpoint.exp: cond_bp_target=1: detach_on_fork=on: displaced=off: continue & [New Thread 2846.2847] (...) [New Thread 2867.2867] /home/pedro/gdb/mygit/src/gdb/target.c:2723: internal-error: Can't determine the current address space of thread Thread 2846.2846 A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) KFAIL: gdb.threads/forking-threads-plus-breakpoint.exp: cond_bp_target=1: detach_on_fork=on: displaced=off: inferior 1 exited (GDB internal error) (PRMS: remote/19496) Resyncing due to internal error. gdb/testsuite/ChangeLog: 2016-02-01 Pedro Alves <palves@redhat.com> PR remote/19496 * gdb.threads/forking-threads-plus-breakpoint.exp (displaced_stepping_supported): New global. (probe_displaced_stepping_support): New procedure. (do_test): Add 'displaced' parameter, and use it. (top level): Check for displaced stepping support. Add displaced stepping on/off testing axis.
2016-02-01gdb: Guard against undefined behaviour in mi-vla-fortran.expAndrew Burgess2-16/+38
The test gdb.mi/mi-vla-fortran.exp reveals an issue with the DWARF generated by gfortran. In the test a pointer variable 'pvla2' is created: real, pointer :: pvla2 (:, :) Initially this variable will be unassociated, so something like this: l = associated(pvla2) should return false. In the test gdb stops at a point _before_ pvla2 is associated with anything, and we then try to print pvla2, the expectation is that gdb should reply <not associated>. The problem is that the data the DWARF directs gdb to read (to identify if the variable is associated or not) is not initialised until the first time pvla2 is accessed. As a result gdb ends up reading uninitialised memory, sometimes this uninitialised memory indicates the variable is associated (when it's not). This first mistake can lead to a cascade of errors, reading uninitialised memory, with the result that gdb builds an invalid type to associate with the variable pvla2. In some cases, this invalid type can be very large, which when we try to print pvla2 causes gdb to allocate a large amount of memory. A recent commit added a new gdb variable 'max-value-size', which prevents gdb from allocating values of extreme size. As a result directly trying to print pvla2 will now now error rather than allocate a large amount of memory. However, some of the later tests create a varobj for pvla2, and then ask for the children of that varobj to be displayed. In the case where an invalid type has been computed for pvla2 then the number of children can be wrong, and very big, in which case trying to display all of these children can cause gdb to consume an excessive amount of memory. This commit first detects if printing pvla2 triggers the max-value-size error, if it does then we avoid all the follow on tests relating to the unassociated pvla2, which avoids the second error printing the varobj children. gdb/testsuite/ChangeLog: * gdb.mi/mi-vla-fortran.exp: Add XFAIL for accessing unassociated pointer. Don't perform further tests on the unassociated pointer if the first test fails.
2016-02-01gdb: New set/show max-value-size command.Andrew Burgess9-4/+289
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.
2016-01-31Fix some comments in varobj.{c,h}Simon Marchi3-6/+13
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.
2016-01-29Fix two misleading indentation warningsSimon Marchi3-16/+23
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.
2016-01-28Add ChangeLog entry for update to gdb.dlang demangle tests.Iain Buclaw1-0/+4
2016-01-28Align dlang demangle tests with libiberty.Iain Buclaw1-15/+18
gdb/testsuite/ChangeLog: * gdb.dlang/demangle.exp: Sync tests from libiberty testsuite.
2016-01-28Add rawmemchr to imported gnulib modulesSimon Marchi5-3/+12
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.
2016-01-28Import strchrnul from gnulib and use itSimon Marchi18-42/+639
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.
2016-01-28[testsuite] Fix tiemout fail in gdb.fortran/vla-value.expYao Qi2-3/+17
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.
2016-01-28Fix GDB crash in dprintf.expYao Qi2-9/+6
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.
2016-01-27rx: Treat scalars larger than 8 bytes as aggregates in rx_push_dummy_call.Kevin Buettner2-1/+7
This patch fixes the following failures (which are also GDB internal errors) for the -m64bit-doubles multilib: FAIL: gdb.base/callfuncs.exp: p t_double_complex_values(dc1, dc2) (GDB internal error) FAIL: gdb.base/callfuncs.exp: p t_double_complex_values(dc3, dc4) (GDB internal error) FAIL: gdb.base/callfuncs.exp: p t_double_complex_many_args(dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4) (GDB internal error) FAIL: gdb.base/callfuncs.exp: p t_double_complex_many_args(dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1) (GDB internal error) FAIL: gdb.base/callfuncs.exp: p t_long_double_complex_values(ldc1, ldc2) (GDB internal error) FAIL: gdb.base/callfuncs.exp: p t_long_double_complex_values(ldc3, ldc4) (GDB internal error) FAIL: gdb.base/callfuncs.exp: p t_long_double_complex_many_args(ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4) (GDB internal error) FAIL: gdb.base/callfuncs.exp: p t_long_double_complex_many_args(ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1,ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1) (GDB internal error) FAIL: gdb.base/callfuncs.exp: noproto: p t_double_complex_values(dc1, dc2) (GDB internal error) FAIL: gdb.base/callfuncs.exp: noproto: p t_double_complex_values(dc3, dc4) (GDB internal error) FAIL: gdb.base/callfuncs.exp: noproto: p t_double_complex_many_args(dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4, dc1, dc2, dc3, dc4) (GDB internal error) FAIL: gdb.base/callfuncs.exp: noproto: p t_double_complex_many_args(dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1, dc1) (GDB internal error) FAIL: gdb.base/callfuncs.exp: noproto: p t_long_double_complex_values(ldc1, ldc2) (GDB internal error) FAIL: gdb.base/callfuncs.exp: noproto: p t_long_double_complex_values(ldc3, ldc4) (GDB internal error) FAIL: gdb.base/callfuncs.exp: noproto: p t_long_double_complex_many_args(ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4, ldc1, ldc2, ldc3, ldc4) (GDB internal error) FAIL: gdb.base/callfuncs.exp: noproto: p t_long_double_complex_many_args(ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1,ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1, ldc1) (GDB internal error) FAIL: gdb.base/varargs.exp: print find_max_double_real(4, dc1, dc2, dc3, dc4) (GDB internal error) FAIL: gdb.base/varargs.exp: print find_max_long_double_real(4, ldc1, ldc2, ldc3, ldc4) (GDB internal error) The assertion failure which is tripped is: gdb_assert (arg_size <= 4); While it may seem that the patch ought to disallow scalars larger than 4, scalars of size 8 are explicitly handled by the code elsewhere. This came up because gcc has a complex type that is 16 bytes in length when 64-bit doubles are used. gdb/ChangeLog: * rx-tdep.c (rx_push_dummy_call): Treat scalars larger than 8 bytes as aggregates.
2016-01-27Add Keith Seitz as Linespec MaintainerJoel Brobecker2-0/+7
gdb/ChangeLog: * MAINTAINERS (Responsible Maintainers): Add Keith Seitz as Linespec Maintainers.
2016-01-26Fix function commentsSimon Marchi2-2/+7
Two obvious fixes. gdb/ChangeLog: * common/common-utils.c (skip_spaces): Fix comment. (skip_to_space_const): Likewise.
2016-01-26Fix subject verb agreement in the description of several debug settings.John Baldwin2-7/+11
gdb/doc/ChangeLog: * gdb.texinfo (Debugging Output): Fix subject verb disagreements.
2016-01-26Remove argument pc in get_next_pcsYao Qi9-21/+38
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.
2016-01-26[GDBserver] Use regcache_read_pc in install_software_single_step_breakpointsYao Qi2-1/+7
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.
2016-01-26[GDBserver] Block and unblock SIGIOYao Qi2-14/+30
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.
2016-01-26[GDBserver] Check input interrupt after reading in a packetYao Qi2-0/+21
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.
2016-01-26Fix GCC6 -Wmisleading-indentation issues.Mark Wielaard5-29/+42
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.
2016-01-25Remove new_thread_notify and dead_thread_notifyYao Qi3-35/+7
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.
2016-01-25Fix PR 19461: strange "info thread" behavior in non-stopPedro Alves5-0/+269
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.
2016-01-25Fix PR 19494: hang when killing unfollowed fork childrenPedro Alves5-35/+281
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.
2016-01-25Move foreach_with_prefix to lib/gdb.expPedro Alves5-36/+22
gdb/testsuite/ChangeLog: 2016-01-25 Pedro Alves <palves@redhat.com> * gdb.base/step-sw-breakpoint-adjust-pc.exp (foreach_with_prefix): Delete, moved to lib/gdb.exp. * gdb.threads/forking-threads-plus-breakpoint.exp (foreach_with_prefix): Likewise. * gdb.threads/process-dies-while-handling-bp.exp (foreach_with_prefix): Likewise. * lib/gdb.exp (foreach_with_prefix): New procedure.
2016-01-25Delete ChangeLog entry from the wrong placePedro Alves1-63/+0
Missed actually removing this in 37e42b4fe92c...
2016-01-25gdb.trace/testsuite: Bump stack collection fudge factor.Marcin Kościelnicki3-2/+7
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.
2016-01-23gdb.trace: Fix unavailable-dwarf-piece.exp on big endian targetsMarcin Kościelnicki2-3/+22
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.
2016-01-23gdb.trace: Fix another expected message on continue.Marcin Kościelnicki2-1/+5
Missed one message in bd0a71fa16f668341a9361c695bc3ca44d27b322, 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.
2016-01-22testsuite: gdb.gdb/selftest.exp: Drop expected Thread numberJan Kratochvil2-1/+8
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.
2016-01-22testsuite: Fix PR threads/19422 regression + Guile regressionJan Kratochvil2-1/+12
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.
2016-01-22Reword the string description of native FreeBSD ptids.John Baldwin2-1/+5
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.
2016-01-22gdb.trace: Fix write_inferior_data_ptr on 32-bit big-endian machines.Marcin Kościelnicki2-3/+10
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 *).
2016-01-22[testsuite] Unbuffer the output in gdb.base/multi-forks.cYao Qi2-0/+11
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.
2016-01-22[ARM] perror_with_name when failed to fetch/store registersYao Qi2-48/+20
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.
2016-01-21* breakpoint.c (init_breakpoint_sal): Add comment.Doug Evans2-1/+6
2016-01-21* lib/ada.exp (gdb_compile_ada): Fix typo.Doug Evans2-1/+5
2016-01-21gdb.trace: Fix string collection for 64-bit platforms.Marcin Kościelnicki2-12/+15
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.
2016-01-21gdb: Small cleanup to disasm.c:maybe_add_dis_line_entryAndrew Burgess2-4/+9
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.
2016-01-21gdb: Respect CXXFLAGS when building with C++ compilerPedro Alves7-11/+41
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.
2016-01-21Fix regression introduced in "break *<EXPR>" by explicit location patches.Joel Brobecker12-12/+229
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 a06efdd6effd149a1d392df8d62824e44872003a 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.
2016-01-21Detect the arm/thumb mode of code SIGRETURN or RT_SIGRETURN returns toYao Qi4-6/+42
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.
2016-01-20Fix sorting of enum values in FlagEnumerationPrinterSimon Marchi5-14/+42
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.
2016-01-20gnu_vector.exp: Respect `should_kfail' for PR 8549Andreas Arnez2-1/+22
The gnu_vector test case yields a new FAIL on s390x: FAIL: gdb.base/gnu_vector.exp: verify vector return value It was introduced by commit 77ae9c1933b50 "gdb.base/gnu_vector.exp: Don't test output from the inferior". That commit dropped the special handling for GDB's inability (on some targets) to set the return value. This change re-establishes the logic from before, converting the above FAIL to a KFAIL (PRMS gdb/8549). gdb/testsuite/ChangeLog: * gdb.base/gnu_vector.exp: Re-establish handling for should_kfail when GDB can not set the vector return value. Add more comments for clarification.
2016-01-20Fix missing IPA lib in tspeed.exp in some configurations.Antoine Tremblay2-1/+6
On Ubuntu 14.04 the following failure would be seen when running the tspeed.exp test on a target that supports fast tracepoints like x86_64: Target returns error code '.In-process agent library not loaded in process. Fast and static tracepoints unavailable.'. (gdb) FAIL: gdb.trace/tspeed.exp: start trace experiment This is because the default is to link with --as-needed and the gdb_compile for the test is using the libs argument instead of shlib which corrects this issue since 6ebea266fd0a7a56c90db3ab6237ff9f6c919747 by adding -Wl,--no-as-needed. This patch fixes the issue by passing the lib as the shlib argument to gdb_compile. Tested on Ubuntu 14.04 x86_64. gdb/testsuite/ChangeLog: * gdb.trace/tspeed.exp: Use shlib instead of libs in gdb_compile command.
2016-01-20Fix gdb/ChangeLog typoPedro Alves1-1/+1
2016-01-20Move ChangeLog entry to proper place (gdb/testsuite/ -> gdb/)Pedro Alves1-0/+63