aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.mi
AgeCommit message (Collapse)AuthorFilesLines
2016-01-01GDB copyright headers update after running GDB's copyright.py script.Joel Brobecker119-119/+119
gdb/ChangeLog: Update year range in copyright notice of all files.
2015-12-21Remove HP-UX references fom testsuiteSimon Marchi2-28/+2
This patch removes all special cases for HP-UX, for which support has been removed earlier, that I found in the testsuite. Note that the hppa architecture != HP-UX, since other OSes can run on hppa, so I tried to leave everything that is not HP-UX specific. Two complete tests were completely HP-UX specific, so I removed them. I ran the testsuite on Linux x86-64, native and native-gdbserver, and noticed no regressions. gdb/testsuite/ChangeLog: * gdb.asm/asm-source.exp: Remove HP-UX references. * gdb.base/annota1.exp: Likewise. * gdb.base/annota3.exp: Likewise. * gdb.base/attach.exp: Likewise. * gdb.base/bigcore.exp: Likewise. * gdb.base/break.exp: Likewise. * gdb.base/call-ar-st.exp: Likewise. * gdb.base/callfuncs.exp: Likewise. * gdb.base/catch-fork-static.exp: Likewise. * gdb.base/display.exp: Likewise. * gdb.base/foll-exec-mode.exp: Likewise. * gdb.base/foll-exec.exp: Likewise. * gdb.base/foll-fork.exp: Likewise. * gdb.base/foll-vfork.exp: Likewise. * gdb.base/funcargs.exp: Likewise. * gdb.base/hbreak2.exp: Likewise. * gdb.base/inferior-died.exp: Likewise. * gdb.base/interrupt.exp: Likewise. * gdb.base/multi-forks.exp: Likewise. * gdb.base/nodebug.exp: Likewise. * gdb.base/sepdebug.exp: Likewise. * gdb.base/solib1.c: Likewise. * gdb.base/step-test.exp: Likewise. * gdb.mi/non-stop.c: Likewise. * gdb.mi/pthreads.c: Likewise. * gdb.multi/bkpt-multi-exec.ex: Likewise. * gdb.threads/pthreads.c: Likewise. * gdb.threads/staticthreads.exp: Likewise. * lib/future.exp: Likewise. * lib/gdb.exp: Likewise. * gdb.base/so-indr-cl.c: Remove. * gdb.base/so-indr-cl.exp: Likewise. * gdb.base/solib.c: Likewise. * gdb.base/solib.exp: Likewise. * gdb.base/solib2.c: Likewise.
2015-12-14Target remote mode fork and exec test updatesDon Breazeal1-5/+0
This patch updates tests for fork and exec events in target remote mode. In the majority of cases this was a simple matter of removing some code that disabled the test for target remote. In a few cases the test needed to be disabled; in those cases the gdb_protocol was checked instead of using the [is_remote target] etc. In a couple of cases we needed to use clean_restart, since target remote doesn't support the run command, and in one case we had to modify an expect expression to allow for a "multiprocess-style" ptid. Tested with the patch that implemented target remote mode fork and exec event support. gdb/testsuite/ChangeLog: * gdb.base/execl-update-breakpoints.exp (main): Enable for target remote. * gdb.base/foll-exec-mode.exp (main): Disable for target remote. * gdb.base/foll-exec.exp (main): Enable for target remote. * gdb.base/foll-fork.exp (main): Likewise. * gdb.base/foll-vfork.exp (main): Likewise. * gdb.base/multi-forks.exp (main): Likewise, and use clean_restart. (proc continue_to_exit_bp_loc): Use clean_restart. * gdb.base/pie-execl.exp (main): Disable for target remote. * gdb.base/watch-vfork.exp (main): Enable for target remote. * gdb.mi/mi-nsthrexec.exp (main): Likewise. * gdb.threads/execl.exp (main): Likewise. * gdb.threads/fork-child-threads.exp (main): Likewise. * gdb.threads/fork-plus-threads.exp (main): Disable for target remote. * gdb.threads/fork-thread-pending.exp (main): Enable for target remote. * gdb.threads/linux-dp.exp (check_philosopher_stack): Allow pid.tid style ptids, instead of just tid. * gdb.threads/thread-execl.exp (main): Enable for target remote. * gdb.threads/watchpoint-fork.exp (main): Likewise. * gdb.trace/report.exp (use_collected_data): Allow pid.tid style ptids, instead of just tid.
2015-12-09varobj zero-padded hexadecimal formatLuis Machado1-2/+23
This set of patches add support for the zero-padded hexadecimal format for varobj's, defined as "zero-hexadecimal". We currently only support regular non-zero-padded hexadecimal. Talking with IDE developers, they would like to have this option that is already available to GDB's print/x commands, in the CLI, as 'z'. gdb/ChangeLog: 2015-12-09 Luis Machado <lgustavo@codesourcery.com> * gdb/mi/mi-cmd-var.c (mi_parse_format): Handle new "zero-hexadecimal" format. * gdb/varobj.c (varobj_format_string): Add "zero-hexadecimal" entry. (format_code): Add 'z' entry. (varobj_set_display_format): Handle FORMAT_ZHEXADECIMAL. * gdb/varobj.h (varobj_display_formats) <FORMAT_ZHEXADECIMAL>: New enum field. * NEWS: Add new note to MI changes citing the new zero-hexadecimal format for -var-set-format. gdb/doc/ChangeLog: 2015-12-09 Luis Machado <lgustavo@codesourcery.com> * gdb.texinfo (GDB/MI Variable Objects): Update text to mention -var-set-format's new zero-hexadecimal format. gdb/testsuite/ChangeLog: 2015-12-09 Luis Machado <lgustavo@codesourcery.com> * gdb.mi/mi-var-display.exp: Add new checks for the zero-hexadecimal format and change test names to make them unique.
2015-11-30Fix mi-nonstop.exp with extended-remotePedro Alves1-4/+7
Testing with "maint set target-non-stop on" makes mi-nonstop.exp run with the extended-remote board. That reveals that mi-nonstop.exp is using the wrong predicate to check for "using remote protocol". This is not visible today because non-stop tests all fail to run with extended-remote board, because they spawn gdb and then do "set non-stop on". However, with that board, gdb connects to the gdbserver from within mi_gdb_start, and changing non-stop when already connected doesn't work. Fix that by instead enabling non-stop mode on gdb's command line. gdb/testsuite/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.mi/mi-nonstop.exp: Append "set non-stop on" to GDBFLAGS instead of issuing "-gdb-set non-stop 1" after starting gdb. Use mi_is_target_remote instead of checking "is_remote target". * lib/gdb.exp (gdb_is_target_remote): Rename to ... (gdb_is_target_remote_prompt): ... this, and add 'prompt_regexp' parameter. (gdb_is_target_remote): Reimplement. * lib/mi-support.exp (mi_is_target_remote): New procedure.
2015-11-24List inferiors/threads/pspaces in ascending orderPedro Alves2-3/+3
Before: (gdb) info threads Id Target Id Frame 3 Thread 0x7ffff77c3700 (LWP 29035) callme () at foo.c:30 2 Thread 0x7ffff7fc4700 (LWP 29034) 0x000000000040087b in child_function_2 (arg=0x0) at foo.c:60 * 1 Thread 0x7ffff7fc5740 (LWP 29030) 0x0000003b37209237 in pthread_join (threadid=140737353893632, thread_return=0x0) at pthread_join.c:92 After: (gdb) info threads Id Target Id Frame * 1 Thread 0x7ffff7fc5740 (LWP 29030) 0x0000003b37209237 in pthread_join (threadid=140737353893632, thread_return=0x0) at pthread_join.c:92 2 Thread 0x7ffff7fc4700 (LWP 29034) 0x000000000040087b in child_function_2 (arg=0x0) at foo.c:60 3 Thread 0x7ffff77c3700 (LWP 29035) callme () at foo.c:30 gdb/doc/ChangeLog: 2015-11-24 Pedro Alves <palves@redhat.com> PR 17539 * gdb.texinfo (Inferiors and Programs): Adjust "maint info program-spaces" example to ascending order listing. (Threads): Adjust "info threads" example to ascending order listing. (Forks): Adjust "info inferiors" example to ascending order listing. gdb/ChangeLog: 2015-11-24 Pedro Alves <palves@redhat.com> PR 17539 * inferior.c (add_inferior_silent): Append the new inferior to the end of the list. * progspace.c (add_program_space): Append the new pspace to the end of the list. * thread.c (new_thread): Append the new thread to the end of the list. gdb/testsuite/ChangeLog: 2015-11-24 Pedro Alves <palves@redhat.com> PR 17539 * gdb.base/foll-exec-mode.exp: Adjust to GDB listing inferiors and threads in ascending order. * gdb.base/foll-fork.exp: Likewise. * gdb.base/foll-vfork.exp: Likewise. * gdb.base/multi-forks.exp: Likewise. * gdb.mi/mi-nonstop.exp: Likewise. * gdb.mi/mi-nsintrall.exp: Likewise. * gdb.multi/base.exp: Likewise. * gdb.multi/multi-arch.exp: Likewise. * gdb.python/py-inferior.exp: Likewise. * gdb.threads/break-while-running.exp: Likewise. * gdb.threads/execl.exp: Likewise. * gdb.threads/gcore-thread.exp: Likewise. * gdb.threads/info-threads-cur-sal.exp: Likewise. * gdb.threads/kill.exp: Likewise. * gdb.threads/linux-dp.exp: Likewise. * gdb.threads/multiple-step-overs.exp: Likewise. * gdb.threads/next-bp-other-thread.exp: Likewise. * gdb.threads/step-bg-decr-pc-switch-thread.exp: Likewise. * gdb.threads/step-over-lands-on-breakpoint.exp: Likewise. * gdb.threads/step-over-trips-on-watchpoint.exp: Likewise. * gdb.threads/thread-find.exp: Likewise. * gdb.threads/tls.exp: Likewise. * lib/mi-support.exp (mi_reverse_list): Delete. (mi_check_thread_states): No longer reverse list.
2015-11-04Fortran: allocate()d memory is uninitializedJan Kratochvil1-1/+1
allocate (vla1 (5)) ! vla1-not-allocated l = allocated(vla1) ! vla1-allocated <------------------ Expecting: ^(510-data-evaluate-expression vla1[^M ]+)?(510\^done,value="\(0, 0, 0, 0, 0\)"[^M ]+[(]gdb[)] ^M [ ]*) 510-data-evaluate-expression vla1^M 510^done,value="(1.82987403e-09, 7.8472714e-44, 1.82987403e-09, 7.8472714e-44, 2.67929926e+20)"^M (gdb) ^M FAIL: gdb.mi/mi-vla-fortran.exp: evaluate allocated vla gcc-4.9.2-6.fc21.x86_64 I think some older gfortran did initialize allocated memory but that is an unspecified behavior. I haven't found any initialization mentioned in Fortran 90 standard (draft) and it is also clearly stated here: https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/268786 Initialization to 0 of allocated arrays (of integers) is an implementation issue. i.e. do not rely on it. Joel Brobecker wrote: I am wondering if it might be better to just relax instead the regexp to allow any number rather than just remove the test altogether. The test allows us to verify that, as soon as we're past the "allocate" call, we no longer say "not allocated". gdb/testsuite/ChangeLog 2015-11-03 Jan Kratochvil <jan.kratochvil@redhat.com> Joel Brobecker <brobecker@adacore.com> * gdb.mi/mi-vla-fortran.exp (evaluate allocated vla): Permit any data.
2015-10-21fort_dyn_array: add basic fortran dyn array supportKeven Boell2-0/+224
Fortran provide types whose values may be dynamically allocated or associated with a variable under explicit program control. The purpose of this commit is: * to read allocated/associated DWARF tags and store them in the dynamic property list of main_type. * enable GDB to print the value of a dynamic array in Fortran in case the type is allocated or associated (pointer to dynamic array). Examples: (gdb) p vla_not_allocated $1 = <not allocated> (gdb) p vla_allocated $1 = (1, 2, 3) (gdb) p vla_ptr_not_associated $1 = <not associated> (gdb) p vla_ptr_associated $1 = (1, 2, 3) Add basic test coverage for most dynamic array use-cases in Fortran. The commit contains the following tests: * Ensure that values of Fortran dynamic arrays can be evaluated correctly in various ways and states. * Ensure that Fortran primitives can be evaluated correctly when used as a dynamic array. * Dynamic arrays passed to subroutines and handled in different ways inside the routine. * Ensure that the ptype of dynamic arrays in Fortran can be printed in GDB correctly. * Ensure that dynamic arrays in different states (allocated/associated) can be evaluated. * Dynamic arrays passed to functions and returned from functions. * History values of dynamic arrays can be accessed and printed again with the correct values. * Dynamic array evaluations using MI protocol. * Sizeof output of dynamic arrays in various states. The patch was tested using the test suite on Ubuntu 12.04 64bit. gdb/ChangeLog: * dwarf2read.c (set_die_type): Add read of DW_AT_allocated and DW_AT_associated. * f-typeprint.c: New include of typeprint.h (f_print_type): Add check for allocated/associated status of type. (f_type_print_varspec_suffix): Add check for allocated/associated status of type. * gdbtypes.c (create_array_type_with_stride): Add check for valid data location of type in case allocated or associated attributes are set. Length of an array should be only calculated if allocated or associated is resolved as true. (is_dynamic_type_internal): Add check for allocated/ associated. (resolve_dynamic_array): Evaluate allocated/associated properties. * gdbtypes.h (enum dynamic_prop_node_kind): <DYN_PROP_ALLOCATED> <DYN_PROP_ASSOCIATED>: New enums. (TYPE_ALLOCATED_PROP, TYPE_ASSOCIATED_PROP): New macros. (type_not_allocated): New function. (type_not_associated): New function. * valarith.c (value_subscripted_rvalue): Add check for allocated/associated. * valprint.c: New include of typeprint.h. (valprint_check_validity): Add check for allocated/associated. (value_check_printable): Add check for allocated/ associated. * typeprint.h (val_print_not_allocated): New function. (val_print_not_associated): New function. * typeprint.c (val_print_not_allocated): New function. (val_print_not_associated): New function. gdb/testsuite/ChangeLog: * gdb.fortran/vla-alloc-assoc.exp: New file. * gdb.fortran/vla-datatypes.exp: New file. * gdb.fortran/vla-datatypes.f90: New file. * gdb.fortran/vla-history.exp: New file. * gdb.fortran/vla-ptype-sub.exp: New file. * gdb.fortran/vla-ptype.exp: New file. * gdb.fortran/vla-sizeof.exp: New file. * gdb.fortran/vla-sub.f90: New file. * gdb.fortran/vla-value-sub-arbitrary.exp: New file. * gdb.fortran/vla-value-sub-finish.exp: New file. * gdb.fortran/vla-value-sub.exp: New file. * gdb.fortran/vla-value.exp: New file. * gdb.fortran/vla-ptr-info.exp: New file. * gdb.mi/mi-vla-fortran.exp: New file. * gdb.mi/vla.f90: New file.
2015-09-18Fix pathname prefix and timeout issues in gdb.mi/mi-pending.exp.Sandra Loosemore1-3/+3
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 Loosemore1-1/+1
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 Loosemore1-1/+1
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-09Replace "struct continuation" mechanism by something more extensiblePedro Alves1-0/+18
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-08-14New /s modifier for the disassemble command.Doug Evans1-1/+1
The "source centric" /m option to the disassemble command is often unhelpful, e.g., in the presence of optimized code. This patch adds a /s modifier that is better. For one, /m only prints instructions from the originating source file, leaving out instructions from e.g., inlined functions from other files. gdb/ChangeLog: PR gdb/11833 * NEWS: Document new /s modifier for the disassemble command. * cli/cli-cmds.c (disassemble_command): Add support for /s. (_initialize_cli_cmds): Update online docs of disassemble command. * disasm.c: #include "source.h". (struct deprecated_dis_line_entry): Renamed from dis_line_entry. All uses updated. (dis_line_entry): New struct. (hash_dis_line_entry, eq_dis_line_entry): New functions. (allocate_dis_line_table): New functions. (maybe_add_dis_line_entry, line_has_code_p): New functions. (dump_insns): New arg end_pc. All callers updated. (do_mixed_source_and_assembly_deprecated): Renamed from do_mixed_source_and_assembly. All callers updated. (do_mixed_source_and_assembly): New function. (gdb_disassembly): Handle /s (DISASSEMBLY_SOURCE). * disasm.h (DISASSEMBLY_SOURCE_DEPRECATED): Renamed from DISASSEMBLY_SOURCE. All uses updated. (DISASSEMBLY_SOURCE): New macro. * mi/mi-cmd-disas.c (mi_cmd_disassemble): New modes 4,5. gdb/doc/ChangeLog: * gdb.texinfo (Machine Code): Update docs for mixed source/assembly disassembly. (GDB/MI Data Manipulation): Update docs for new disassembly modes. gdb/testsuite/ChangeLog: * gdb.mi/mi-disassemble.exp: Update. * gdb.base/disasm-optim.S: New file. * gdb.base/disasm-optim.c: New file. * gdb.base/disasm-optim.h: New file. * gdb.base/disasm-optim.exp: New file.
2015-08-11Explicit locations: MI support for explicit locationsKeith Seitz2-1/+93
This patch adds support for explicit locations to MI's -break-insert command. The new options, documented in the User Manual, are --source, --line, --function, and --label. gdb/ChangeLog: * mi/mi-cmd-break.c (mi_cmd_break_insert_1): Add support for explicit locations, options "--source", "--function", "--label", and "--line". gdb/testsuite/ChangeLog: * gdb.mi/mi-break.exp (test_explicit_breakpoints): New proc. (at toplevel): Call test_explicit_breakpoints. * gdb.mi/mi-dprintf.exp: Add tests for explicit dprintf breakpoints. * lib/mi-support.exp (mi_make_breakpoint): Add support for breakpoint conditions, "-cond".
2015-07-29Unbuffer all tests that rely on stdioPedro Alves1-0/+4
This forces all tests that rely on stdio to be unbuffered, like interrupt.exp was adjusted in 6f98576f. To recap, in some scenarios, GDB or GDBserver can be spawned with input _not_ connected to a tty, and then tests that rely on stdio fail with timeouts, because the inferior's stdout and stderr streams end up fully buffered. Calling gdb_unbuffer_output forces output to be unbuffered. See https://sourceware.org/ml/gdb-patches/2015-02/msg00809.html and https://sourceware.org/ml/gdb-patches/2015-02/msg00819.html. Tested on x86_64 Fedora 20, native, and against a remote gdbserver board file that connects to the target with ssh, with and without -t (create pty). gdb/testsuite/ChangeLog: 2015-07-29 Pedro Alves <palves@redhat.com> * gdb.base/call-ar-st.c: Include "../lib/unbuffer_output.c". (main): Call gdb_unbuffer_output. * gdb.base/call-rt-st.c: Include "../lib/unbuffer_output.c". (main): Call gdb_unbuffer_output. * gdb.base/call-strs.c: Include "../lib/unbuffer_output.c". (main): Call gdb_unbuffer_output. * gdb.base/call-strs.exp: Adjust to step over the gdb_unbuffer_output call. * gdb.base/catch-gdb-caused-signals.c: Include "../lib/unbuffer_output.c". (main): Call gdb_unbuffer_output. * gdb.base/dprintf.c: Include "../lib/unbuffer_output.c". (main): Call gdb_unbuffer_output. * gdb.base/ending-run.c: Include "../lib/unbuffer_output.c". (main): Call gdb_unbuffer_output. * gdb.base/run.c: Include "../lib/unbuffer_output.c". (main): Call gdb_unbuffer_output. * gdb.base/shlib-call.exp: Adjust to step over the gdb_unbuffer_output call. * gdb.base/shmain.c: Include "../lib/unbuffer_output.c". (main): Call gdb_unbuffer_output. * gdb.base/sizeof.c: Include "../lib/unbuffer_output.c". (main): Call gdb_unbuffer_output. * gdb.base/varargs.c: Include "../lib/unbuffer_output.c". (main): Rename to ... (test): ... this. (main): Reimplement. * gdb.base/varargs.exp: Run to test instead of to main. * gdb.mi/mi-dprintf.c: Include "../lib/unbuffer_output.c". (main): Call gdb_unbuffer_output.
2015-07-29Make gdb.mi/mi-dprintf.exp use $inferior_spawn_idPedro Alves1-32/+34
gdb/testsuite/ChangeLog: 2015-07-29 Pedro Alves <palves@redhat.com> * gdb.mi/mi-dprintf.exp (mi_expect_dprintf): New procedure, factore out from mi_continue_dprintf. For call-style dprintfs, expect dprintf output out of $inferior_spawn_id. (mi_continue_dprintf): Use mi_expect_dprintf. * gdb.mi/mi-dprintf.c: Include "../lib/unbuffer_output.c". (main): Call gdb_unbuffer_output.
2015-07-27gdb.mi/mi-pending.c: Return NULL instead of nothing in thread functionSimon Marchi1-2/+2
Using gcc 5.2 (maybe other versions as well), building mi-pending.c gives these warnings: ./gdb.mi/mi-pending.c: In function ‘thread_func’: ./gdb.mi/mi-pending.c:34:5: warning: ‘return’ with no value, in function returning non-void return; ^ ./gdb.mi/mi-pending.c:38:5: warning: ‘return’ with no value, in function returning non-void return; ^ gdb_compile_pthreads assumes that the build was successful only if there is no output. These warnings therefore make gdb_compile_pthreads think that the build failed, and the test doesn't run. The easy fix is to replace the "return" with "return NULL". I am pushing this as obvious. gdb/testsuite/ChangeLog: * gdb.mi/mi-pending.c (thread_func): Replace return with return NULL.
2015-07-27Remove xfail in gdb.mi/mi-watch.expSimon Marchi1-4/+0
I noticed there was an unexpected pass in mi-watch.exp when running on x86_64. Doing a bit of archeology shows that the xfail was added by 4a543da. This particular test failed on the MIPS architecture, which the original contributor was working with. Here is the thread: https://www.sourceware.org/ml/gdb-patches/2007-09/msg00151.html Looking at the latest buildbot results for MIPS, it seems that it's also an unexpected pass on that architecture. Therefore, I see no reason to leave the xfail in place. gdb/testsuite/ChangeLog: * gdb.mi/mi-watch.exp (test_watchpoint_triggering): Remove xfail.
2015-06-12Fix MI dprintf-insert not printing on a resolved pending location.Antoine Tremblay3-0/+131
This patch fixes the "Format string required" error when trying to print a dprintf on a now resolved, pending location when set via the MI interface even if the format string is entered correctly. This patch also adds a test case to check that issue called mi-dprintf-pending.exp. gdb/ChangeLog: PR breakpoints/16465 * breakpoint.c (create_breakpoint): Save extra_string for pending breakpoints. gdb/testsuite/ChangeLog: PR breakpoints/16465 * gdb.mi/mi-dprintf-pending.c: New file. * gdb.mi/mi-dprintf-pending.exp: New test. * gdb.mi/mi-dprintf-pendshr.c: New file.
2015-06-02Fix =thread-exited not showing up when detaching (PR 15564)Simon Marchi1-0/+35
I sent a patch in 2013 for this (incorrectly named =thread-created): https://cygwin.com/ml/gdb-patches/2013-06/msg00129.html Tom Tromey was ok with the change, but suggested to add a test as well. Then I forgot about this patch until today. So here it is again, with the corresponding test. The problem is that the =thread-exited event does not appear when detaching from a local process. It does appear with remote though. It's not a really big deal, but I'd like it to be consistent. Tested with local and remote Linux on my Ubuntu 14.04. gdb/ChangeLog: PR gdb/15564 * inferior.c (detach_inferior): Call exit_inferior_1 with silent = 0. gdb/testsuite/ChangeLog: PR gdb/15564 * gdb.mi/mi-detach.exp: New file.
2015-05-26Rename dwarf2 to dwarf in "set debug" and maintenance commands.Doug Evans1-3/+3
gdb/ChangeLog: * NEWS: Add entries for command renamings. * dwarf2read.c (dwarf_read_debug): Renamed from dwarf2_read_debug. All uses updated. (dwarf_die_debug): Renamed from dwarf2_die_debug. All uses updated. (dwarf_max_cache_age): Renamed from dwarf2_max_cache_age. All uses updated. (show_dwarf_max_cache_age): Renamed from show_dwarf2_max_cache_age. All callers updated. Fix spelling of DWARF in help text. (set_dwarf_cmdlist): Renamed from set_dwarf2_cmdlist. All uses updated. (show_dwarf_cmdlist): Renamed from show_dwarf2_cmdlist. All uses updated. (set_dwarf_cmd): Renamed from set_dwarf2_cmd. All callers updated. (show_dwarf_cmd): Renamed from show_dwarf2_cmd. All callers updated. (dwarf_always_disassemble): Renamed from dwarf_always_disassemble. All uses updated. (show_dwarf_always_disassemble): Renamed from show_dwarf2_always_disassemble. All callers updated. (_initialize_dwarf2_read): Rename "set/show dwarf2" prefix to "set/show dwarf". Rename "set/show dwarf2 max-cache-age" to "set/show dwarf max-cache-age". Rename "set/show dwarf2 always-disassemble" to "set/show dwarf always-disassemble". Rename "set/show debug dwarf2-read" to "set/show debug dwarf-read". Rename "set/show debug dwarf2-die" to "set/show debug dwarf-die". gdb/doc/ChangeLog: * gdb.texinfo (Debugging Output): Update for DWARF "set debug" command renamings. (Maintenance Commands): Update for DWARF "set debug" command renamings. gdb/testsuite/ChangeLog: * gdb.dwarf2/dw2-op-call.exp: Update. * gdb.dwarf2/dw4-sig-types.exp: Update. * gdb.dwarf2/implptr.exp: Update. * gdb.mi/mi-cmd-param-changed.exp: Update.
2015-03-24Fix mi-pending.exp test output to allow stable test diffingAntoine Tremblay1-1/+1
gdb/testsuite/ChangeLog: * gdb.mi/mi-pending.exp: Fix output of breakpoint test.
2015-03-24Fix breakpoint thread condition missing with mi and a pending breakpoint.Antoine Tremblay5-25/+127
When setting a pending breakpoint with a thread condition while using the mi interface, the thread condition would be lost by gdb when the breakpoint was resolved. This patch fixes this behavior by setting the thread condition properly in the mi case. Also, this patch modifies the mi-pending test case to test for this issue and removes some unneeded code in the testcase and dependency on stdio. gdb/Changelog: PR breakpoints/16466 * breakpoint.c (create_breakpoint): Set thread on breakpoint struct. gdb/testsuite/ChangeLog: PR breakpoints/16466 * gdb.mi/Makefile.in: Add mi-pendshr2.sl to cleanup. * gdb.mi/mi-pending.c (thread_func): New function. (int main): Add threading support required. * gdb.mi/mi-pending.exp: Add tests for this issue. * gdb.mi/mi-pendshr.c (pendfunc1): Remove stdio dependency. (pendfunc2): Remove stdio dependency. * gdb.mi/mi-pendshr2.c: New file.
2015-01-25Remove testsuite compile errors with GCC5.Mark Wielaard3-0/+3
GCC5 defaults to the GNU11 standard for C and warns by default for implicit function declarations and implicit return types. https://gcc.gnu.org/gcc-5/porting_to.html Fixing these issues in the testsuite turns 9 untested and 17 unsupported testcases into 417 new passes when compiling with GCC5. gdb/testsuite/ChangeLog: * gdb.arch/i386-bp_permanent.c (standard): New declaration. * gdb.base/disp-step-fork.c: Include unistd.h. * gdb.base/siginfo-obj.c: Include stdio.h. * gdb.base/siginfo-thread.c: Likewise. * gdb.mi/non-stop.c: Include unistd.h. * gdb.mi/nsthrexec.c: Include stdio.h. * gdb.mi/pthreads.c: Include unistd.h. * gdb.modula2/unbounded1.c (main): Declare returns int. * gdb.reverse/consecutive-reverse.c: Likewise. * gdb.threads/create-fail.c: Include unistd.h. * gdb.threads/killed.c: Likewise. * gdb.threads/linux-dp.c: Likewise. * gdb.threads/non-ldr-exc-1.c: Include stdio.h and string.h. * gdb.threads/non-ldr-exc-2.c: Likewise. * gdb.threads/non-ldr-exc-3.c: Likewise. * gdb.threads/non-ldr-exc-4.c: Likewise. * gdb.threads/pthreads.c: Include unistd.h. (main): Declare returns int. * gdb.threads/tls-main.c (foo): New declaration. * gdb.threads/watchpoint-fork-mt.c: Define _GNU_SOURCE.
2015-01-23Catch exception in value_rtti_indirect_typeSimon Marchi2-0/+109
In the situation described in bug 17416 [1]: * "set print object" is on; * The variable object is a pointer to a struct, and it contains an invalid value (e.g. NULL, or random uninitialized value); * The variable object (struct) has a child which is also a pointer to a struct; * We try to use "-var-list-children". ... an exception thrown in value_ind can propagate too far and leave an half-built variable object, leading to a wrong state. This patch adds a TRY_CATCH to catch it and makes value_rtti_indirect_type return NULL in that case, meaning that the type of the pointed object could not be found. A test for the fix is also added. New in v2: * Added test. * Restructured "catch" code. * Added details about the bug in commit log. gdb/Changelog: * valops.c (value_rtti_indirect_type): Catch exception thrown by value_ind. gdb/testsuite/ChangeLog * gdb.mi/mi-var-list-children-invalid-grandchild.c: New file. * gdb.mi/mi-var-list-children-invalid-grandchild.exp: New file. [1] https://sourceware.org/bugzilla/show_bug.cgi?id=17416
2015-01-01Update year range in copyright notice of all files owned by the GDB project.Joel Brobecker110-110/+110
gdb/ChangeLog: Update year range in copyright notice of all files.
2014-11-17Eliminate literal line numbers in mi-until.expAndreas Arnez2-13/+20
Remove literal line numbers from the regexps in mi-until.exp. Add appropriate eye-catchers to until.c and refer to those instead. This change fixes the test case after having disturbed the line numbering with the previous fix for compiler warnings with -std=gnu11. gdb/testsuite/ChangeLog: * gdb.mi/until.c: Add eye-catchers. * gdb.mi/mi-until.exp: Refer to eye-catchers instead of literal line numbers.
2014-11-13GDB testsuite: Fix warnings with -std=gnu11Andreas Arnez7-4/+17
Since upstream GCC has changed the default C language dialect to 'gnu11', it yields multiple warnings in the GDB testsuite for missing function return types and implicit function declarations. This patch attempts to fix these. gdb/testsuite/ChangeLog: * gdb.ada/cond_lang/foo.c (callme): Add return type. * gdb.base/call-sc.c (zed): Likewise. * gdb.base/checkpoint.c (main): Likewise. * gdb.base/dump.c (main): Likewise. * gdb.base/gcore.c (main): Likewise. * gdb.base/huge.c (main): Likewise. * gdb.base/multi-forks.c (main): Likewise. * gdb.base/pr10179-a.c (main): Likewise. * gdb.base/savedregs.c (main): Likewise. * gdb.base/sigaltstack.c (main): Likewise. * gdb.base/siginfo.c (main): Likewise. * gdb.base/structs.c (zed): Likewise. * gdb.mi/mi-stack.c (callee3, callee2, callee1, main): Likewise. * gdb.mi/mi-syn-frame.c (main): Likewise. * gdb.mi/until.c (foo, main): Likewise. * gdb.base/global-var-nested-by-dso.c (b_main, c_main): Declare. * gdb.base/solib-weak.c (foo): Declare. * gdb.base/attach-twice.c: Include stdio.h. * gdb.base/weaklib1.c: Likewise. * gdb.base/weaklib2.c: Likewise. * gdb.base/catch-signal-fork.c: Include stdio.h and sys/wait.h. * gdb.mi/mi-condbreak-call-thr-state-mt.c: Include stdio.h and unistd.h. * gdb.base/attach-pie-misread.c: Include stdlib.h. * gdb.mi/mi-exit-code.c: Likewise. * gdb.base/break-interp-lib.c: Include string.h. * gdb.base/coremaker.c: Likewise. * gdb.base/testenv.c: Likewise. * gdb.python/py-finish-breakpoint.c: Likewise. * gdb.base/inferior-died.c: Include sys/wait.h. * gdb.base/fileio.c: Include time.h. * gdb.base/async-shell.c: Include unistd.h. * gdb.base/dprintf-non-stop.c: Likewise. * gdb.base/info-os.c: Likewise. * gdb.mi/mi-console.c: Likewise. * gdb.mi/watch-nonstop.c: Likewise. * gdb.python/py-events.c: Likewise. * gdb.base/async.c (baz): Move up before its invocation. * gdb.base/code_elim2.c (my_global_func): Likewise. * gdb.base/skip-solib-lib.c (multiply): Likewise. * gdb.base/advance.c (func2): Likewise.
2014-11-13Eliminate literal line numbers in mi-console.expAndreas Arnez2-2/+3
Remove the literal line number from a regexp in mi-console.exp. Add an appropriate eye-catcher to mi-console.c and refer to that instead. gdb/testsuite/ChangeLog: * gdb.mi/mi-console.c: Add eye-catcher. * gdb.mi/mi-console.exp (semihosted_string): Refer to eye-catcher instead of literal line number.
2014-10-17Delete Tru64 supportPedro Alves2-4/+4
This commit does most of the mechanical removal. IOW, the easy part. procfs.c isn't touched beyond removing a couple obvious bits that are guarded by a couple macros defined in config/alpha/nm-osf3.h. Going beyond that for procfs.c & co would be a harder excision that potentially affects Solaris. Some comments in the generic alpha code ABIs that may still be relevant and I wouldn't know what to do with them. That can always be done on a separate pass, preferably by someone who can test on alpha. A couple other spots have references to OSF/Tru64 and related files being removed, but it felt like removing them would make things worse, not better. We can revisit those when we next need to touch that code. I didn't remove a reference to osf in testsuite/lib/future.exp, as I believe that code is imported from DejaGNU. Built and tested on x86_64 Fedora 20, with --enable-targets=all. Tested that building for --target=alpha-osf3 on x86_64 Fedora 20 fails with: checking for default auto-load directory... $debugdir:$datadir/auto-load checking for default auto-load safe-path... $debugdir:$datadir/auto-load *** Configuration alpha-unknown-osf3 is obsolete. *** Support has been REMOVED. make[1]: *** [configure-gdb] Error 1 make[1]: Leaving directory `build-osf' make: *** [all] Error 2 gdb/ 2014-10-17 Pedro Alves <palves@redhat.com> * Makefile.in (ALL_64_TARGET_OBS): Remove alpha-osf1-tdep.o. (HFILES_NO_SRCDIR): Remove config/alpha/nm-osf3.h. (ALLDEPFILES): Remove alpha-nat.c, alpha-osf1-tdep.c and solib-osf.c. * NEWS: Mention that support for alpha*-*-osf* has been removed. * ada-lang.h [__alpha__ && __osf__] (ADA_KNOWN_RUNTIME_FILE_NAME_PATTERNS): Delete. * alpha-nat.c, alpha-osf1-tdep.c: Delete files. * alpha-tdep.c (alpha_gdbarch_init): Remove reference to GDB_OSABI_OSF1. * config/alpha/alpha-osf3.mh, config/alpha/nm-osf3.h: Delete files. * config/djgpp/fnchange.lst (config/alpha/alpha-osf1.mh) (config/alpha/alpha-osf2.mh, config/alpha/alpha-osf3.mh): Delete. * configure: Regenerate. * configure.ac: Remove references to osf. * configure.host: Handle alpha*-*-osf* in the obsolete hosts section. Remove all other references to osf. * configure.tgt: Add alpha*-*-osf* to the obsolete targets section. Remove all other references to osf. * dec-thread.c: Delete file. * defs.h (GDB_OSABI_OSF1): Delete. * inferior.h (START_INFERIOR_TRAPS_EXPECTED): New unconditionally defined. * osabi.c (gdb_osabi_names): Delete "OSF/1". * procfs.c (procfs_debug_inferior) [PROCFS_DONT_TRACE_FAULTS]: Delete code. (unconditionally_kill_inferior) [PROCFS_NEED_CLEAR_CURSIG_FOR_KILL]: Delete code. * solib-osf.c: Delete file. gdb/testsuite/ 2014-10-17 Pedro Alves <palves@redhat.com> * gdb.base/callfuncs.exp: emove references to osf. * gdb.base/sigall.exp: Likewise. * gdb.gdb/selftest.exp: Likewise. * gdb.hp/gdb.base-hp/callfwmall.exp: Likewise. * gdb.mi/non-stop.c: Likewise. * gdb.mi/pthreads.c: Likewise. * gdb.reverse/sigall-precsave.exp: Likewise. * gdb.reverse/sigall-reverse.exp: Likewise. * gdb.threads/pthreads.c: Likewise. * gdb.threads/pthreads.exp: Likewise. gdb/doc/ 2014-10-17 Pedro Alves <palves@redhat.com> * gdb.texinfo (Ada Tasks and Core Files): Delete mention of Tru64. (SVR4 Process Information): Delete mention of OSF/1.
2014-10-14Fix fail in mi-var-child.exp and mi-var-display.expYao Qi5-10/+53
Hi, I see the following fails on arm-none-eabi target, -var-list-children --simple-values struct_declarations ^M ^done,numchild="11",children=[...,child={name="struct_declarations.func_ptr_struct",exp="func_ptr_struct",numchild="0",value="0x0 <_ftext>",type="struct _struct_decl (*)(int, char *, long)",thread-id="1"},child={name="struct_declarations.func_ptr_ptr",exp="func_ptr_ptr",numchild="0",value="0x0 <_ftext>",type="struct _struct_decl *(*)(int, char *, long)",thread-id="1"},... (gdb) ^M FAIL: gdb.mi/mi-var-child.exp: listing of children, simple types: names, type and values, complex types: names and types -var-set-format weird.func_ptr_ptr natural^M ^done,format="natural",value="0x0 <_ftext>"^M (gdb) ^M FAIL: gdb.mi/mi-var-display.exp: set format variable weird.func_ptr_ptr in natural In the test, "0x0" is expected, but "0x0 <_ftext>" is in the output. Function pointers point to address zero, and tests assume there is no symbol on address zero. However, on my arm-none-eabi target, there is a code symbol _ftext on address zero, and test fails. Note that "set print symbol off" doesn't take effect for function pointer. int (*f) (void); f = main; (gdb) p f $1 = (int (*)(void)) 0x8048400 <main> (gdb) set print symbol off (gdb) p f $2 = (int (*)(void)) 0x8048400 <main> In order to erase the difference, we can assign some function address explicitly to function pointer, so the test behaves in a unique way. In this patch, we assign nothing1 and nothing2 to function pointers func_ptr_struct and func_ptr_ptr respectively, and update test as the source file is changed. gdb/testsuite: 2014-10-14 Yao Qi <yao@codesourcery.com> * gdb.mi/mi-var-child.c (nothing1): New function. (nothing2): New function. (do_children_tests): Set function pointers by nothing1 and nothing2. * gdb.mi/mi-var-child.exp: Step over new added statements. Update test to match the new output. * gdb.mi/var-cmd.c (nothing1): New function. (nothing2): New function. (do_children_tests): Set function pointers by nothing1 and nothing2. * gdb.mi/mi-var-display.exp: Update test to match output. Step to the line specified by $line_dct_nothing. Increase the number of lines to step.
2014-10-14Use mi_varobj_update in mi-var-child.exp and mi2-var-child.expYao Qi2-60/+77
Hi, I modify mi-var-child.exp and find that the pattern to match the output of -var-update * is quite complicated. However, it can be simplified by using mi_varobj_update. That is what this patch does. gdb/testsuite: 2014-10-14 Yao Qi <yao@codesourcery.com> * gdb.mi/mi-var-child.exp: Use mi_varobj_update to simplify tests. * gdb.mi/mi2-var-child.exp: Likewise.
2014-10-01Exit code of exited inferiors in -list-thread-groupsSimon Marchi2-0/+115
Don't reset the exit code at inferior exit and print it in -list-thread-groups. gdb/ChangeLog: * NEWS: Announce new exit-code field in -list-thread-groups output. * inferior.c (exit_inferior_1): Don't clear exit code. (inferior_appeared): Clear exit code. * mi/mi-main.c (print_one_inferior): Add printing of the exit code. gdb/testsuite/ChangeLog: * gdb.mi/mi-exit-code.exp: New file. * gdb.mi/mi-exit-code.c: New file. gdb/doc/ChangeLog: * gdb.texinfo (Miscellaneous gdb/mi Commands): Document new exit-code field in -list-thread-groups output.
2014-09-09Set print symbol off in mi-var-display.expYao Qi1-0/+3
Hi, I see the following fail on arm-none-eabi target, -var-evaluate-expression -f nat foo^M ^done,value="0x3 <_ftext+2>"^M (gdb) ^M FAIL: gdb.mi/mi-var-display.exp: eval variable -f nat foo the "<_ftext+2>" isn't expected in the test, so "set print symbol off" can prevent printing it. It is obvious and I'll commit it in three days if no comments. gdb/testsuite: 2014-09-09 Yao Qi <yao@codesourcery.com> * gdb.mi/mi-var-display.exp: Set print symbol off.
2014-08-25Fix clang compilation errors in gdb.mi/basics.c.Doug Evans1-4/+4
gdb/testsuite/ChangeLog: * gdb.mi/basics.c (callee3, callee2, callee1): Specify result type. (main): Ditto.
2014-08-09Make test messages in gdb.mi/mi-var-display.exp uniqueYao Qi1-16/+16
When I fix a bug in gdb.mi/mi-var-display.exp, I find its test messages aren't unique, which makes some confusions for me. $ cat testsuite/gdb.sum | grep "PASS" | sort | uniq -c | sort -n ... 2 PASS: gdb.mi/mi-var-display.exp: set format variable bar 2 PASS: gdb.mi/mi-var-display.exp: set format variable foo 2 PASS: gdb.mi/mi-var-display.exp: set format variable weird.func_ptr 2 PASS: gdb.mi/mi-var-display.exp: set format variable weird.func_ptr_ptr 2 PASS: gdb.mi/mi-var-display.exp: show format variable foo 3 PASS: gdb.mi/mi-var-display.exp: eval variable foo This patch is to make test messages in mi-var-display.exp unique. gdb/testsuite: 2014-08-09 Yao Qi <yao@codesourcery.com> PR testsuite/13443 * gdb.mi/mi-var-display.exp: Make test messages unique.
2014-07-09Improve MI -var-info-path-expression for nested struct/union case.Andrew Burgess2-0/+144
https://sourceware.org/ml/gdb-patches/2014-05/msg00383.html The MI command -var-info-path-expression currently does not handle non-anonymous structs / unions nested within other structs / unions, it will skip parts of the expression. Consider this example: ## START EXAMPLE ## $ cat ex.c #include <string.h> int main () { struct s1 { int a; }; struct ss { struct s1 x; }; struct ss an_ss; memset (&an_ss, 0, sizeof (an_ss)); return 0; } $ gcc -g -o ex.x ex.c $ gdb ex.x (gdb) break 18 Breakpoint 1 at 0x80483ba: file ex.c, line 18. (gdb) run Starting program: /home/user/ex.x Breakpoint 1, main () at ex.c:18 18 return 0; (gdb) interpreter-exec mi "-var-create an_ss * an_ss" (gdb) interpreter-exec mi "-var-list-children an_ss" ^done,numchild="1",children=[child={name="an_ss.x",exp="x",numchild="1",type="struct s1",thread-id="1"}],has_more="0" (gdb) interpreter-exec mi "-var-list-children an_ss.x" ^done,numchild="1",children=[child={name="an_ss.x.a",exp="a",numchild="0",type="int",thread-id="1"}],has_more="0" (gdb) interpreter-exec mi "-var-list-children an_ss.x.a" ^done,numchild="0",has_more="0" (gdb) interpreter-exec mi "-var-info-path-expression an_ss.x.a" ^done,path_expr="(an_ss).a" (gdb) print (an_ss).a There is no member named a. ## END EXAMPLE ## Notice that the path expression returned is wrong, and as a result the print command fails. This patch adds a new method to the varobj_ops structure called is_path_expr_parent, to allow language specific control over finding the parent varobj, the current logic becomes the C/C++ version and is extended to handle the nested cases. No other language currently uses this code, so all other languages just get a default method. With this patch, the above example now finishes like this: ## START EXAMPLE ## $ gdb ex.x (gdb) break 18 Breakpoint 1 at 0x80483ba: file ex.c, line 18. (gdb) run Starting program: /home/user/ex.x Breakpoint 1, main () at ex.c:18 18 return 0; (gdb) interpreter-exec mi "-var-list-children an_ss" ^done,numchild="1",children=[child={name="an_ss.x",exp="x",numchild="1",type="struct s1",thread-id="1"}],has_more="0" (gdb) interpreter-exec mi "-var-list-children an_ss.x" ^done,numchild="1",children=[child={name="an_ss.x.a",exp="a",numchild="0",type="int",thread-id="1"}],has_more="0" (gdb) interpreter-exec mi "-var-list-children an_ss.x.a" ^done,numchild="0",has_more="0" (gdb) interpreter-exec mi "-var-info-path-expression an_ss.x.a" ^done,path_expr="((an_ss).x).a" (gdb) print ((an_ss).x).a $1 = 0 ## END EXAMPLE ## Notice that the path expression is now correct, and the print is a success. gdb/ChangeLog: * ada-varobj.c (ada_varobj_ops): Fill in is_path_expr_parent field. * c-varobj.c (c_is_path_expr_parent): New function, moved core from varobj.c, with additional checks. (c_varobj_ops): Fill in is_path_expr_parent field. (cplus_varobj_ops): Fill in is_path_expr_parent field. * jv-varobj.c (java_varobj_ops): Fill in is_path_expr_parent field. * varobj.c (is_path_expr_parent): Call is_path_expr_parent varobj ops method. (varobj_default_is_path_expr_parent): New function. * varobj.h (lang_varobj_ops): Add is_path_expr_parent field. (varobj_default_is_path_expr_parent): Declare new function. gdb/testsuite/ChangeLog: * gdb.mi/var-cmd.c (do_nested_struct_union_tests): New function setting up test structures. (main): Call new test function. * gdb.mi/mi2-var-child.exp: Create additional breakpoint in new test function, continue into test function and walk test structures.
2014-06-17In a couple functions (type_update_when_use_rtti_test andLuis Machado1-12/+16
skip_type_update_when_not_use_rtti_test) the testcase assumes an uninitialized object has a specific type. In particular, 'ptr' and 's'. In reality the compiler is free to do what it wants with that uninitialized variable, even initialize it beforehand with the future assignment's value. This is exactly what happens on some targets. ptr should have type 'Base *', but it really has type 'Derived *' because it is already initialized (earlier) by the compiler. The same thing happens to 's'. The following patch addresses this by explicitly initializing those variables so the compiler doesn't optimize their assignments and GDB can print their correct values. 2014-06-17 Luis Machado <lgustavo@codesourcery.com> * gdb.mi/mi-var-rtti.cc (type_update_when_use_rtti_test): Initialize ptr and S explicitly. (skip_type_update_when_not_use_rtti_test): Likewise.
2014-06-16Fix for PR mi/15863Keith Seitz1-0/+6
If an MI client creates a varobj and attempts to update the root /before/ the inferior is started, gdb will throw an internal error: (gdb) -var-create * - batch_flag ^done,name="var1",numchild="0",value="0",type="int",has_more="0" (gdb) -var-update var1 ^done,changelist=[] (gdb) -var-update * ~"../../src/gdb/thread.c:628: internal-error: is_thread_state: Assertion `tp' failed.\nA problem internal to GDB has been detected,\nfurther debugging may prove unreliable.\nQuit this debugging session? " ~"(y or n) " The function that handles the varobj update in the failing case, mi_cmd_var_udpate_iter, checks if the thread/inferior is stopped before attempting to update the varobj. It calls is_stopped (inferior_ptid) which calls is_thread_state: tp = find_thread_ptid (ptid); gdb_assert (tp); When there is no inferior, ptid is null_ptid, and find_thread_ptid (null_ptid) returns NULL and the assertion is triggered. This patch changes mi_cmd_var_update_iter to behave the same way "-var-update var1" does: by calling the thread "stopped" if there is no inferior (and thereby calling varobj_update_one). ChangeLog 2014-06-16 Keith Seitz <keiths@redhat.com> PR mi/15863 * mi/mi-cmd-var.c (mi_cmd_var_update_iter): Do not attempt to update the varobj if inferior_ptid is null_ptid. testsuite/ChangeLog 2014-06-16 Keith Seitz <keiths@redhat.com> PR mi/15863 * gdb.mi/mi-var-cmd.exp: Add test for -var-update before the inferior is started.
2014-06-05PR mi/15806: Fix quoting of async eventsSimon Marchi1-1/+1
Original patch: https://sourceware.org/ml/gdb-patches/2014-04/msg00552.html New in v2: * In remote.c:escape_buffer, pass '\\' to fputstrn_unfiltered/printchar to make sure backslashes are escaped in remote debug output. * Updated function documentation for printchar. See updated ChangeLog below. -------------------- The quoting in whatever goes in the event_channel of MI is little bit broken. Link for the lazy: https://sourceware.org/bugzilla/show_bug.cgi?id=15806 Here is an example of a =library-loaded event with an ill-named directory, /tmp/how"are\you (the problem is present with every directory on Windows since it uses backslashes as a path separator). The result will be the following: =library-loaded,id="/tmp/how"are\\you/libexpat.so.1",... The " between 'how' and 'are' should be escaped. Another bad behavior is double escaping in =breakpoint-created, for example: =breakpoint-created,bkpt={...,fullname="/tmp/how\\"are\\\\you/test.c",...} The two backslashes before 'how' should be one and the four before 'you' should be two. The reason for this is that when sending something to an MI console, escaping can take place at two different moments (the actual escaping work is always done in the printchar function): 1. When generating the content, if ui_out_field_* functions are used. Here, fields are automatically quoted with " and properly escaped. At least mi_field_string does it, not sure about mi_field_fmt, I need to investigate further. 2. When gdb_flush is called, to send the data in the buffer of the console to the actual output (stdout). At this point, mi_console_raw_packet takes the whole string in the buffer, quotes it, and escapes all occurences of the quoting character and backslashes. The event_channel does not specify a quoting character, so quotes are not escaped here, only backslashes. The problem with =library-loaded is that it does use fprintf_unfiltered, which doesn't do escaping (so, no #1). When gdb_flush is called, backslashes are escaped (#2). The problem with =breakpoint-created is that it first uses ui_out_field_* functions to generate its output, so backslashes and quotes are escaped there (#1). backslashes are escaped again in #2, leading to an overdose of backslashes. In retrospect, there is no way escaping can be done reliably in mi_console_raw_packet for data that is already formatted, such as event_channel. At this point, there is no way to differentiate quotes that delimit field values from those that should be escaped. In the case of other MI consoles, it is ok since mi_console_raw_packet receives one big string that should be quoted and escaped as a whole. So, first part of the fix: for the MI channels that specify no quoting character, no escaping at all should be done in mi_console_raw_packet (that's the change in printchar, thanks to Yuanhui Zhang for this). For those channels, whoever generates the content is responsible for proper quoting and escaping. This will fix the =breakpoint-created kind of problem. Second part of the fix is to make =library-loaded generate content that is properly escaped. For this, we use ui_out_field_* functions, instead of one big fprintf_unfiltered. =library-unloaded suffered from the same problem so it is modified as well. There might be other events that need fixing too, but that's all I found with a quick scan. Those that use fprintf_unfiltered but whose sole variable data is a %d are not critical, since it won't generate a " or a \. Finally, a test has been fixed, as it was expecting an erroneous output. Otherwise, all other tests that were previously passing still pass (x86-64 linux). gdb/ChangeLog: 2014-06-02 Simon Marchi <simon.marchi@ericsson.com> PR mi/15806 * utils.c (printchar): Don't escape at all if quoter is NUL. Update function documentation to clarify effect of parameter QUOTER. * remote.c (escape_buffer): Pass '\\' as the quoter to fputstrn_unfiltered. * mi/mi-interp.c (mi_solib_loaded): Use ui_out_field_* functions to generate the output. (mi_solib_unloaded): Same. gdb/testsuite/ChangeLog: 2014-06-02 Simon Marchi <simon.marchi@ericsson.com> * gdb.mi/mi-breakpoint-changed.exp (test_insert_delete_modify): Fix erroneous dprintf expected input.
2014-05-29enable target async by default; separate MI and target notions of asyncPedro Alves8-8/+8
This finally makes background execution commands possible by default. However, in order to do that, there's one last thing we need to do -- we need to separate the MI and target notions of "async". Unlike the CLI, where the user explicitly requests foreground vs background execution in the execution command itself (c vs c&), MI chose to treat "set target-async" specially -- setting it changes the default behavior of execution commands. So, we can't simply "set target-async" default to on, as that would affect MI frontends. Instead we have to make the setting MI-specific, and teach MI about sync commands on top of an async target. Because the "target" word in "set target-async" ends up as a potential source of confusion, the patch adds a "set mi-async" option, and makes "set target-async" a deprecated alias. Rather than make the targets always async, this patch introduces a new "maint set target-async" option so that the GDB developer can control whether the target is async. This makes it simpler to debug issues arising only in the synchronous mode; important because sync mode seems unlikely to go away. Unlike in previous revisions, "set target-async" does not affect this new maint parameter. The rationale for this is that then one can easily run the test suite in the "maint set target-async off" mode and have tests that enable mi-async fail just like they fail on non-async-capable targets. This emulation is exactly the point of the maint option. I had asked Tom in a previous iteration to split the actual change of the target async default to a separate patch, but it turns out that that is quite awkward in this version of the patch, because with MI async and target async decoupled (unlike in previous versions), if we don't flip the default at the same time, then just "set target-async on" alone never actually manages to do anything. It's best to not have that transitory state in the tree. Given "set target-async on" now only has effect for MI, the patch goes through the testsuite removing it from non-MI tests. MI tests are adjusted to use the new and less confusing "mi-async" spelling. 2014-05-29 Pedro Alves <palves@redhat.com> Tom Tromey <tromey@redhat.com> * NEWS: Mention "maint set target-async", "set mi-async", and that background execution commands are now always available. * target.h (target_async_permitted): Update comment. * target.c (target_async_permitted, target_async_permitted_1): Default to 1. (set_target_async_command): Rename to ... (maint_set_target_async_command): ... this. (show_target_async_command): Rename to ... (maint_show_target_async_command): ... this. (_initialize_target): Adjust. * infcmd.c (prepare_execution_command): Make extern. * inferior.h (prepare_execution_command): Declare. * infrun.c (set_observer_mode): Leave target async alone. * mi/mi-interp.c (mi_interpreter_init): Install mi_on_sync_execution_done as sync_execution_done observer. (mi_on_sync_execution_done): New function. (mi_execute_command_input_handler): Don't print the prompt if we just started a synchronous command with an async target. (mi_on_resume): Check sync_execution before printing prompt. * mi/mi-main.h (mi_async_p): Declare. * mi/mi-main.c: Include gdbcmd.h. (mi_async_p): New function. (mi_async, mi_async_1): New globals. (set_mi_async_command, show_mi_async_command, mi_async): New functions. (exec_continue): Call prepare_execution_command. (run_one_inferior, mi_cmd_exec_run, mi_cmd_list_target_features) (mi_execute_async_cli_command): Use mi_async_p. (_initialize_mi_main): Install "set mi-async". Make "target-async" a deprecated alias. 2014-05-29 Pedro Alves <palves@redhat.com> Tom Tromey <tromey@redhat.com> * gdb.texinfo (Non-Stop Mode): Remove "set target-async 1" from example. (Asynchronous and non-stop modes): Document '-gdb-set mi-async'. Mention that target-async is now deprecated. (Maintenance Commands): Document maint set/show target-async. 2014-05-29 Pedro Alves <palves@redhat.com> Tom Tromey <tromey@redhat.com> * gdb.base/async-shell.exp: Don't enable target-async. * gdb.base/async.exp * gdb.base/corefile.exp (corefile_test_attach): Remove 'async' parameter. Adjust. (top level): Don't test with "target-async". * gdb.base/dprintf-non-stop.exp: Don't enable target-async. * gdb.base/gdb-sigterm.exp: Don't test with "target-async". * gdb.base/inferior-died.exp: Don't enable target-async. * gdb.base/interrupt-noterm.exp: Likewise. * gdb.mi/mi-async.exp: Use "mi-async" instead of "target-async". * gdb.mi/mi-nonstop-exit.exp: Likewise. * gdb.mi/mi-nonstop.exp: Likewise. * gdb.mi/mi-ns-stale-regcache.exp: Likewise. * gdb.mi/mi-nsintrall.exp: Likewise. * gdb.mi/mi-nsmoribund.exp: Likewise. * gdb.mi/mi-nsthrexec.exp: Likewise. * gdb.mi/mi-watch-nonstop.exp: Likewise. * gdb.multi/watchpoint-multi.exp: Adjust comment. * gdb.python/py-evsignal.exp: Don't enable target-async. * gdb.python/py-evthreads.exp: Likewise. * gdb.python/py-prompt.exp: Likewise. * gdb.reverse/break-precsave.exp: Don't test with "target-async". * gdb.server/solib-list.exp: Don't enable target-async. * gdb.threads/thread-specific-bp.exp: Likewise. * lib/mi-support.exp: Adjust to use mi-async.
2014-05-29PR gdb/13860 - Make MI sync vs async output (closer to) the same.Pedro Alves1-21/+2
Ignoring expected and desired differences like whether the prompt is output after *stoppped records, GDB MI output is still different in sync and async modes. In sync mode, when a CLI execution command is entered, the "reason" field is missing in the *stopped async record. And in async mode, for some events, like program exits, the corresponding CLI output is missing in the CLI channel. Vis, diff between sync vs async modes: run ^running *running,thread-id="1" (gdb) ... - ~"[Inferior 1 (process 15882) exited normally]\n" =thread-exited,id="1",group-id="i1" =thread-group-exited,id="i1",exit-code="0" - *stopped + *stopped,reason="exited-normally" si ... (gdb) ~"0x000000000045e033\t29\t memset (&args, 0, sizeof args);\n" - *stopped,frame=...,thread-id="1",stopped-threads="all",core="0" + *stopped,reason="end-stepping-range",frame=...,thread-id="1",stopped-threads="all",core="0" (gdb) In addition, in both cases, when a MI execution command is entered, and a breakpoint triggers, the event is sent to the console too. But some events like program exits have the CLI output missing in the CLI channel: -exec-run ^running *running,thread-id="1" (gdb) ... =thread-exited,id="1",group-id="i1" =thread-group-exited,id="i1",exit-code="0" - *stopped + *stopped,reason="exited-normally" We'll want to make background commands always possible by default. IOW, make target-async be the default. But, in order to do that, we'll need to emulate MI sync on top of an async target. That means we'll have yet another combination to care for in the testsuite. Rather than making the testsuite cope with all these differences, I thought it better to just fix GDB to always have the complete output, no matter whether it's in sync or async mode. This is all related to interpreter-exec, and the corresponding uiout switching. (Typing a CLI command directly in MI is shorthand for running it through -interpreter-exec console.) In sync mode, when a CLI command is active, normal_stop is called when the current interpreter and uiout are CLI's. So print_XXX_reason prints the stop reason to CLI uiout (only), and we don't show it in MI. In async mode the stop event is processed when we're back in the MI interpreter, so the stop reason is printed directly to the MI uiout. Fix this by making run control event printing roughly independent of whatever is the current interpreter or uiout. That is, move these prints to interpreter observers, that know whether to print or be quiet, and if printing, which uiout to print to. In the case of the console/tui interpreters, only print if the top interpreter. For MI, always print. Breakpoint hits / normal stops are already handled similarly -- MI has a normal_stop observer that prints the event to both MI and the CLI, though that could be cleaned up further in the direction of this patch. This also makes all of: (gdb) foo and (gdb) interpreter-exec MI "-exec-foo" and (gdb) -exec-foo and (gdb) -interpreter-exec console "foo" print as expected. Tested on x86_64 Fedora 20, sync and async modes. gdb/ 2014-05-29 Pedro Alves <palves@redhat.com> PR gdb/13860 * cli/cli-interp.c: Include infrun.h and observer.h. (cli_uiout, cli_interp): New globals. (cli_on_signal_received, cli_on_end_stepping_range) (cli_on_signal_exited, cli_on_exited, cli_on_no_history): New functions. (cli_interpreter_init): Install them as 'end_stepping_range', 'signal_received' 'signal_exited', 'exited' and 'no_history' observers. (_initialize_cli_interp): Remove cli_interp local. * infrun.c (handle_inferior_event): Call the several stop reason observers instead of printing the stop reason directly. (end_stepping_range): New function. (print_end_stepping_range_reason, print_signal_exited_reason) (print_exited_reason, print_signal_received_reason) (print_no_history_reason): Make static, and add an uiout parameter. Print to that instead of to CURRENT_UIOUT. * infrun.h (print_end_stepping_range_reason) (print_signal_exited_reason, print_exited_reason) (print_signal_received_reason print_no_history_reason): New declarations. * mi/mi-common.h (struct mi_interp): Rename 'uiout' field to 'mi_uiout'. <cli_uiout>: New field. * mi/mi-interp.c (mi_interpreter_init): Adjust. Create the new uiout for CLI output. Install 'signal_received', 'end_stepping_range', 'signal_exited', 'exited' and 'no_history' observers. (find_mi_interpreter, mi_interp_data, mi_on_signal_received) (mi_on_end_stepping_range, mi_on_signal_exited, mi_on_exited) (mi_on_no_history): New functions. (ui_out_free_cleanup): Delete function. (mi_on_normal_stop): Don't allocate a new uiout for CLI output, instead use the one already stored in the MI interpreter data. (mi_ui_out): Adjust. * tui/tui-interp.c: Include infrun.h and observer.h. (tui_interp): New global. (tui_on_signal_received, tui_on_end_stepping_range) (tui_on_signal_exited, tui_on_exited) (tui_on_no_history): New functions. (tui_init): Install them as 'end_stepping_range', 'signal_received' 'signal_exited', 'exited' and 'no_history' observers. (_initialize_tui_interp): Delete tui_interp local. gdb/doc/ 2014-05-29 Pedro Alves <palves@redhat.com> PR gdb/13860 * observer.texi (signal_received, end_stepping_range) (signal_exited, exited, no_history): New observer subjects. gdb/testsuite/ 2014-05-29 Pedro Alves <palves@redhat.com> PR gdb/13860 * gdb.mi/mi-cli.exp: Always expect "end-stepping-range" stop reason, even in sync mode.
2014-05-29PR15693 - Fix spurious *running events, thread state, dprintf-style callPedro Alves4-0/+236
If one sets a breakpoint with a condition that involves calling a function in the inferior, and then the condition evaluates false, GDB outputs one *running event for each time the program hits the breakpoint. E.g., $ gdb return-false -i=mi (gdb) start ... (gdb) b 14 if return_false () &"b 14 if return_false ()\n" ~"Breakpoint 2 at 0x4004eb: file return-false.c, line 14.\n" ... ^done (gdb) c &"c\n" ~"Continuing.\n" ^running *running,thread-id=(...) (gdb) *running,thread-id=(...) *running,thread-id=(...) *running,thread-id=(...) *running,thread-id=(...) *running,thread-id=(...) ... repeat forever ... An easy way a user can trip on this is with a dprintf with "set dprintf-style call". In that case, a dprintf is just a breakpoint that when hit GDB calls the printf function in the inferior, and then resumes it, just like the case above. If the breakpoint/dprintf is set in a loop, then these spurious events can potentially slow down a frontend much, if it decides to refresh its GUI whenever it sees this event (Eclipse is one such case). When we run an infcall, we pretend we don't actually run the inferior. This is already handled for the usual case of calling a function directly from the CLI: (gdb) p return_false () &"p return_false ()\n" ~"$1 = 0" ~"\n" ^done (gdb) Note no *running, nor *stopped events. That's handled by: static void mi_on_resume (ptid_t ptid) { ... /* Suppress output while calling an inferior function. */ if (tp->control.in_infcall) return; and equivalent code on normal_stop. However, in the cases of the PR, after finishing the infcall there's one more resume, and mi_on_resume doesn't know that it should suppress output then too, somehow. The "running/stopped" state is a high level user/frontend state. Internal stops are invisible to the frontend. If follows from that that we should be setting the thread to running at a higher level where we still know the set of threads the user _intends_ to resume. Currently we mark a thread as running from within target_resume, a low level target operation. As consequence, today, if we resume a multi-threaded program while stopped at a breakpoint, we see this: -exec-continue ^running *running,thread-id="1" (gdb) *running,thread-id="all" The first *running was GDB stepping over the breakpoint, and the second is GDB finally resuming everything. Between those two *running's, threads other than "1" still have their state set to stopped. That's bogus -- in async mode, this opens a tiny window between both resumes where the user might try to run another execution command to threads other than thread 1, and very much confuse GDB. That is, the "step" below should fail the "step", complaining that the thread is running: (gdb) c -a & (gdb) thread 2 (gdb) step IOW, threads that GDB happens to not resume immediately (say, because it needs to step over a breakpoint) shall still be marked as running. Then, if we move marking threads as running to a higher layer, decoupled from target_resume, plus skip marking threads as running when running an infcall, the spurious *running events disappear, because there will be no state transitions at all. I think we might end up adding a new thread state -- THREAD_INFCALL or some such, however since infcalls are always synchronous today, I didn't find a need. There's no way to execute a CLI/MI command directly from the prompt if some thread is running an infcall. Tested on x86_64 Fedora 20. gdb/ 2014-05-29 Pedro Alves <palves@redhat.com> PR PR15693 * infrun.c (resume): Determine how much to resume depending on whether the caller wanted a step, not whether we can hardware step the target. Mark all threads that we intend to run as running, unless we're calling an inferior function. (normal_stop): If the thread is running an infcall, don't finish thread state. * target.c (target_resume): Don't mark threads as running here. gdb/testsuite/ 2014-05-29 Pedro Alves <palves@redhat.com> Hui Zhu <hui@codesourcery.com> PR PR15693 * gdb.mi/mi-condbreak-call-thr-state-mt.c: New file. * gdb.mi/mi-condbreak-call-thr-state-st.c: New file. * gdb.mi/mi-condbreak-call-thr-state.c: New file. * gdb.mi/mi-condbreak-call-thr-state.exp: New file.
2014-05-21PR gdb/13860: don't lose '-interpreter-exec console EXECUTION_COMMAND''s ↵Pedro Alves2-7/+56
output in async mode. The other part of PR gdb/13860 is about console execution commands in MI getting their output half lost. E.g., take the finish command, executed on a frontend's GDB console: sync: finish &"finish\n" ~"Run till exit from #0 usleep (useconds=10) at ../sysdeps/unix/sysv/linux/usleep.c:27\n" ^running *running,thread-id="1" (gdb) ~"0x00000000004004d7 in foo () at stepinf.c:6\n" ~"6\t usleep (10);\n" ~"Value returned is $1 = 0\n" *stopped,reason="function-finished",frame={addr="0x00000000004004d7",func="foo",args=[],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="6"},thread-id="1",stopped-threads="all",core="1" async: finish &"finish\n" ~"Run till exit from #0 usleep (useconds=10) at ../sysdeps/unix/sysv/linux/usleep.c:27\n" ^running *running,thread-id="1" (gdb) *stopped,reason="function-finished",frame={addr="0x00000000004004d7",func="foo",args=[],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="6"},gdb-result-var="$1",return-value="0",thread-id="1",stopped-threads="all",core="0" Note how all the "Value returned" etc. output is missing in async mode. The same happens with e.g., catchpoints: =breakpoint-modified,bkpt={number="1",type="catchpoint",disp="keep",enabled="y",what="22016",times="1"} ~"\nCatchpoint " ~"1 (forked process 22016), 0x0000003791cbd8a6 in __libc_fork () at ../nptl/sysdeps/unix/sysv/linux/fork.c:131\n" ~"131\t pid = ARCH_FORK ();\n" *stopped,reason="fork",disp="keep",bkptno="1",newpid="22016",frame={addr="0x0000003791cbd8a6",func="__libc_fork",args=[],file="../nptl/sysdeps/unix/sysv/linux/fork.c",fullname="/usr/src/debug/glibc-2.14-394-g8f3b1ff/nptl/sysdeps/unix/sysv/linux/fork.c",line="131"},thread-id="1",stopped-threads="all",core="0" where all those ~ lines are missing in async mode, or just the "step" current line indication: s &"s\n" ^running *running,thread-id="all" (gdb) ~"13\t foo ();\n" *stopped,frame={addr="0x00000000004004ef",func="main",args=[{name="argc",value="1"},{name="argv",value="0x7fffffffdd78"}],file="stepinf.c",fullname="/home/pedro/gdb/tests/stepinf.c",line="13"},thread-id="1",stopped-threads="all",core="3" (gdb) Or in the case of the PRs example, the "Stopped due to shared library event" note: start &"start\n" ~"Temporary breakpoint 1 at 0x400608: file ../../../src/gdb/testsuite/gdb.mi/solib-main.c, line 21.\n" =breakpoint-created,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x0000000000400608",func="main",file="../../../src/gdb/testsuite/gdb.mi/solib-main.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.mi/solib-main.c",line="21",times="0",original-location="main"} ~"Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/solib-main \n" =thread-group-started,id="i1",pid="21990" =thread-created,id="1",group-id="i1" ^running *running,thread-id="all" (gdb) =library-loaded,id="/lib64/ld-linux-x86-64.so.2",target-name="/lib64/ld-linux-x86-64.so.2",host-name="/lib64/ld-linux-x86-64.so.2",symbols-loaded="0",thread-group="i1" ~"Stopped due to shared library event (no libraries added or removed)\n" *stopped,reason="solib-event",thread-id="1",stopped-threads="all",core="3" (gdb) IMO, if you're typing execution commands in a frontend's console, you expect to see their output. Indeed it's what you get in sync mode. I think async mode should do the same. Deciding what to mirror to the console wrt to breakpoints and random stops gets messy real fast. E.g., say "s" trips on a breakpoint. We'd clearly want to mirror the event to the console in this case. But what about more complicated cases like "s&; thread n; s&", and one of those steps spawning a new thread, and that thread hitting a breakpoint? It's impossible in general to track whether the thread had any relation to the commands that had been executed. So I think we should just simplify and always mirror breakpoints and random events to the console. Notes: - mi->out is the same as gdb_stdout when MI is the current interpreter. I think that referring to that directly is cleaner. An earlier revision of this patch made the changes that are now done in mi_on_normal_stop directly in infrun.c:normal_stop, and so not having an obvious place to put the new uiout by then, and not wanting to abuse CLI's uiout, I made a temporary uiout when necessary. - Hopefuly the rest of the patch is more or less obvious given the comments added. Tested on x86_64 Fedora 20, no regressions. 2014-05-21 Pedro Alves <palves@redhat.com> PR gdb/13860 * gdbthread.h (struct thread_control_state): New field `command_interp'. * infrun.c (follow_fork): Copy the new thread control field to the child fork thread. (clear_proceed_status_thread): Clear the new thread control field. (proceed): Set the new thread control field. * interps.h (command_interp): Declare. * interps.c (command_interpreter): New global. (command_interp): New function. (interp_exec): Set `command_interpreter' while here. * cli-out.c (cli_uiout_dtor): New function. (cli_ui_out_impl): Install it. * mi/mi-interp.c: Include cli-out.h. (mi_cmd_interpreter_exec): Add comment. (restore_current_uiout_cleanup): New function. (ui_out_free_cleanup): New function. (mi_on_normal_stop): If finishing an execution command started by a CLI command, or any kind of breakpoint-like event triggered, print the stop event to the output (CLI) stream. * mi/mi-out.c (mi_ui_out_impl): Install NULL `dtor' handler. 2014-05-21 Pedro Alves <palves@redhat.com> PR gdb/13860 * gdb.mi/mi-cli.exp (line_callee4_next_step): New global. (top level): Test that output related to execution commands is sent to the console with CLI commands, but not with MI commands. Test that breakpoint events are always mirrored to the console. Also expect the new source line to be output after a "next" in async mode too. Make it a pass/fail test. * gdb.mi/mi-solib.exp: Test that the CLI solib event note is output. * lib/mi-support.exp (mi_gdb_expect_cli_output): New procedure.
2014-05-21PR gdb/13860: make -interpreter-exec console "list" behave more like "list".Pedro Alves1-0/+20
I noticed that "list" behaves differently in CLI vs MI. Particularly: $ ./gdb -nx -q ./testsuite/gdb.mi/mi-cli Reading symbols from /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/mi-cli...done. (gdb) start Temporary breakpoint 1 at 0x40054d: file ../../../src/gdb/testsuite/gdb.mi/basics.c, line 62. Starting program: /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/mi-cli Temporary breakpoint 1, main () at ../../../src/gdb/testsuite/gdb.mi/basics.c:62 62 callee1 (2, "A string argument.", 3.5); (gdb) list 57 { 58 } 59 60 main () 61 { 62 callee1 (2, "A string argument.", 3.5); 63 callee1 (2, "A string argument.", 3.5); 64 65 do_nothing (); /* Hello, World! */ 66 (gdb) Note the list started at line 57. IOW, the program stopped at line 62, and GDB centered the list on that. compare with: $ ./gdb -nx -q ./testsuite/gdb.mi/mi-cli -i=mi =thread-group-added,id="i1" ~"Reading symbols from /home/pedro/gdb/mygit/build/gdb/testsuite/gdb.mi/mi-cli..." ~"done.\n" (gdb) start &"start\n" ... ~"\nTemporary breakpoint " ~"1, main () at ../../../src/gdb/testsuite/gdb.mi/basics.c:62\n" ~"62\t callee1 (2, \"A string argument.\", 3.5);\n" *stopped,reason="breakpoint-hit",disp="del",bkptno="1",frame={addr="0x000000000040054d",func="main",args=[],file="../../../src/gdb/testsuite/gdb.mi/basics.c",fullname="/home/pedro/gdb/mygit/src/gdb/testsuite/gdb.mi/basics.c",line="62"},thread-id="1",stopped-threads="all",core="0" =breakpoint-deleted,id="1" (gdb) -interpreter-exec console list ~"62\t callee1 (2, \"A string argument.\", 3.5);\n" ~"63\t callee1 (2, \"A string argument.\", 3.5);\n" ~"64\t\n" ~"65\t do_nothing (); /* Hello, World! */\n" ~"66\t\n" ~"67\t callme (1);\n" ~"68\t callme (2);\n" ~"69\t\n" ~"70\t return 0;\n" ~"71\t}\n" ^done (gdb) Here the list starts at line 62, where the program was stopped. This happens because print_stack_frame, called from both normal_stop and mi_on_normal_stop, is the function responsible for setting the current sal from the selected frame, overrides the PRINT_WHAT argument, and only after that does it decide whether to center the current sal line or not, based on the overridden value, and it will always decide false. (The print_stack_frame call in mi_on_normal_stop is a little different from the call in normal_stop, in that it is an unconditional SRC_AND_LOC call. A future patch will make those uniform.) A previous version of this patch made MI uniform with CLI here, by making print_stack_frame also center when MI is active. That changed the output of a "list" command in mi-cli.exp, to expect line 57 instead of 62, as per the example above. However, looking deeper, that list in question is the first "list" after the program stops, and right after the stop, before the "list", the test did "set listsize 1". Let's try the same thing with the CLI: (gdb) start 62 callee1 (2, "A string argument.", 3.5); (gdb) set listsize 1 (gdb) list 57 { Huh, that's unexpected. Why the 57? It's because print_stack_frame, called in reaction to the breakpoint stop, expecting the next "list" to show 10 lines (the listsize at the time) around line 62, sets the lines listed range to 57-67 (62 +/- 5). If the user changes the listsize before "list", why would we still show that range? Looks bogus to me. So the fix for this whole issue should be delay trying to center the listing to until actually listing, so that the correct listsize can be taken into account. This makes MI and CLI uniform too, as it deletes the center code from print_stack_frame. A series of tests are added to list.exp to cover this. mi-cli.exp was after all correct all along, but it now gains an additional test that lists lines with listsize 10, to ensure the centering is consistent with CLI's. One related Python test changed related output -- it's a test that prints the line number after stopping for a breakpoint, similar to the new list.exp tests. Previously we'd print the stop line minus 5 (due to the premature centering), now we print the stop line. I think that's a good change. Tested on x86_64 Fedora 20. gdb/ 2014-05-21 Pedro Alves <palves@redhat.com> * cli/cli-cmds.c (list_command): Handle the first "list" after the current source line having changed. * frame.h (set_current_sal_from_frame): Remove 'center' parameter. * infrun.c (normal_stop): Adjust call to set_current_sal_from_frame. * source.c (clear_lines_listed_range): New function. (set_current_source_symtab_and_line, identify_source_line): Clear the lines listed range. (line_info): Handle the first "info line" after the current source line having changed. * stack.c (print_stack_frame): Remove center handling. (set_current_sal_from_frame): Remove 'center' parameter. Don't center sal.line. gdb/testsuite/ 2014-05-21 Pedro Alves <palves@redhat.com> * gdb.base/list.exp (build_pattern, test_list): New procedures. Use them to test variations of "list" after reaching a breakpoint. * gdb.mi/mi-cli.exp (line_main_callme_2): New global. Test "list" with listsize 10 after reaching a breakpoint. * gdb.python/python.exp (decode_line current location line number): Adjust expected line number.
2014-05-14Fix mi-file.exp fails on remote hostYao Qi1-2/+6
This patch fixes mi-file.exp fails on remote host. First, we can't assume ${srcdir}/${subdir}/${srcfile} directory exists on remote host, so this patch changes it to match ${srcfile} only on remote host. Second, regexp pattern ".*/${srcfile}" isn't friendly to Windows path. The file name is "basics.c" in my test env and can't match the pattern due to "/" in it. Remove "/" from the pattern. gdb/testsuite: 2014-05-14 Yao Qi <yao@codesourcery.com> * gdb.mi/mi-file.exp (test_file_list_exec_source_file): Don't match absolute path on remote host. (test_file_list_exec_source_files): Remove "/" from the pattern.
2014-04-23Introduce some new MI test suite cleanups for breakpoint andKeith Seitz16-106/+181
breakpoint table handling. This is a patch in five parts (all committed here in one commit). ----- 1/5: parse_args parse_args is a very useful utility function which allows you to do getopt-y kinds of things in Tcl. Example: proc myproc {foo args} { parse_args {{bar} {baz "abc"} {qux}} # ... } myproc ABC -bar -baz DEF peanut butter will define the following variables in myproc: foo (=ABC), bar (=1), baz (=DEF), and qux (=0) args will be the list {peanut butter} ----- 2/5: mi_build_kv_pairs build_kv_pairs simply does what it says: given the input list and an option join string, it combines list elements into kv-pairs for MI handling. It knows how to handle tuples and other special MI types. Example: mi_build_kv_pairs {a b c d e f g \[.*\]} returns a=\"b\",c=\"d\",e=\"f\",g=\[.*\] ----- 3/5: mi_make_breakpoint This function builds breakpoint regexps, such as "bkpt={number=\".*\", [snip]}". Note that ONLY the options given to mi_make_breakpoint/mi_create_breakpoint will actually be tested. So if -number is omitted, the regexp will allow anything [number=\".*\"] Examples: mi_make_breakpoint -number 3 mi_create_breakpoint "myfile.c:21" -file myfile.c -line 21 ----- 4/5: mi_make_breakpoint_table This function builds MI breakpoint table regexps. Example: set bps {} lappend bps [mi_make_breakpoint -number 1 -func "main" \ -file ".*/myfile.c" -line 42 lappend bps [mi_make_breakpoint -number 2 -func "marker" \ -file ".*myfile.c" -line 21 gdb_test "-break-info" "\\^done,[mi_make_breakpoint_table $bps]" \ "breakpoint list" ----- 5/5: Update all callers Self-explanatory testsuite/ChangeLog 2014-04-23 Keith Seitz <keiths@redhat.com> * lib/mi-support.exp (mi_list_breakpoints): Delete. (mi_make_breakpoint_table): New procedure. (mi_create_breakpoint): Use mi_make_breakpoint and return the result. (mi_make_breakpoint): New procedure. (mi_build_kv_pairs): New procedure. * gdb.mi/mi-break.exp: Remove unused globals, update mi_create_breakpoint usage, and use mi_make_breakpoint_table. All callers updated. * gdb.mi/mi-dprintf.exp: Use variable to track command number. Update all callers of mi_create_breakpoint and use mi_make_breakpoint_table. Remove any unused global variables. * gdb.mi/mi-nonstop.exp: Likewise. * gdb.mi/mi-nsintrall.exp: Likewise. * gdb.mi/mi-nsmoribund.exp: Likewise. * gdb.mi/mi-nsthrexec.exp: Likewise. * gdb.mi/mi-reverse.exp: Likewise. * gdb.mi/mi-simplerun.exp: Likewise. * gdb.mi/mi-stepn.exp: Likewise. * gdb.mi/mi-syn-frame.exp: Likewise. * gdb.mi/mi-until.exp: Likewise. * gdb.mi/mi-var-cp.exp: Likewise. * gdb.mi/mi-var-display.exp: Likewise. * gdb.mi/mi2-amd64-entry-value.exp: Likewise. * gdb.mi/mi2-var-child.exp: Likewise. * gdb.mi/mi-vla-c99.exp: Likewise. * lib/mi-support.exp: Likewise. From Ian Lance Taylor <iant@cygnus.com>: * lib/gdb.exp (parse_args): New procedure.
2014-04-15Remove unused globals in mi-simplerun.exp.Keith Seitz1-9/+0
2014-04-15 Keith Seitz <keiths@redhat.com> * gdb.mi/mi-simplerun.exp (test_breakpoints_creation_and_listing): Remove unused globals. (test_running_the_program): Likewise. (test_controlled_execution): Likewise. (test_controlling_breakpoints): Likewise. (test_program_termination): Likewise.
2014-04-15Test suite cleanup.Keith Seitz1-17/+9
2014-04-15 Keith Seitz <keiths@redhat.com> * gdb.mi/mi-break.exp (test_tbreak_creation_and_listing): Remove unused globals. (test_rbreak_creation_and_listing): Likewise. (test_ignore_count): Likewise. (test_error): Likewise.
2014-04-14test: add mi vla testSanimir Agovic2-0/+119
testsuite/ChangeLog: * gdb.mi/mi-vla-c99.exp: New file. * gdb.mi/vla.c: New file.