aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
AgeCommit message (Collapse)AuthorFilesLines
2015-09-21Add a test case for fast tracepoints' locking mechanismPierre Langlois3-0/+199
When installing a fast tracepoint, we create a jump pad with a spin-lock. This way, only one thread can collect a given tracepoint at any time. This test case checks that this lock actually works as expected. This test works by creating a function which overrides the in-process agent library's gdb_collect function. On start up, GDBserver will ask GDB with the 'qSymbol' packet about symbols present in the inferior. GDB will reply with the gdb_agent_gdb_collect function from the test case instead of the one from the agent. gdb/testsuite/ChangeLog: * gdb.trace/ftrace-lock.c: New file. * gdb.trace/ftrace-lock.exp: New file.
2015-09-21Add a gdb.trace test for instruction relocationPierre Langlois3-0/+627
This test case makes sure that relocating PC relative instructions does not change their behaviors. All PC relative AArch64 instructions are covered. While call and jump (32 bit relative) instructions are covered on x86. The test case creates a static array of function pointers for each supported architecture. Each function in this array tests a specific instruction using inline assembly. They all need to contain a symbol in the form of 'set_point\[0-9\]+' and finish by either calling pass or fail. The number of 'set_pointN' needs to go from 0 to (ARRAY_SIZE - 1). The test will: - look up the number of function pointers in the static array. - set fast tracepoints on each 'set_point\[0-9\]+' symbol, one in each functions from 0 to (ARRAY_SIZE - 1). - run the trace experiment and make sure the pass function is called for every function. gdb/testsuite/ChangeLog: * gdb.arch/insn-reloc.c: New file. * gdb.arch/ftrace-insn-reloc.exp: New file.
2015-09-21Enable fast tracepoint testsPierre Langlois11-1/+36
gdb/testsuite/ChangeLog: * gdb.trace/change-loc.h (func4) [__aarch64__]: Add a nop instruction. * gdb.trace/pendshr1.c (pendfunc): Likewise. * gdb.trace/pendshr2.c (pendfunc2): Likewise. * gdb.trace/range-stepping.c: Likewise. * gdb.trace/trace-break.c: Likewise. * gdb.trace/trace-mt.c (thread_function): Likewise. * gdb.trace/ftrace.c (marker): Likewise. * gdb.trace/trace-condition.c (marker): Likewise. * gdb.trace/ftrace.exp: Enable ftrace test if is_aarch64_target. * gdb.trace/trace-condition.exp: Set pcreg to "\$pc" if is_aarch64_target.
2015-09-18default_read_var_value <LOC_UNRESOLVED>: Include minsym kind in error message.Doug Evans3-0/+88
bfd/ChangeLog: * targets.c (enum bfd_flavour): Add comment. (bfd_flavour_name): New function. * bfd-in2.h: Regenerate. gdb/ChangeLog: * findvar.c (default_read_var_value) <LOC_UNRESOLVED>: Include the kind of minimal symbol in the error message. * objfiles.c (objfile_flavour_name): New function. * objfiles.h (objfile_flavour_name): Declare. gdb/testsuite/ChangeLog: * gdb.dwarf2/dw2-bad-unresolved.c: New file. * gdb.dwarf2/dw2-bad-unresolved.exp: New file.
2015-09-18Fix directory prefix in gdb.base/dso2dso.exp.Sandra Loosemore2-1/+6
2015-09-18 Sandra Loosemore <sandra@codesourcery.com> gdb/testsuite/ * gdb.base/dso2dso.exp: Don't use directory prefix when setting the breakpoint.
2015-09-18Fix pathname prefix and timeout issues in gdb.mi/mi-pending.exp.Sandra Loosemore2-3/+9
2015-09-18 Sandra Loosemore <sandra@codesourcery.com> gdb/testsuite/ * gdb.mi/mi-pending.exp: Don't use directory prefix when setting the pending breakpoint. Remove timeout override for "Run till MI pending breakpoint on pendfunc3 on thread 2" test.
2015-09-18Generalize breakpoint pattern in gdb.mi/mi-cli.exp.Sandra Loosemore2-1/+6
2015-09-18 Sandra Loosemore <sandra@codesourcery.com> gdb/testsuite/ * gdb.mi/mi-cli.exp: Don't require directory prefix in breakpoint filename pattern.
2015-09-18Generalize filename pattern in gdb.mi/mi-dprintf-pending.exp.Sandra Loosemore2-1/+6
2015-09-18 Sandra Loosemore <sandra@codesourcery.com> gdb/testsuite/ * gdb.mi/mi-dprintf-pending.exp: Don't require directory prefix in breakpoint filename pattern.
2015-09-18Fix shared library load in gdb.base/global-var-nested-by-dso.exp.Sandra Loosemore2-1/+5
2015-09-18 Sandra Loosemore <sandra@codesourcery.com> gdb/testsuite/ * gdb.base/global-var-nested-by-dso.exp: Call gdb_load_shlibs.
2015-09-18Require readline for gdb.linespec/explicit.exp tab-completion tests.Sandra Loosemore2-135/+148
2015-09-18 Sandra Loosemore <sandra@codesourcery.com> gdb/testsuite/ * gdb.linespec/explicit.exp: Check for readline support for tab-completion tests. Fix obvious typo.
2015-09-18btrace: honour scheduler-locking for all-stop targetsMarkus Metzger2-74/+158
In all-stop mode, record btrace maintains the old behaviour of an implicit scheduler-locking on. Now that we added a scheduler-locking mode to model this old behaviour, we don't need the respective code in record btrace anymore. Remove it. For all-stop targets, step inferior_ptid and continue other threads matching the argument ptid. Assert that inferior_ptid matches the argument ptid. This should make record btrace honour scheduler-locking. gdb/ * record-btrace.c (record_btrace_resume): Honour scheduler-locking. testsuite/ * gdb.btrace/multi-thread-step.exp: Test scheduler-locking on, step, and replay.
2015-09-18btrace: non-stopMarkus Metzger3-0/+295
Support non-stop mode in record btrace. gdb/ * record-btrace.c (record_btrace_open): Remove non_stop check. * NEWS: Announce that record btrace supports non-stop mode. testsuite/ * gdb.btrace/non-stop.c: New. * gdb.btrace/non-stop.exp: New.
2015-09-17Add test case for tracepoints with conditionsPierre Langlois3-0/+240
This patch adds a test case for tracepoints with a condition expression. Each case will test a condition against the number of frames that should have been traced. Some of these tests fail on x86_64 and others on i386, which have been marked as known failures for now, see PR/18955. gdb/testsuite/ChangeLog: 2015-09-17 Pierre Langlois <pierre.langlois@arm.com> Yao Qi <yao.qi@linaro.org> * gdb.trace/trace-condition.c: New file. * gdb.trace/trace-condition.exp: New file.
2015-09-16Fix argument to compiled_cond, and add cases for compiled-condition.Wei-cheng Wang2-0/+69
This patch fixes the argument passed to compiled_cond. It should be regs buffer instead of tracepoint_hit_ctx. Test case is added as well for testing compiled-cond. gdb/gdbserver/ChangeLog 2015-09-16 Wei-cheng Wang <cole945@gmail.com> * tracepoint.c (eval_result_type): Change prototype. (condition_true_at_tracepoint): Fix argument to compiled_cond. gdb/testsuite/ChangeLog 2015-09-16 Wei-cheng Wang <cole945@gmail.com> * gdb.trace/ftrace.exp: (test_ftrace_condition) New function for testing bytecode compilation.
2015-09-16non-stop-fair-events.exp slower on software single-step && !displ-step targetsPedro Alves4-38/+96
On software single-step targets that don't support displaced stepping, threads keep hitting each other's single-step breakpoints, and then GDB needs to pause all threads to step past those. The end result is that progress in the main thread will be slower and it may take a bit longer for the signal to be queued. This patch bumps the timeout on such targets. gdb/testsuite/ChangeLog: 2015-09-16 Pedro Alves <palves@redhat.com> Sandra Loosemore <sandra@codesourcery.com> * gdb.threads/non-stop-fair-events.c (timeout): New global. (SECONDS): Redefine. (main): Call pthread_kill and alarm early. * gdb.threads/non-stop-fair-events.exp: Probe displaced stepping support. (test): If the target can't hardware step and doesn't support displaced stepping, increase the timeout.
2015-09-16Make it easier to debug non-stop-fair-events.expPedro Alves2-3/+61
If we enable infrun debug running this test, it quickly fails with a full expect buffer. That can be simply handled with a couple exp_continues. As it's annoying to hack this every time we need to debug the test, this patch adds bits to enable debugging support easily, with a one-line change. And then, if any iteration of the test fails, we end up with a long cascade of time outs. Just bail out when we see the first fail. gdb/testsuite/ 2015-09-16 Pedro Alves <palves@redhat.com> * gdb.threads/non-stop-fair-events.exp (gdb_test_no_anchor) (enable_debug): New procedures. (test): Use them. Bail out if waiting for threads fails. (top level): Bail out if a test fails.
2015-09-16Don't skip gdb.asm/asm-source.exp on aarch64Yao Qi3-0/+43
This patch adds gdb.asm/aarch64.inc, so asm-source.exp isn't skipped on aarch64 any more. gdb/testsuite: 2015-09-16 Yao Qi <yao.qi@linaro.org> * gdb.asm/asm-source.exp: Set asm-arch for aarch64*-*-* target. * gdb.asm/aarch64.inc: New file.
2015-09-15[Ada] Enhance type printing for arrays with variable-sized elementsPierre-Marie de Rodat5-0/+127
This change is relevant only for standard DWARF (as opposed to the GNAT encodings extensions): at the time of writing it only makes a difference with GCC patches that are to be integrated: see the patch series submission at <https://gcc.gnu.org/ml/gcc-patches/2015-07/msg01353.html>. Given the following Ada declarations: subtype Small_Int is Natural range 0 .. 100; type R_Type (L : Small_Int := 0) is record S : String (1 .. L); end record; type A_Type is array (Natural range <>) of R_Type; A : A_Type := (1 => (L => 0, S => ""), 2 => (L => 2, S => "ab")); Before this change, we would get the following GDB session: (gdb) ptype a type = array (1 .. 2) of foo.r_type <packed: 838-bit elements> This is wrong: "a" is not a packed array. This output comes from the fact that, because R_Type has a dynamic size (with a maximum), the compiler has to describe in the debugging information the size allocated for each array element (i.e. the stride, in DWARF parlance: see DW_AT_byte_stride). Ada type printing currently assumes that arrays with a stride are packed, hence the above output. In practice, GNAT never performs bit-packing for arrays that contain variable-sized elements. Leveraging this fact, this patch enhances type printing so that ptype does not pretend that arrays are packed when they have a stride and they contain dynamic elements. After this change, we get the following expected output: (gdb) ptype a type = array (1 .. 2) of foo.r_type gdb/ChangeLog: * ada-typeprint.c (print_array_type): Do not describe arrays as packed when they embed dynamic elements. gdb/testsuite/ChangeLog: * gdb.ada/array_of_variable_length.exp: New testcase. * gdb.ada/array_of_variable_length/foo.adb: New file. * gdb.ada/array_of_variable_length/pck.adb: New file. * gdb.ada/array_of_variable_length/pck.ads: New file. Tested on x86_64-linux, no regression.
2015-09-15Handle clang naming of function static local variable.Doug Evans2-1/+6
clang names the local variable t_structs_a.buf. gdb/testsuite/ChangeLog: * gdb.base/callfuncs.exp (do_function_calls): Handle clang naming of function static local variable.
2015-09-15Fix PR/18564 - regression in showing __thread so extern variablePhilippe Waroquiers4-0/+153
Ensure tls variable address is not relocated, as the msym addr is an offset in the thread local storage of the shared library/object.
2015-09-15[ppc64le] Use skip_entrypoint for skip_trampoline_codeJan Kratochvil4-0/+147
ppc64le loses control when stepping between two PLT-called functions inside a shared library: 29 shlib_second (); /* first-hit */^M (gdb) PASS: gdb.base/solib-intra-step.exp: first-hit step^M ^M Program received signal SIGABRT, Aborted.^M 0x00003fffb7cbe578 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56^M 56 return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);^M (gdb) FAIL: gdb.base/solib-intra-step.exp: second-hit -> 29 shlib_second (); /* first-hit */^M (gdb) PASS: gdb.base/solib-intra-step.exp: first-hit step^M shlib_second () at ./gdb.base/solib-intra-step-lib.c:23^M 23 abort (); /* second-hit */^M (gdb) PASS: gdb.base/solib-intra-step.exp: second-hit This is because gdbarch_skip_trampoline_code() will resolve the final function as shlib_second+0 and place there the breakpoint, but ld.so will jump after the breakpoint - at shlib_second+8 - as it is ELFv2 local symbol optimization: Dump of assembler code for function shlib_second: 0x0000000000000804 <+0>: addis r2,r12,2 0x0000000000000808 <+4>: addi r2,r2,30668 0x000000000000080c <+8>: mflr r0 Currently gdbarch_skip_entrypoint() has been called in skip_prologue_sal() and fill_in_stop_func() but that is not enough. I believe gdbarch_skip_entrypoint() should be called after every gdbarch_skip_trampoline_code(). gdb/ChangeLog 2015-09-15 Jan Kratochvil <jan.kratochvil@redhat.com> * linespec.c (minsym_found): Call gdbarch_skip_entrypoint. * ppc64-tdep.c (ppc64_skip_trampoline_code): Rename to ... (ppc64_skip_trampoline_code_1): ... here. (ppc64_skip_trampoline_code): New wrapper function. * symtab.c (find_function_start_sal): Call gdbarch_skip_entrypoint. gdb/testsuite/ChangeLog 2015-09-15 Jan Kratochvil <jan.kratochvil@redhat.com> * gdb.opt/solib-intra-step-lib.c: New file. * gdb.opt/solib-intra-step-main.c: New file. * gdb.opt/solib-intra-step.exp: New file.
2015-09-15Fix gdb.threads/non-ldr-exc-3.exp racePedro Alves2-5/+6
gdb.threads/non-ldr-exc-3.exp is sometimes failing like this: [Switching to Thread 6831.6832] Breakpoint 2, thread_execler (arg=0x0) at /home/pedro/gdb/mygit/build/../src/gdb/testsuite/gdb.threads/non-ldr-exc-3.c:41 41 if (execl (image, image, argv1, NULL) == -1) /* break-here */ PASS: gdb.threads/non-ldr-exc-3.exp: lock-sched=on,non-stop=off: continue to breakpoint (gdb) set scheduler-locking on (gdb) FAIL: gdb.threads/non-ldr-exc-3.exp: lock-sched=on,non-stop=off: set scheduler-locking on The problem is that the gdb_test_multiple is missing the prompt anchor. The problem was introduced by 2fd33e9448. This reverts the hunk that introduced the problem, reverting back to gdb_continue_to_breakpoint. gdb/testsuite/ChangeLog: 2015-09-15 Pedro Alves <palves@redhat.com> * gdb.threads/non-ldr-exc-3.exp (do_test): Use gdb_continue_to_breakpoint instead of gdb_test_multiple.
2015-09-14Bail out of processing stop if hook-stop resumes target / changes contextPedro Alves6-142/+183
This patch, relative to a tree with https://sourceware.org/ml/gdb-patches/2015-08/msg00295.html, fixes issues/crashes that trigger if something unexpected happens during a hook-stop. E.g., if the inferior disappears while running the hook-stop, we hit failed assertions: (gdb) define hook-stop Type commands for definition of "hook-stop". End with a line saying just "end". >kill >end (gdb) si Kill the program being debugged? (y or n) [answered Y; input not from terminal] /home/pedro/gdb/mygit/build/../src/gdb/thread.c:88: internal-error: inferior_thread: Assertion `tp' failed. A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) I noticed that if a hook-stop issues a synchronous execution command, we print the same stop event twice: (gdb) define hook-stop Type commands for definition of "hook-stop". End with a line saying just "end". >si >end (gdb) si 0x000000000040074a 42 args[i] = 1; /* Init value. */ <<<<<<< once 0x000000000040074a 42 args[i] = 1; /* Init value. */ <<<<<<< twice (gdb) In MI: *stopped,reason="end-stepping-range",frame={addr="0x000000000040074a",func="main",args=[],file="threads.c",fullname="/home/pedro/gdb/tests/threads.c",line="42"},thread-id="1",stopped-threads="all",core="0" *stopped,reason="end-stepping-range",frame={addr="0x000000000040074a",func="main",args=[],file="threads.c",fullname="/home/pedro/gdb/tests/threads.c",line="42"},thread-id="1",stopped-threads="all",core="0" (gdb) The fix has GDB stop processing the event if the context changed. I don't expect people to be doing crazy things from the hook-stop. E.g., it gives me headaches to try to come up a proper behavior for handling a thread change from a hook-stop... (E.g., imagine the hook-stop does thread N; step, with scheduler-locing on). I think the most important bit here is preventing crashes. The patch adds a new hook-stop.exp test that covers the above and also merges in the old hook-stop-continue.exp and hook-stop-frame.exp into the same framework. gdb/ChangeLog: 2015-09-14 Pedro Alves <palves@redhat.com> * infrun.c (current_stop_id): New global. (get_stop_id, new_stop_id): New functions. (fetch_inferior_event): Handle normal_stop proceeding the target. (struct stop_context): New. (save_stop_context, release_stop_context_cleanup) (stop_context_changed): New functions. (normal_stop): Return true if the hook-stop changes the stop context. * infrun.h (get_stop_id): Declare. (normal_stop): Now returns int. Add documentation. gdb/testsuite/ChangeLog: 2015-09-14 Pedro Alves <palves@redhat.com> * gdb.base/hook-stop-continue.c: Delete. * gdb.base/hook-stop-continue.exp: Delete. * gdb.base/hook-stop-frame.c: Delete. * gdb.base/hook-stop-frame.exp: Delete. * gdb.base/hook-stop.c: New file. * gdb.base/hook-stop.exp: New file.
2015-09-14[Ada] Fix the evaluation of access to packed array subscriptPierre-Marie de Rodat5-0/+113
This change is relevant only for standard DWARF (as opposed to the GNAT encodings extensions): at the time of writing it only makes a difference with GCC patches that are to be integrated: see in particular <https://gcc.gnu.org/ml/gcc-patches/2015-07/msg01364.html>. Given the following Ada declarations: type Small is mod 2 ** 6; type Array_Type is array (0 .. 9) of Small with Pack; type Array_Access is access all Array_Type; A : aliased Array_Type := (1, 2, 3, 4, 5, 6, 7, 8, 9, 10); AA : constant Array_Type := A'Access; Before this change, we would get the following GDB session: (gdb) print aa.all(2) $1 = 3 (gdb) print aa(2) $2 = 16 This is wrong: both expression should yield the same value: 3. The problem is simply that the routine which handles accesses to arrays lack general handling for packed arrays. After this patch, we have the expected output: (gdb) print aa.all(2) $1 = 3 (gdb) print aa(2) $2 = 3 gdb/ChangeLog: * ada-lang.c (ada_value_ptr_subscript): Update the heading comment. Handle packed arrays. gdb/testsuite/ChangeLog: * gdb.ada/access_to_packed_array.exp: New testcase. * gdb.ada/access_to_packed_array/foo.adb: New file. * gdb.ada/access_to_packed_array/pack.adb: New file. * gdb.ada/access_to_packed_array/pack.ads: New file. Tested on x86_64-linux, no regression.
2015-09-14btrace, test: remove buffer-size test with unlimited buffer sizeMarkus Metzger2-11/+6
The gdb.btrace/buffer-size.exp test starts recording with an unlimited buffer size. This will, for a short time, use up most if not all BTS resources. I don' think this test is necessary. Remove it. testsuite/ * gdb.btrace/buffer-size.exp: Remove recording with unlimited BTS buffer size test.
2015-09-11Extended-remote exec testDon Breazeal9-103/+178
This patch updates several exec-related tests and some of the library functions in order to get them running with extended-remote. There were three changes that were required, as follows: In gdb.base/foll-exec.exp, use 'clean_start' in place of proc 'zap_session' to reset the state of the debugger between tests. This sets 'remote exec-file' to execute the correct binary file in each subsequent test. In gdb.base/pie-execl.exp, there is an expect statement with an expression that is used to match output from both gdb and the program under debug. For the remote target, this had to be split into two expressions, using $inferior_spawn_id to match the output from the program. Because I had encountered problems with extended-remote exec events in non-stop mode in my manual testing, I added non-stop testing to the non-ldr-exc-[1234].exp tests. In order to set non-stop mode for remote targets, it is necessary to 'set non-stop on' after gdb has started, but before it connects to gdbserver. This is done using 'save_vars' to set non-stop mode in GDBFLAGS, so GDB sets non-stop mode on startup. gdb/testsuite/ChangeLog: * gdb.base/foll-exec.c: Add copyright header. Fix formatting issues. * gdb.base/foll-exec.exp (zap_session): Delete proc. (do_exec_tests): Use clean_restart in place of zap_session, and for test initialization. Fix formatting issues. Use fail in place of perror. * gdb.base/pie-execl.exp (main): Use 'inferior_spawn_id' in an expect statement to match an expression with output from the program under debug. * gdb.threads/non-ldr-exc-1.exp (do_test, main): Add non-stop tests and pass stop mode argument to clean_restart. Use save_vars to enable non-stop in GDBFLAGS. * gdb.threads/non-ldr-exc-2.exp: Likewise. * gdb.threads/non-ldr-exc-3.exp: Likewise. * gdb.threads/non-ldr-exc-4.exp: Likewise.
2015-09-09* gdb.python/py-prettyprint.exp: Check result of run_lang_tests.Doug Evans2-2/+10
gdb/testsuite/ChangeLog: * gdb.python/py-prettyprint.exp: Check result of run_lang_tests.
2015-09-09* gdb.base/pie-execl.exp: Fix result test of build_executable.Doug Evans2-2/+6
gdb/testsuite/ChangeLog: * gdb.base/pie-execl.exp: Fix result test of build_executable.
2015-09-09* gdb.base/savedregs.exp: Fix typo.Doug Evans2-1/+5
gdb/testsuite/ChangeLog: * gdb.base/savedregs.exp: Fix typo.
2015-09-09Replace "struct continuation" mechanism by something more extensiblePedro Alves2-0/+22
This adds an object oriented replacement for the "struct continuation" mechanism, and converts the stepping commands (step, next, stepi, nexti) and the "finish" commands to use it. It adds a new thread "class" (struct thread_fsm) that contains the necessary info and callbacks to manage the state machine of a thread's execution command. This allows getting rid of some hacks. E.g., in fetch_inferior_event and normal_stop we no longer need to know whether a thread is doing a multi-step (e.g., step N). This effectively makes the intermediate_continuations unused -- they'll be garbage collected in a separate patch. (They were never a proper abstraction, IMO. See how fetch_inferior_event needs to check step_multi before knowing whether to call INF_EXEC_CONTINUE or INF_EXEC_COMPLETE.) The target async vs !async uiout hacks in mi_on_normal_stop go away too. print_stop_event is no longer called from normal_stop. Instead it is now called from within each interpreter's normal_stop observer. This clears the path to make each interpreter print a stop event the way it sees fit. Currently we have some hacks in common code to differenciate CLI vs TUI vs MI around this area. The "finish" command's FSM class stores the return value plus that value's position in the value history, so that those can be printed to both MI and CLI's streams. This fixes the CLI "finish" command when run from MI -- it now also includes the function's return value in the CLI stream: (gdb) ~"callee3 (strarg=0x400730 \"A string argument.\") at src/gdb/testsuite/gdb.mi/basics.c:35\n" ~"35\t}\n" +~"Value returned is $1 = 0\n" *stopped,reason="function-finished",frame=...,gdb-result-var="$1",return-value="0",thread-id="1",stopped-threads="all",core="0" -FAIL: gdb.mi/mi-cli.exp: CLI finish: check CLI output +PASS: gdb.mi/mi-cli.exp: CLI finish: check CLI output gdb/ChangeLog: 2015-09-09 Pedro Alves <palves@redhat.com> * Makefile.in (COMMON_OBS): Add thread-fsm.o. * breakpoint.c (handle_jit_event): Print debug output. (bpstat_what): Split event callback handling to ... (bpstat_run_callbacks): ... this new function. (momentary_bkpt_print_it): No longer handle bp_finish here. * breakpoint.h (bpstat_run_callbacks): Declare. * gdbthread.h (struct thread_info) <step_multi>: Delete field. <thread_fsm>: New field. (thread_cancel_execution_command): Declare. * infcmd.c: Include thread-fsm.h. (struct step_command_fsm): New. (step_command_fsm_ops): New global. (new_step_command_fsm, step_command_fsm_prepare): New functions. (step_1): Adjust to use step_command_fsm_prepare and prepare_one_step. (struct step_1_continuation_args): Delete. (step_1_continuation): Delete. (step_command_fsm_should_stop): New function. (step_once): Delete. (step_command_fsm_clean_up, step_command_fsm_async_reply_reason) (prepare_one_step): New function, based on step_once. (until_next_command): Remove step_multi reference. (struct return_value_info): New. (print_return_value): Rename to ... (print_return_value_1): ... this. New struct return_value_info parameter. Adjust. (print_return_value): Reimplement as wrapper around print_return_value_1. (struct finish_command_fsm): New. (finish_command_continuation): Delete. (finish_command_fsm_ops): New global. (new_finish_command_fsm, finish_command_fsm_should_stop): New functions. (finish_command_fsm_clean_up, finish_command_fsm_return_value): New. (finish_command_continuation_free_arg): Delete. (finish_command_fsm_async_reply_reason): New. (finish_backward, finish_forward): Change symbol parameter to a finish_command_fsm. Adjust. (finish_command): Create a finish_command_fsm. Adjust. * infrun.c: Include "thread-fsm.h". (clear_proceed_status_thread): Delete the thread's FSM. (infrun_thread_stop_requested_callback): Cancel the thread's execution command. (clean_up_just_stopped_threads_fsms): New function. (fetch_inferior_event): Handle the event_thread's should_stop method saying the command isn't done yet. (process_event_stop_test): Run breakpoint callbacks here. (print_stop_event): Rename to ... (print_stop_location): ... this. (restore_current_uiout_cleanup): New function. (print_stop_event): Reimplement. (normal_stop): No longer notify the end_stepping_range observers here handle "step N" nor "finish" here. No longer call print_stop_event here. * infrun.h (struct return_value_info): Forward declare. (print_return_value): Declare. (print_stop_event): Change prototype. * thread-fsm.c: New file. * thread-fsm.h: New file. * thread.c: Include "thread-fsm.h". (thread_cancel_execution_command): New function. (clear_thread_inferior_resources): Call it. * cli/cli-interp.c (cli_on_normal_stop): New function. (cli_interpreter_init): Install cli_on_normal_stop as normal_stop observer. * mi/mi-interp.c: Include "thread-fsm.h". (restore_current_uiout_cleanup): Delete. (mi_on_normal_stop): If the thread has an FSM associated, and it finished, ask it for the async-reply-reason to print. Always call print_stop_event here, regardless of the top-level interpreter. Check bpstat_what to tell whether an asynchronous breakpoint hit triggered. * tui/tui-interp.c (tui_on_normal_stop): New function. (tui_init): Install tui_on_normal_stop as normal_stop observer. gdb/testsuite/ChangeLog: 2015-09-09 Pedro Alves <palves@redhat.com> * gdb.mi/mi-cli.exp: Add CLI finish tests.
2015-09-08Improve hand-call-in-threads.exp failure handling.Sandra Loosemore2-3/+24
2015-09-08 Sandra Loosemore <sandra@codesourcery.com> gdb/testsuite/ * gdb.threads/hand-call-in-threads.exp: Make sure the thread command actually switches threads. Give up on remaining tests if target fails to stop at breakpoint.
2015-09-03[Ada] Make string_char_type a true TYPE_CODE_CHAR type in AdaPierre-Marie de Rodat3-0/+70
Before this change, trying to call an overloaded function with at least one character literal in argument would fail. For instance, given these two functions: function F (C : Character) return Integer is begin return Character'Pos (C); end F; function F (I : Integer) return Integer is begin return -I; end F; We would get the following GDB session: (gdb) p f('A') $1 = -65 (gdb) p f(1) $1 = -1 This is wrong because the first call should select the first F function and thus return 65. The root problem is that ada-lang.c:ada_language_arch_info stores in string_char_type a type whose code is TYPE_CODE_INT instead of TYPE_CODE_CHAR. As a result, all parsed character literals are turned into integer values and during overload matching, the TYPE_CODE_CHAR formal rejects the TYPE_CODE_INT actual. This change turns string_char_type into a true TYPE_CODE_CHAR type in ada-lang.c so that we have instead the expected: (gdb) p f('A') $1 = 65 gdb/ChangeLog: * ada-lang.c (ada_language_arch_info): Create a TYPE_CODE_CHAR type instead of a TYPE_CODE_INT one for the string_char_type and the ada_primitive_type_char types. gdb/testsuite/ChangeLog: * gdb.ada/funcall_char.exp: New testcase. * gdb.ada/funcall_char/foo.adb: New file. Tested on x86_64-linux, no regression.
2015-09-01[Ada] Fix completion for multiple function matchesPierre-Marie de Rodat7-1/+86
Before this change, trying to complete an expression ending with an ambiguous function name (i.e. for which there are multiple matches) would display a menu with a prompt for the user to pick one. For instance: (gdb) p func<tab>Multiple matches for func [0] cancel [1] pack2.func at pack2.adb:5 [2] pack.func at pack.adb:5 > This is not user friendly and actually triggered a segmentation fault after the user did pick one. It is not clear whether the segmentation fault needs a separate fix, but this is the only known case which exhibits it at the moment, and this case must be fixed itself. The problem lies in ada-lang.c (ada_resolve_function): when we got multiple matches, we should not display the menu if we are in completion mode. This patch adjusts the corresponding condition accordingly. gdb/ChangeLog: * ada-lang.c (ada_resolve_function): Do not ask the user what match to use when in completion mode. gdb/testsuite/ChangeLog: * gdb.ada/complete.exp: Add "pck.ambiguous_func" to the relevant expected outputs. Add two testcases for completing ambiguous functions. * gdb.ada/complete/aux_pck.adb: New file. * gdb.ada/complete/aux_pck.ads: New file. * gdb.ada/complete/foo.adb: Pull Aux_Pck and call the two Ambiguous_Func functions. * gdb.ada/complete/pck.ads: Add an Ambiguous_Func function. * gdb.ada/complete/pck.adb: Likewise. Tested on x86_64-linux, no regression.
2015-08-27Report UNRESOLVED on failures while detecting Cell/B.E.Ulrich Weigand2-1/+6
The gdb.cell testcases use the predicate skip_cell_tests defined in lib/cell.exp to determine whether Cell/B.E. test cases ought to be run. This tests verifies that we have a toolchain that supports generating combined Cell/B.E. binaries, and that the target machine actually is a Cell/B.E. In order to do so, a small test program is built and run (under the debugger). Any failure is taken as a sign that we don't have a Cell/B.E. machine and the tests are to be skipped. This has the unfortunate effect that a serious bug in GDB that causes internal compiler errors even on the trivial test program does not lead to any failures in the testsuite, since now all gdb.cell test are simply skipped. This patch changes skip_cell_tests to at least report UNRESOLVED in cases where execution of the test program fails in unexpected ways. testsuite/ChangeLog: * lib/cell.exp (skip_cell_tests): Report UNRESOLVED on unexpected failures to run the test program under GDB.
2015-08-27Force language to C in gdb.compile/compile-ifunc.expLuis Machado2-0/+11
Due to the lack of debug information in the binary, GDB is unable to figure out what language is being used. This may be a problem when doing remote debugging and the binary stops at the entry point containing asm code. In this case GDB will switch to asm as current language and will not switch back to C when it reaches main, which in turn causes the compile feature check to malfunction. This is solved by forcing the language to C after reaching main. gdb/testsuite/ChangeLog: 2015-08-26 Luis Machado <lgustavo@codesourcery.com> * gdb.compile/compile-ifunc.exp (with_test_prefix): Force language to C.
2015-08-26Unset attach_flag when running a new processPatrick Palka3-0/+92
We currently set attach_flag when attaching to a process, so we should make sure to unset it when forking a new process. Otherwise attach_flag would remain set after forking, if the previous process associated with the inferior was attached to. gdb/ChangeLog: * target.c (target_pre_inferior): Unset attach_flag. gdb/testsuite/ChangeLog: * gdb.base/run-after-attach.exp: New test file. * gdb.base/run-after-attach.c: New test file.
2015-08-26New test for follow-exec-modeDon Breazeal3-0/+242
This patch implements a new GDB test for follow-exec-mode. Although there is a GDB test for debugging across an exec, there is no test for follow-exec-mode. This test is derived from gdb.base/foll-exec.exp, and re-uses execd-prog.c as the program to exec. The following behavior is tested: follow-exec-mode == "same" - 'next' over the exec, check for one inferior - 'continue' past the exec to a breakpoint, check for one inferior - after the exec, use a 'run' command to run the current binary follow-exec-mode == "new" - 'next' over the exec, check for two inferiors - 'continue' past the exec to a breakpoint, check for two inferiors - after the exec, use a 'run' command to run the current binary - after the exec, use the 'inferior' command to switch inferiors, then use a 'run' command to run the current binary Note that single-step breakpoints do not survive across an exec. There has to be a breakpoint in the execed program in order for it to stop right after the exec. gdb/testsuite/ChangeLog: * gdb.base/foll-exec-2.c: New test program. * gdb.base/foll-exec-2.exp: New test.
2015-08-25DWARF: handle non-local references in nested functionsPierre-Marie de Rodat7-0/+334
GDB's current behavior when dealing with non-local references in the context of nested fuctions is approximative: - code using valops.c:value_of_variable read the first available stack frame that holds the corresponding variable (whereas there can be multiple candidates for this); - code directly relying on read_var_value will instead read non-local variables in frames where they are not even defined. This change adds the necessary context to symbol reads (to get the block they belong to) and to blocks (the static link property, if any) so that GDB can make the proper decisions when dealing with non-local varibale references. gdb/ChangeLog: * ada-lang.c (ada_read_var_value): Add a var_block argument and pass it to default_read_var_value. * block.c (block_static_link): New accessor. * block.h (block_static_link): Declare it. * buildsym.c (finish_block_internal): Add a static_link argument. If there is a static link, associate it to the new block. (finish_block): Add a static link argument and pass it to finish_block_internal. (end_symtab_get_static_block): Update calls to finish_block and to finish_block_internal. (end_symtab_with_blockvector): Update call to finish_block_internal. * buildsym.h: Forward-declare struct dynamic_prop. (struct context_stack): Add a static_link field. (finish_block): Add a static link argument. * c-exp.y: Remove an obsolete comment (evaluation of variables already start from the selected frame, and now they climb *up* the call stack) and propagate the block information to the produced expression. * d-exp.y: Likewise. * f-exp.y: Likewise. * go-exp.y: Likewise. * jv-exp.y: Likewise. * m2-exp.y: Likewise. * p-exp.y: Likewise. * coffread.c (coff_symtab_read): Update calls to finish_block. * dbxread.c (process_one_symbol): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. * compile/compile-c-symbols.c (convert_one_symbol): Promote the "sym" parameter to struct block_symbol, update its uses and pass its block to calls to read_var_value. (convert_symbol_sym): Update the calls to convert_one_symbol. * compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Update call to read_var_value. * dwarf2loc.c (block_op_get_frame_base): New. (dwarf2_block_frame_base_locexpr_funcs): Implement the get_frame_base method. (dwarf2_block_frame_base_loclist_funcs): Likewise. (dwarf2locexpr_baton_eval): Add a frame argument and use it instead of the selected frame in order to evaluate the expression. (dwarf2_evaluate_property): Add a frame argument. Update call to dwarf2_locexpr_baton_eval to provide a frame in available and to handle the absence of address stack. * dwarf2loc.h (dwarf2_evaluate_property): Add a frame argument. * dwarf2read.c (attr_to_dynamic_prop): Add a forward declaration. (read_func_scope): Record any available static link description. Update call to finish_block. (read_lexical_block_scope): Update call to finish_block. * findvar.c (follow_static_link): New. (get_hosting_frame): New. (default_read_var_value): Add a var_block argument. Use get_hosting_frame to handle non-local references. (read_var_value): Add a var_block argument and pass it to the LA_READ_VAR_VALUE method. * gdbtypes.c (resolve_dynamic_range): Update calls to dwarf2_evaluate_property. (resolve_dynamic_type_internal): Likewise. * guile/scm-frame.c (gdbscm_frame_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * guile/scm-symbol.c (gdbscm_symbol_value): Update call to read_var_value (TODO). * infcmd.c (finish_command_continuation): Update call to read_var_value, passing it the block coming from symbol lookup. * infrun.c (insert_exception_resume_breakpoint): Likewise. * language.h (struct language_defn): Add a var_block argument to the LA_READ_VAR_VALUE method. * objfiles.c (struct static_link_htab_entry): New. (static_link_htab_entry_hash): New. (static_link_htab_entry_eq): New. (objfile_register_static_link): New. (objfile_lookup_static_link): New. (free_objfile): Free the STATIC_LINKS hashed map if needed. * objfiles.h: Include hashtab.h. (struct objfile): Add a static_links field. (objfile_register_static_link): New. (objfile_lookup_static_link): New. * printcmd.c (print_variable_and_value): Update call to read_var_value. * python/py-finishbreakpoint.c (bpfinishpy_init): Likewise. * python/py-frame.c (frapy_read_var): Update call to read_var_value, passing it the block coming from symbol lookup. * python/py-framefilter.c (extract_sym): Add a sym_block parameter and set the pointed value to NULL (TODO). (enumerate_args): Update call to extract_sym. (enumerate_locals): Update calls to extract_sym and to read_var_value. * python/py-symbol.c (sympy_value): Update call to read_var_value (TODO). * stack.c (read_frame_local): Update call to read_var_value. (read_frame_arg): Likewise. (return_command): Likewise. * symtab.h (struct symbol_block_ops): Add a get_frame_base method. (struct symbol): Add a block field. (SYMBOL_BLOCK): New accessor. * valops.c (value_of_variable): Remove frame/block handling and pass the block argument to read_var_value, which does this job now. (value_struct_elt_for_reference): Update calls to read_var_value. (value_of_this): Pass the block found to read_var_value. * value.h (read_var_value): Add a var_block argument. (default_read_var_value): Likewise. gdb/testsuite/ChangeLog: * gdb.base/nested-subp1.exp: New file. * gdb.base/nested-subp1.c: New file. * gdb.base/nested-subp2.exp: New file. * gdb.base/nested-subp2.c: New file. * gdb.base/nested-subp3.exp: New file. * gdb.base/nested-subp3.c: New file.
2015-08-24gdbserver crashes when multiprocess extensions aren't supportedPedro Alves3-0/+88
Ref: https://sourceware.org/ml/gdb-patches/2015-08/msg00675.html If multiprocess extensions are off (because specific gdbserver port doesn't support them), then when gdbserver doesn't have a thread selected yet, and GDB sends Hg packet to select one, gdbserver crashes. That's because extracting the desired thread id out of the packet that GDB sent depends on the current thread to fill in the missing process id ... Fix this by getting the process id from the first (and only) process in the processes list instead. The GNU/Linux port doesn't trip on this because it always runs with multiprocess extensions enabled. To make it easier to catch such regressions going forward, this commit also adds a new smoke test that spawns gdbserver, connects to it and runs to main with the multiprocess extensions force-disabled. gdb/gdbserver/ChangeLog: 2015-08-24 Pedro Alves <palves@redhat.com> * inferiors.c (get_first_process): New function. * inferiors.h (get_first_process): New declaration. * remote-utils.c (read_ptid): Default to the first process in the list, instead of to the current thread's process. gdb/testsuite/ChangeLog: 2015-08-24 Pedro Alves <palves@redhat.com> * gdb.server/connect-without-multi-process.c: New file. * gdb.server/connect-without-multi-process.exp: New file.
2015-08-24Make z intLuis Machado2-1/+5
This makes z an int for gdb/testsuite/gdb.opt/inline-markers.c. gdb/testsuite/ChangeLog: 2015-08-24 Luis Machado <lgustavo@codesourcery.com> * gdb.opt/inline-markers.c: Make z int.
2015-08-24Make z volatile.Luis Machado2-1/+6
This fixes a typo in gdb/testsuite/gdb.opt/inline-markers.c, making z a volatile variable. gdb/testsuite/ChangeLog: 2015-08-24 Luis Machado <lgustavo@codesourcery.com> * gdb.opt/inline-markers.c: Make z volatile.
2015-08-24Prevent GCC from folding inline test functionsLuis Machado5-3/+15
While doing some powerpc Linux tests on a ppc 476 board using GCC 5.2, i noticed inline-bt.exp, inline-cmds.exp and inline-locals.exp failing. FAIL: gdb.opt/inline-bt.exp: continue to bar (1) FAIL: gdb.opt/inline-bt.exp: backtrace from bar (1) FAIL: gdb.opt/inline-bt.exp: continue to bar (2) FAIL: gdb.opt/inline-bt.exp: backtrace from bar (2) FAIL: gdb.opt/inline-bt.exp: continue to bar (3) FAIL: gdb.opt/inline-bt.exp: backtrace from bar (3) FAIL: gdb.opt/inline-cmds.exp: continue to bar (1) FAIL: gdb.opt/inline-cmds.exp: backtrace from bar (1) FAIL: gdb.opt/inline-cmds.exp: continue to bar (2) FAIL: gdb.opt/inline-cmds.exp: backtrace from bar (2) FAIL: gdb.opt/inline-cmds.exp: continue to marker FAIL: gdb.opt/inline-cmds.exp: backtrace from marker FAIL: gdb.opt/inline-cmds.exp: step into finish marker FAIL: gdb.opt/inline-locals.exp: continue to bar (1) FAIL: gdb.opt/inline-locals.exp: continue to bar (2) FAIL: gdb.opt/inline-locals.exp: backtrace from bar (2) FAIL: gdb.opt/inline-locals.exp: continue to bar (3) FAIL: gdb.opt/inline-locals.exp: backtrace from bar (3) They failed because the breakpoint supposedly inserted at bar was actually inserted at noinline. (gdb) break inline-markers.c:20^M Breakpoint 2 at 0x1000079c: file gdb/testsuite/gdb.opt/inline-markers.c, line 20.^M (gdb) continue^M Continuing.^M ^M Breakpoint 2, noinline () at gdb/testsuite/gdb.opt/inline-markers.c:35^M 35 inlined_fn (); /* inlined */^M As we can see, line 20 is really inside bar, not noinline: 18 void bar(void) 19 { 20 x += y; /* set breakpoint 1 here */ 21 } Further investigation shows that this is really due to GCC 5's new ICF pass (-fipa-icf), now enabled by default at -O2, which folds bar and marker into noinline, where the call to inlined_fn was inlined. This breaks the testcase since it expects to stop at specific spots. I thought about two possible fixes for this issue. - Disable the ICF pass manually when building the binary (-fno-ipa-icf). This has the advantage of not having to touch the testcase sources themselves, but the disadvantage of having to add conditional blocks to test the GCC version. If we ever change GCC's default, we will have to adjust the conditional block again to match GCC's behavior. - Modify the testcase sources to make the identical functions unique. This solution doesn't touch the testcase itself, but changes the source code slightly in order to make bar, marker and inlined_fn unique. This causes GCC's ICF pass to ignore these functions and not fold them into a common identical function. I'm good with either of them, but i'm more inclined to go with the second one. The attached patch implements this by adding the new global variable z, set to 0, that gets added in different ways to marker and inlined_fn. Since it is 0, it doesn't affect any possible value checks that we may wish to do in the future (we currently only check for values changed by bar). Ok? ps: I also noticed GDB doesn't do a great job at stating that the breakpoint was actually inserted at a different source line than previously requested, so this sounds like a bug that should be fixed, if it is not just wrong DWARF information (did not investigate it further). gdb/testsuite/ChangeLog: 2015-08-24 Luis Machado <lgustavo@codesourcery.com> * gdb.opt/inline-bt.c: New volatile global z. * gdb.opt/inline-cmds.c: Likewise. * gdb.opt/inline-locals.c: Likewise. * gdb.opt/inline-markers.c: New extern global z. (marker): Use z. (inline_fn): Likewise.
2015-08-24gdb/testsuite/: garbage collect a few references to dead targetsPedro Alves7-49/+32
gdb/testsuite/ChangeLog: 2015-08-24 Pedro Alves <palves@redhat.com> * config/m32r-stub.exp: Remove file. * gdb.base/call-ar-st.exp: Remove reference to sparclet. * gdb.base/call-rt-st.exp: Likewise. * gdb.base/call-strs.exp: Likewise. * gdb.base/default.exp: Remove references to h8300-*-hms and *-*-udi*. * gdb.base/funcargs.exp: Remove reference to sparclet-*-*.
2015-08-24gnu_vector.exp: Avoid some more known FAILsAndreas Arnez2-13/+60
This avoids two more types of FAILs with the gnu_vector test case. First, for POWER targets newer GCCs emit an ABI note when invoked with "-mcpu=native". Then the test case fell back to non-native compile, producing code for a non-vector ABI. But that is not supported by GDB. Thus the compiler note is now suppressed with "-Wno-psabi". Second, on s390 the test case produced FAILs after falling back to a non-vector ABI when using "finish" or "return" in a vector-valued function. This was due to a long-standing known bug (Bug 8549). This case is now detected, and KFAILs are emitted instead. gdb/testsuite/ChangeLog: * gdb.base/gnu_vector.exp: Try compilation with "-mcpu=native -Wno-psabi" if "-mcpu=native" fails. For the tests with "finish" and "return" use KFAIL when GDB can not read/write the vector return value.
2015-08-21Warn when accessing binaries from remote targetsGary Benson2-4/+8
GDB provides no indicator of progress during file operations, and can appear to have locked up during slow remote transfers. This commit updates GDB to print a warning each time a file is accessed over RSP. An additional message detailing how to avoid remote transfers is printed for the first transfer only. gdb/ChangeLog: * target.h (struct target_ops) <to_fileio_open>: New argument warn_if_slow. Update comment. All implementations updated. (target_fileio_open_warn_if_slow): New declaration. * target.c (target_fileio_open): Renamed as... (target_fileio_open_1): ...this. New argument warn_if_slow. Pass warn_if_slow to implementation. Update debug printing. (target_fileio_open): New function. (target_fileio_open_warn_if_slow): Likewise. * gdb_bfd.c (gdb_bfd_iovec_fileio_open): Use new function target_fileio_open_warn_if_slow. gdb/testsuite/ChangeLog: * gdb.trace/pending.exp: Cope with remote transfer warnings.
2015-08-20Fix gdb.server/solib-list.exp native-extended-gdbserver regressionPedro Alves2-9/+5
Commit 221e1a37 (remote non-stop: Process initially stopped threads before other commands) caused a test regression when testing with the native-extended-gdbserver board: FAIL: gdb.server/solib-list.exp: non-stop 1: non-stop interior stop (timeout) This "interior stop" now happens before "target remote" prints the prompt, so we should no longer explicitly expect it. gdb/testsuite/ChangeLog: 2015-08-20 Pedro Alves <palves@redhat.com> * gdb.server/solib-list.exp: No longer expect an interior stop in non-stop mode.
2015-08-20remote non-stop: Process initially stopped threads before other commandsPedro Alves3-0/+109
The main motivation for this is making non-stop / all-stop behave similarly on initial connection, in order to move in the direction of reimplementing all-stop mode with the remote target always running in non-stop mode. When we connect to a remote target in non-stop mode, we may find threads either running or already stopped. The act of connecting itself does not force threads to stop. To handle that, the remote non-stop connection is currently roughly like this: #1 - Fetch list of remote threads (qXfer:threads:read, qfThreadInfo, etc). All threads are assumed to be running until the target reports an asynchronous stop reply for them. #2 - Fetch the initial set of threads that were already stopped, with the '?' packet. (In non-stop, this is coupled with the vStopped mechanism to be able to retrieve the status of more than one thread.) The stop replies fetched in #2 are placed in the pending stop reply queue, and left for the regular event loop to process. That is, "target remote" finishes and returns _before_ those stops are processed. That means that it's possible to have GDB process further commands before the initial set of stopped threads is reported to the user. E.g., before the patch, note how the prompt is printed before the frame: Remote debugging using :9999 (gdb) [Thread 15296] #1 stopped. 0x0000003615a011f0 in ?? () Even though thread #1 was not running, for a moment, the user can see it as such: $ gdb a.out -ex "set non-stop 1" -ex "tar rem :9999" -ex "info threads" -ex "info registers" Remote debugging using :9999 Id Target Id Frame * 1 Thread 4772 (running) Target is executing. <<<<<<< info registers (gdb) [Thread 4772] #1 stopped. 0x0000003615a011f0 in ?? () To fix that, this commit makes gdb process all threads found already stopped at connection time, before giving the prompt to the user. The fix takes a cue from fork-child.c:startup_inferior [1], and processes the events locally in remote.c, avoiding the whole wait_for_inferior/handle_inferior_event path. I decided to try this approach after noticing that: - several cases in handle_inferior_event miss checking stop_soon. - we don't want to fetch the thread list in normal_stop. and trying to fix them was resulting in sprinkling stop_soon checks in many places, and uglifying normal_stop even more. While with this patch, I'm avoiding changing GDB's output other than when the prompt is printed, I think this approach is more flexible if we do want to change it. And also, it's likely easier to get rid of the MI *running event that is still sent for threads that are initially found stopped, if we want to. This happens to fix the testsuite too. All non-stop tests are racy against "target remote" / gdbserver testing currently. That is, sometimes the tests run, but other times they're just skipped without any indication of PASS/FAIL. When that happens, the logs show: target remote localhost:2346 Remote debugging using localhost:2346 (gdb) [Thread 25418] #1 stopped. 0x0000003615a011f0 in ?? () ^CQuit (gdb) Remote debugging from host 127.0.0.1 Killing process(es): 25418 monitor exit (gdb) Remote connection closed (gdb) testcase /home/pedro/gdb/mygit/build/../src/gdb/testsuite/gdb.threads/multi-create-ns-info-thr.exp completed in 61 seconds The trouble here is that there's output after the prompt, and the regex in question doesn't expect that: -re "Remote debugging using .*$serialport_re.*$gdb_prompt $" { verbose "Set target to $targetname" return 0 } [1] - before startup_inferior was added, we'd go through wait_for_inferior/handle_inferior_event while going through the shell, and that turned out problematic. Tested on x86_64 Fedora 20, gdbserver. gdb/ChangeLog: 2015-08-20 Pedro Alves <palves@redhat.com> * infrun.c (print_target_wait_results): Make extern. * infrun.h (print_target_wait_results): Declare. * remote.c (set_stop_requested_callback): Delete. (process_initial_stop_replies): New function. (remote_start_remote): Use it. (stop_reply_queue_length): New function. gdb/testsuite/ChangeLog: 2015-08-20 Pedro Alves <palves@redhat.com> * gdb.server/connect-stopped-target.c: New file. * gdb.server/connect-stopped-target.exp: New file.
2015-08-20Fix language of compilation unit with unknown file extensionPedro Alves3-0/+119
Here, in dwarfread.c:process_full_comp_unit: /* Set symtab language to language from DW_AT_language. If the compilation is from a C file generated by language preprocessors, do not set the language if it was already deduced by start_subfile. */ if (!(cu->language == language_c && COMPUNIT_FILETABS (cust)->language != language_c)) COMPUNIT_FILETABS (cust)->language = cu->language; in case start_subfile doesn't manage to deduce a language COMPUNIT_FILETABS(cust)->language ends up as language_unknown, not language_c. So the condition above evals false and we never set the language from the cu's language. gdb/ChangeLog: 2015-08-20 Pedro Alves <palves@redhat.com> * dwarf2read.c (process_full_comp_unit): To tell whether start_subfile managed to deduce a language, test for language_unknown instead of language_c. gdb/testsuite/ChangeLog: 2015-08-20 Pedro Alves <palves@redhat.com> * gdb.dwarf2/comp-unit-lang.exp: New file. * gdb.dwarf2/comp-unit-lang.c: New file.
2015-08-20[Ada] Fix parsing for expressions with attributes and charactersPierre-Marie de Rodat3-0/+71
Before this change, trying to evaluate the following Ada expression yielded a syntax error, even though it's completely legal: (gdb) p s'first = 'a' Error in expression, near `'. The problem lies in the lexer (gdb/ada-lex.l): at the point we reach "'a'", we're still in the BEFORE_QUAL_QUOTE start condition (the mechanism to distinguish character literals from other "tick" usages: qualified expressions and attributes), so we consider that this quote is actually a separate "tick". This changes resets the start condition to INITIAL in the {TICK}[a-zA-Z][a-zA-Z]+ rule (for attributes): attributes activate this BEFORE_QUAL_QUOTE condition and in this case the above rule is always executed rather than the <BEFORE_QUAL_QUOTE>"'" one (in flex, it's always the longest match that is chosen). We now have instead: (gdb) p s'first = 'a' $1 = true gdb/ChangeLog: * ada-lex.l: Reset the start condition to INITIAL in the rule that matches attributes. gdb/testsuite/ChangeLog: * gdb.ada/attr_ref_and_charlit.exp: New testcase. * gdb.ada/attr_ref_and_charlit/foo.adb: New file. Tested on x86_64-linux, no regression.
2015-08-19dwarf2read.c: Check type of string valued attributes prior to decoding.Kevin Buettner3-0/+118
This change introduces a new function, dwarf2_string_attr(), which is a wrapper for dwarf2_attr(). dwarf2read.c has been updated to call dwarf2_string_attr in most instances where a string-valued attribute is decoded to produce a string value. In most cases, it simplifies the code; in some instances, the complexity of the code remains unchanged. I performed this change by looking for instances where the result of DW_STRING was used in an assignment. Many of these had a pattern which (roughly) looks something like this: struct attribute *attr = NULL; attr = dwarf2_attr (die, name, cu); if (attr != NULL && DW_STRING (attr)) { const char *str; ... str = DW_STRING (attr); ... /* Use str in some fashion. */ } Code of this form is transformed to look like this instead: const char *str; str = dwarf2_string_attr (die, name, cu) if (str != NULL) { ... /* Use str in some fashion. */ ... } In addition to invoking dwarf2_attr() and DW_STRING(), dwarf2_string_attr() checks to make sure that the attribute's `form' field matches one of DW_FORM_strp, DW_FORM_string, or DW_FORM_GNU_strp_alt. If it does not match one of these forms, it will return a NULL value in addition to calling complaint(). An earlier version of this patch did this type checking for one particular instance where a string attribute was being decoded. The situation that I was attempting to handle in that earlier patch is this: The Texas Instruments compiler uses the encoding for DW_AT_MIPS_linkage_name for other purposes. TI uses the encoding, 0x2007, for TI_AT_TI_end_line which, unlike DW_AT_MIPS_linkage_name, does not have a string-typed value. In this instance, GDB was attempting to use an integer value as a string pointer, with predictable results. (GDB would die with a segmentation fault.) I've added a test which reproduces the problem that I was orignally wanting to fix. It uses DW_AT_MIPS_linkage name with an associate value which is a string, and again, where the value is a small integer. My test case causes GDB to segfault in an unpatched GDB. There will be two PASSes in a patched GDB. Unpatched GDB: (gdb) ptype f ERROR: Process no longer exists UNRESOLVED: gdb.dwarf2/dw2-bad-mips-linkage-name.exp: ptype f ERROR: Couldn't send ptype g to GDB. UNRESOLVED: gdb.dwarf2/dw2-bad-mips-linkage-name.exp: ptype g Patched GDB: (gdb) ptype f type = bool () (gdb) PASS: gdb.dwarf2/dw2-bad-mips-linkage-name.exp: ptype f ptype g type = bool () (gdb) PASS: gdb.dwarf2/dw2-bad-mips-linkage-name.exp: ptype g I see no regressions on an x86_64 native target. gdb/ChangeLog: * dwarf2read.c (dwarf2_string_attr): New function. (lookup_dwo_unit, process_psymtab_comp_unit_reader) (dwarf2_compute_name, dwarf2_physname, find_file_and_directory) (read_call_site_scope, namespace_name, guess_full_die_structure_name) (anonymous_struct_prefix, prepare_one_comp_unit): Use dwarf2_string_attr in place of dwarf2_attr and DW_STRING. gdb/testsuite/ChangeLog: * gdb.dwarf2/dw2-bad-mips-linkage-name.c: New file. * gdb.dwarf2/dw2-bad-mips-linkage-name.exp: New file.