aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
AgeCommit message (Collapse)AuthorFilesLines
2014-01-01Update Copyright year range in all files maintained by GDB.Joel Brobecker2114-2114/+2114
2013-12-19Fix PR breakpoints/16297: catch syscall with syscall 0Gabriel Krisman Bertazi3-5/+34
Code rationale ============== by: Gabriel Krisman Bertazi This is a fix for bug 16297. The problem occurs when the user attempts to catch any syscall 0 (such as syscall read on Linux/x86_64). GDB was not able to catch the syscall and was missing the breakpoint. Now, breakpoint_hit_catch_syscall returns immediately when it finds the correct syscall number, avoiding a following check for the end of the search vector, that returns a no hit if the syscall number was zero. Testcase rationale ================== by: Sergio Durigan Junior This testcase is a little difficult to write. By doing a quick inspection at the Linux source, one can see that, in many targets, the syscall number 0 is restart_syscall, which is forbidden to be called from userspace. Therefore, on many targets, there's just no way to test this safely. My decision was to take the simpler route and just adds the "read" syscall on the default test. Its number on x86_64 is zero, which is "good enough" since many people here do their tests on x86_64 anyway and it is a popular architecture. However, there was another little gotcha. When using "read" passing 0 as the third parameter (i.e., asking it to read 0 bytes), current libc implementations could choose not to effectively call the syscall. Therefore, the best solution was to create a temporary pipe, write 1 byte into it, and then read this byte from it. gdb/ChangeLog 2013-12-19 Gabriel Krisman Bertazi <gabriel@krisman.be> PR breakpoints/16297 * breakpoint.c (breakpoint_hit_catch_syscall): Return immediately when expected syscall is hit. gdb/testsuite/ChangeLog 2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com> PR breakpoints/16297 * gdb.base/catch-syscall.c (read_syscall, pipe_syscall) (write_syscall): New variables. (main): Create a pipe, write 1 byte in it, and read 1 byte from it. * gdb.base/catch-syscall.exp (all_syscalls): Include "pipe, "write" and "read" syscalls. (fill_all_syscalls_numbers): Improve the way to obtain syscalls numbers.
2013-12-19fortran: enable ptype/whatis for modules.Keven Boell3-3/+28
Added new domain MODULE_DOMAIN for fortran modules to avoid issues with sharing namespaces (e.g. when a variable currently in scope has the same name as a module). (gdb) ptype modname old> No symbol "modname" in current context. new> type = module modname This fixes PR 15209 and also addresses the issue with sharing namespaces: https://sourceware.org/ml/gdb-patches/2013-02/msg00643.html 2013-11-19 Keven Boell <keven.boell@intel.com> Sanimir Agovic <sanimir.agovic@intel.com> * cp-namespace.c (cp_lookup_nested_symbol): Enable nested lookups for fortran modules. * dwarf2read.c (read_module): Add fortran module to the symbol table. (add_partial_symbol, add_partial_module): Add fortran module to the partial symbol table. (new_symbol_full): Create full symbol for fortran module. * f-exp.y (yylex): Add new module domain to be parsed. * symtab.h: New domain for fortran modules. testsuite/ * gdb.fortran/module.exp: Completion matches fortran module names as well. ptype/whatis on modules return a proper type. Add new check for having the correct scope.
2013-12-19fortran: enable ptype/whatis for user defined types.Keven Boell3-0/+81
(gdb) ptype type old> No symbol "type" in current context. new> type = Type type integer(kind=4) :: t_i End Type type 2013-11-19 Sanimir Agovic <sanimir.agovic@intel.com> Keven Boell <keven.boell@intel.com> * f-exp.y (yylex): Add domain array to enable lookup in multiple domains. Loop over lookup domains and try to find requested symbol. Add STRUCT_DOMAIN to lookup domains to be able to query for user defined types. testsuite/ * gdb.fortran/type.f90: New file. * gdb.fortran/whatis_type.f90: New file.
2013-12-18Improve and fix catch-syscall.expSergio Durigan Junior3-98/+91
While fixing another bug, I found that the current gdb.base/catch-syscall.exp is kind of messy, could use some improvements, and is not correctly testing some things. I've made the following patch to address all the issues I found. On the organization side, it does a cleanup and removes unecessary imports of gdb_prompt, uses prepare_for_testing and clean_restart where needed, and fixes some comments. The testcase was also not correctly testing catching syscalls using only numbers, or catching many syscalls at once. I fixed that. The patch also uses a new method for obtaining the syscalls numbers: it relies on the C source file to get them, via <sys/syscall.h> and SYS_* macros. This makes the .exp file simpler because there is no need to include target conditionals there. I tested this on x86_64 Fedora 18. gdb/testsuite/ChangeLog: 2013-12-18 Sergio Durigan Junior <sergiodj@redhat.com> * gdb.base/catch-syscall.c: Include <sys/syscall.h>. (close_syscall, chroot_syscall, exit_group_syscall): New variables. * gdb.base/catch-syscall.exp: Replace gdb_compile by prepare_for_testing. Call fill_all_syscalls_numbers before starting. Replace gdb_exit, gdb_start, gdb_reinitialize_dir and gdb_load by clean_restart. (check_info_bp_any_syscall, check_info_bp_specific_syscall) (check_info_bp_many_syscalls): Remove global gdb_prompt. (check_call_to_syscall): Likewise. Add global decimal. Improve testing regex. (check_return_from_syscall): Likewise. (check_continue, insert_catch_syscall_with_arg): Remove global gdb_prompt. (insert_catch_syscall_with_many_args): Likewise. Add global decimal. Fix $filter_str. Improve testing regex. (check_for_program_end): Remove global gdb_prompt. (test_catch_syscall_without_args): Likewise. Add global decimal. Improve testing regex. (test_catch_syscall_with_args, test_catch_syscall_with_many_args) (test_catch_syscall_with_wrong_args) (test_catch_syscall_restarting_inferior) (test_catch_syscall_fail_nodatadir): Remove global gdb_prompt. (do_syscall_tests): Likewise. Remove global srcdir. (test_catch_syscall_without_args_noxml): Remove global gdb_prompt. Add global last_syscall_number. Test for the exact syscall number to be caught. (test_catch_syscall_with_args_noxml): Remove global gdb_prompt. Add global all_syscalls_numbers. Test each syscall number to be caught, instead of only testing "close". (test_catch_syscall_with_wrong_args_noxml): Remove global gdb_prompt. (do_syscall_tests_without_xml): Likewise. Remove global srcdir. Remove stale comment. (fill_all_syscalls_numbers): Add global last_syscall_number. Fill the correct syscall numbers using information from the inferior.
2013-12-17"tfind" across unavailable-stack frames.Pedro Alves2-2/+8
Like when stepping, the current stack frame location is expected to be printed as result of tfind command, if that results in moving to a different function. In tfind_1 we see: if (from_tty && (has_stack_frames () || traceframe_number >= 0)) { enum print_what print_what; /* NOTE: in imitation of the step command, try to determine whether we have made a transition from one function to another. If so, we'll print the "stack frame" (ie. the new function and it's arguments) -- otherwise we'll just show the new source line. */ if (frame_id_eq (old_frame_id, get_frame_id (get_current_frame ()))) print_what = SRC_LINE; else print_what = SRC_AND_LOC; print_stack_frame (get_selected_frame (NULL), 1, print_what, 1); do_displays (); } However, when we haven't collected any registers in the tracepoint (collect $regs), that doesn't actually work: (gdb) tstart (gdb) info tracepoints Num Type Disp Enb Address What 1 tracepoint keep y 0x080483b7 in func0 at ../.././../git/gdb/testsuite/gdb.trace/circ.c:28 collect testload installed on target 2 tracepoint keep y 0x080483bc in func1 at ../.././../git/gdb/testsuite/gdb.trace/circ.c:32 collect testload installed on target (gdb) c Continuing. Breakpoint 3, end () at ../.././../git/gdb/testsuite/gdb.trace/circ.c:72 72 } (gdb) tstop (gdb) tfind start Found trace frame 0, tracepoint 1 #0 func0 () at ../.././../git/gdb/testsuite/gdb.trace/circ.c:28 28 } (gdb) tfind Found trace frame 1, tracepoint 2 32 } (gdb) When we don't have info about the stack available (UNWIND_UNAVAILABLE), frames end up with outer_frame_id as frame ID. And in the scenario above, the issue is that both frames before and after the second tfind (the frames for func0 an func1) have the same id (outer_frame_id), so the frame_id_eq check returns false, even though the frames were of different functions. GDB knows that, because the PC is inferred from the tracepoint's address, even if no registers were collected. To fix this, this patch adds support for frame ids with a valid code address, but <unavailable> stack address, and then makes the unwinders use that instead of the catch-all outer_frame_id for such frames. The frame_id_eq check in tfind_1 then automatically does the right thing as expected. I tested with --directory=gdb.trace/ , before/after the patch, and compared the resulting gdb.logs, then adjusted the tests to expect the extra output that came out. Turns out that was only circ.exp, the original test that actually brought this issue to light. Tested on x86_64 Fedora 17, native and gdbserver. gdb/ 2013-12-17 Pedro Alves <palves@redhat.com> * frame.h (enum frame_id_stack_status): New enum. (struct frame_id) <stack_addr>: Adjust comment. <stack_addr_p>: Delete field, replaced with ... <stack_status>: ... this new field. (frame_id_build_unavailable_stack): Declare. * frame.c (frame_addr_hash, fprint_field, outer_frame_id) (frame_id_build_special): Adjust. (frame_id_build_unavailable_stack): New function. (frame_id_build, frame_id_build_wild): Adjust. (frame_id_p, frame_id_eq, frame_id_inner): Adjust to take into account frames with unavailable stack. * amd64-tdep.c (amd64_frame_this_id) (amd64_sigtramp_frame_this_id, amd64_epilogue_frame_this_id): Use frame_id_build_unavailable_stack. * dwarf2-frame.c (dwarf2_frame_this_id): Likewise. * i386-tdep.c (i386_frame_this_id, i386_epilogue_frame_this_id) (i386_sigtramp_frame_this_id): Likewise. gdb/testsuite/ 2013-12-17 Pedro Alves <palves@redhat.com> * gdb.trace/circ.exp: Expect frame info to be printed when switching between frames with unavailable stack, but different functions.
2013-12-17Convert the unavailable vector to be bit, not byte, based.Andrew Burgess3-0/+425
https://sourceware.org/ml/gdb-patches/2013-12/msg00144.html The vector of unavailable parts of a value is currently byte based. Given that we can model a value down to the bit level, we can potentially loose information with the current implementation. After this patch we model the unavailable information in bits. gdb/ChangeLog * dwarf2loc.c (read_pieced_value): Mark bits, not bytes unavailable, use correct bit length. * value.c (struct value): Extend comment on unavailable to indicate that it is bit based. (value_bits_available): New function. (value_bytes_available): Call value_bits_available. (value_entirely_available): Check against the bit length, not byte length. (mark_value_bits_unavailable): New function. (mark_value_bytes_unavailable): Move contents to mark_value_bits_unavailable, call to same. (memcmp_with_bit_offsets): New function. (value_available_contents_bits_eq): New function, takes the functionality from value_available_contents_eq but uses memcmp_with_bit_offsets now, and is bit not byte based. (value_available_contents_eq): Move implementation into value_available_contents_bits_eq, call to same. (value_contents_copy_raw): Work on bits, not bytes. (unpack_value_bits_as_long_1): Check availability in bits, not bytes. * value.h (value_bits_available): Declare new function. (mark_value_bits_unavailable): Declare new function. gdb/testsuite/ChangeLog * gdb.trace/unavailable-dwarf-piece.c: New file. * gdb.trace/unavailable-dwarf-piece.exp: New file.
2013-12-15Perf test case: skip-prologueYao Qi4-0/+165
This patch add a perf test case on skip-prologue by inserting breakpoints on two functions many times, in order to exercise skip-prologue. gdb/testsuite: 2013-12-15 Yao Qi <yao@codesourcery.com> * gdb.perf/skip-prologue.c: New. * gdb.perf/skip-prologue.exp: New. * gdb.perf/skip-prologue.py: New.
2013-12-13wrong dimension found in ada-lang.c:ada_array_bound_from_typeJoel Brobecker6-0/+164
This function has the following code: elt_type = type; for (i = n; i > 1; i--) elt_type = TYPE_TARGET_TYPE (type); For multi-dimension arrays, the code above tries to find the array type corresponding to the dimension we're trying to inspect. The problem is that, past the second dimension, the loop does nothing other than repeat the first iteration. There is a little thinko where it got the TYPE_TARGET_TYPE of TYPE instead of ELT_TYPE! To my surprise, I was unable to produce an Ada exemple that demonstrated the problem. That's because the examples I created all trigger a parallel ___XA type which we then use in place of the ELT_TYPE in order to determine the bounds - see the code that immediately follows our loop above: index_type_desc = ada_find_parallel_type (type, "___XA"); ada_fixup_array_indexes_type (index_type_desc); if (index_type_desc != NULL) [...] So, in order to avoid depending on an Ada example where the compiler can potentially decide one way or the other, I decided to use an artificial example, written in C. With ... int multi[1][2][3]; ... forcing the language to Ada, and trying to print the 'last, we get: (gdb) p multi'last(1) $1 = 0 (gdb) p multi'last(2) $2 = 1 (gdb) p multi'last(3) $3 = 1 <<<--- This should be 2! Additionally, I noticed that a couple of check_typedef's were missing. This patch adds them. And since the variable in question only gets used within an "else" block, I moved the variable declaration and use inside that block - making it clear what the scope of the variable is. gdb/ChangeLog: * ada-lang.c (ada_array_bound_from_type): Move the declaration and assignment of variable "elt_type" inside the else block where it is used. Add two missing check_typedef calls. Fix bug where we got TYPE's TYPE_TARGET_TYPE, where in fact we really wanted to get ELT_TYPE's TYPE_TARGET_TYPE. gdb/testsuite/ChangeLog: * gdb.ada/arraydim: New testcase.
2013-12-122013-12-12 Siva Chandra Reddy <sivachandra@google.com>Siva Chandra3-0/+72
PR python/16113 * NEWS (Python Scripting): Add entry for the new feature and the new attribute of gdb.Field objects. * python/py-type.c (gdbpy_is_field): New function (convert_field): Add 'parent_type' attribute to gdb.Field objects. * python/py-value.c (valpy_getitem): Allow subscript value to be a gdb.Field object. (value_has_field): New function (get_field_flag): New function * python/python-internal.h (gdbpy_is_field): Add declaration. testsuite/ * gdb.python/py-value-cc.cc: Improve test case. * gdb.python/py-value-cc.exp: Add new tests to test usage of gdb.Field objects as subscripts on gdb.Value objects. doc/ * gdb.texinfo (Values From Inferior): Add a note about using gdb.Field objects as subscripts on gdb.Value objects. (Types In Python): Add description about the new attribute "parent_type" of gdb.Field objects.
2013-12-10add missing PR# to previous entryDoug Evans1-0/+1
2013-12-10PR 16286Doug Evans3-0/+32
* c-lang.c (c_get_string): Ignore the declared size of the object if a specific length is requested. testsuite/ * gdb.python/py-value.c: #include stdlib.h, string.h. (str): New struct. (main): New local xstr. * gdb.python/py-value.exp (test_value_in_inferior): Add test to fetch a value as a string with a length beyond the declared length of the array.
2013-12-10Add call to get_compiler_info to gdb_compile_shlib.Andrew Burgess2-2/+14
https://sourceware.org/ml/gdb-patches/2013-12/msg00374.html gdb/testsuite/ChangeLog * lib/gdb.exp (gdb_compile_shlib): Add call to get_compiler_info, update comment.
2013-12-10Set language for Ada minimal symbols.Joel Brobecker2-0/+11
This helps with the following issue: Given an Ada program defining a global variable: package Pck is Watch : Integer := 1974; end Pck; When printing the address of this variable, GDB also tries to print the associated symbol name: (gdb) p watch'address $1 = (access integer) 0x6139d8 <pck__watch> ^^ || The problem is that GDB prints the variable's linkage name, instead of its natural name. This is because the language of the associated minimal symbol never really gets set. This patch adds handling for Ada symbols in symbol_find_demangled_name. After this patch, we now get: (gdb) p watch'address $1 = (access integer) 0x6139d8 <pck.watch> ^ | gdb/ChangeLog: * symtab.c (symbol_find_demangled_name): Add handling of Ada symbols. gdb/testsuite/ChangeLog: * gdb.ada/int_deref.exp: Add test verifying that we print the decoded symbol name when printing the address of Ada symbols.
2013-12-10GDB/MI: Document support for -exec-run --start in -list-featuresJoel Brobecker2-0/+11
This adds "exec-run-start-option" in the output of the -list-features commands, allowing front-ends to easily determine whether -exec-run supports the --start option. gdb/ChangeLog: * mi/mi-main.c (mi_cmd_list_features): add "exec-run-start-option". * NEWS: Expand the entry documenting the new -exec-run --start option to mention the corresponding new entry in the output of "-list-features". gdb/doc/ChangeLog: * gdb.texinfo (GDB/MI Miscellaneous Commands): Document the new "exec-run-start-option" entry in the output of the "-list-features" command. gdb/testsuite/ChangeLog: * gdb.mi/mi-start.exp: Add test verifying that -list-features contains "exec-run-start-option".
2013-12-08Use gdb_produce_sourceYao Qi2-51/+61
We added a new proc gdb_produce_source recently, and it can be used more widely in lib/gdb.exp to generate source file. gdb/testsuite: 2013-12-08 Yao Qi <yao@codesourcery.com> * lib/gdb.exp (support_complex_tests): Use gdb_produce_source. (is_elf_target, is_ilp32_target, is_ilp64_target): Likewise. (is_64_target, is_amd64_regs_target): Likewise. (skip_altivec_tests, skip_vsx_tests, skip_btrace_tests): Likewise.
2013-12-07strip off +x bits on non-executable/script filesMike Frysinger3-0/+5
These files are source files and have no business being +x. We couldn't easily fix it in CVS (you need login+write access to the raw rcs files), but we can fix this w/git. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-12-07gdb: testsuite: fix ksh shebang to use shMike Frysinger4-3/+9
These scripts use /bin/ksh, but they're dirt simple and can be used with /bin/sh, so just change the shebang. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-12-06Fix "info frame" in the outermost frame.Pedro Alves4-0/+608
Doing "info frame" in the outermost frame, when that was indicated by the next frame saying the unwound PC is undefined/not saved, results in error and incomplete output: (gdb) bt #0 thread_function0 (arg=0x0) at threads.c:63 #1 0x00000034cf407d14 in start_thread (arg=0x7ffff7fcb700) at pthread_create.c:309 #2 0x000000323d4f168d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115 (gdb) frame 2 #2 0x000000323d4f168d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:115 115 call *%rax (gdb) info frame Stack level 2, frame at 0x0: rip = 0x323d4f168d in clone (../sysdeps/unix/sysv/linux/x86_64/clone.S:115); saved rip Register 16 was not saved (gdb) Not saved register values are treated as optimized out values internally throughout. stack.c:frame_info is handing unvailable values, but not optimized out ones. The patch deletes the frame_unwind_caller_pc_if_available wrapper function and instead lets errors propagate to frame_info (it's only user). As frame_unwind_pc now needs to be able to handle and cache two different error scenarios, the prev_pc.p variable is replaced with an enumeration. (FWIW, I looked into making gdbarch_unwind_pc or a variant return struct value's instead, but it results in lots of boxing and unboxing for no real gain -- e.g., the mips and arm implementations need to do computation on the unboxed PC value. Might as well throw an error on first attempt to get at invalid contents.) After the patch, we get: (gdb) info frame Stack level 2, frame at 0x0: rip = 0x323d4f168d in clone (../sysdeps/unix/sysv/linux/x86_64/clone.S:115); saved rip = <not saved> Outermost frame: outermost caller of frame at 0x7ffff7fcafc0 source language asm. Arglist at 0x7ffff7fcafb8, args: Locals at 0x7ffff7fcafb8, Previous frame's sp is 0x7ffff7fcafc8 (gdb) A new test is added. It's based off dw2-reg-undefined.exp, and tweaked to mark the return address (rip) of "stop_frame" as undefined. Tested on x86_64 Fedora 17. gdb/ 2013-12-06 Pedro Alves <palves@redhat.com> * frame.c (enum cached_copy_status): New enum. (struct frame_info) <prev_pc.p>: Change type to enum cached_copy_status. (fprint_frame): Handle not saved and unavailable prev_pc values. (frame_unwind_pc_if_available): Delete and merge contents into ... (frame_unwind_pc): ... here. Handle OPTIMIZED_OUT_ERROR. Adjust to use enum cached_copy_status. (frame_unwind_caller_pc_if_available): Delete. (create_new_frame): Adjust. * frame.h (frame_unwind_caller_pc_if_available): Delete declaration. * stack.c (frame_info): Use frame_unwind_caller_pc instead of frame_unwind_caller_pc_if_available, and handle NOT_AVAILABLE_ERROR and OPTIMIZED_OUT_ERROR errors. * valprint.c (val_print_optimized_out): Use val_print_not_saved. (val_print_not_saved): New function. * valprint.h (val_print_not_saved): Declare. gdb/testsuite/ 2013-12-06 Pedro Alves <palves@redhat.com> * gdb.dwarf2/dw2-undefined-ret-addr.S: New file. * gdb.dwarf2/dw2-undefined-ret-addr.c: New file. * gdb.dwarf2/dw2-undefined-ret-addr.exp: New file.
2013-12-06 * gdb.base/break.exp: Fix setting of $baz.Doug Evans2-1/+5
2013-12-06Add support for DW_OP_bit_piece and DW_OP_plus_uconst to DWARF assembler.Andrew Burgess2-0/+14
https://sourceware.org/ml/gdb-patches/2013-12/msg00143.html gdb/testsuite/ChangeLog * lib/dwarf.exp: (Dwarf::_location): Handle DW_OP_bit_piece and DW_OP_plus_uconst.
2013-12-06testsuite: introduce index in varobj child eval.Keven Boell2-1/+17
In some languages, e.g. fortran, arrays start with index 1 instead 0. This patch changes the MI library to support testing varobj children of fortran arrays. 2013-11-21 Keven Boell <keven.boell@intel.com> testsuite/ * lib/mi-support.exp (mi_list_varobj_children_range): Add call to mi_list_array_varobj_children_with_index. (mi_list_array_varobj_children_with_index): New function. Add parameter to specify array start.
2013-12-03Fixed typo in date in testsuite/ChangeLog entryJose E. Marchesi1-1/+1
2013-12-03testsuite: handle SIGLOST/SIGPWR conflict in sparc64-*-linux-gnu targets.Jose E. Marchesi3-4/+20
2013-10-03 Jose E. Marchesi <jose.marchesi@oracle.com> * gdb.base/sigall.exp (test_one_sig): gdb identifies SIGLOST as a SIGPWR in sparc64. * gdb.base/sigall.c (main): In some targets SIGLOST and SIGPWR have the same signal number. Handle this situation.
2013-12-03Ada: Reserved word "all" should not need to be spelled in lowercase.Joel Brobecker5-0/+108
Consider the following code: type Ptr is access all Integer; IP : Ptr := new Integer'(123); IP is the Ada exception of a pointer to an integer. To dereference the pointer and get its value, the user uses the reserved word "all" as follow: (gdb) p ip.all $1 = 123 Ada being a case-insensitive language, the casing should not matter. Unfortunately, for the reserved word "all", things don't work. For instance: (gdb) p ip.ALL Type integer is not a structure or union type This patch fixes the problem. gdb/ChangeLog: * ada-lex.l (find_dot_all): Use strncasecmp instead of strncmp. gdb/testsuite/ChangeLog: * gdb.ada/dot_all: New testcase.
2013-12-03Add "undefined-command" error code at end of ^error result...Joel Brobecker2-0/+37
... when trying to execute an undefined GDB/MI command. When trying to execute a GDB/MI command which does not exist, the current error result record looks like this: -unsupported ^error,msg="Undefined MI command: unsupported" The only indication that the command does not exist is the error message. It would be a little fragile for a consumer to rely solely on the contents of the error message in order to determine whether a command exists or not. This patch improves the situation by adding concept of error code, starting with one well-defined error code ("undefined-command") identifying errors due to a non-existant command. Here is the new output: -unsupported ^error,msg="Undefined MI command: unsupported",code="undefined-command" This error code is only displayed when the corresponding error condition is met. Otherwise, the error record remains unchanged. For instance: -symbol-list-lines foo.adb ^error,msg="-symbol-list-lines: Unknown source file name." For frontends to be able to know whether they can rely on this variable, a new entry "undefined-command-error-code" has been added to the "-list-features" command. Another option would be to always generate an error="..." variable (for the default case, we could decide for instance that the error code is the empty string). But it seems more efficient to provide that info in "-list-features" and then only add the error code when meaningful. gdb/ChangeLog: (from Pedro Alves <palves@redhat.com>) (from Joel Brobecker <brobecker@adacore.com>) * exceptions.h (enum_errors) <UNDEFINED_COMMAND_ERROR>: New enum. * mi/mi-parse.c (mi_parse): Throw UNDEFINED_COMMAND_ERROR instead of a regular error when the GDB/MI command does not exist. * mi/mi-main.c (mi_cmd_list_features): Add "undefined-command-error-code". (mi_print_exception): Print an "undefined-command" error code if EXCEPTION.ERROR is UNDEFINED_COMMAND_ERROR. * NEWS: Add entry documenting the new "code" variable in "^error" result records. gdb/doc/ChangeLog: * gdb.texinfo (GDB/MI Result Records): Fix the syntax of the "^error" result record concerning the error message. Document the error code that may also be part of that result record. (GDB/MI Miscellaneous Commands): Document the "undefined-command-error-code" element in the output of the "-list-features" GDB/MI command. gdb/testsuite/ChangeLog: * gdb.mi/mi-undefined-cmd.exp: New testcase.
2013-12-03New GDB/MI command "-info-gdb-mi-command"Joel Brobecker2-0/+50
This patch adds a new GDB/MI command meant for graphical frontends trying to determine whether a given GDB/MI command exists or not. Examples: -info-gdb-mi-command unsupported-command ^done,command={exists="false"} (gdb) -info-gdb-mi-command symbol-list-lines ^done,command={exists="true"} (gdb) At the moment, this is the only piece of information that this command returns. Eventually, and if needed, we can extend it to provide command-specific pieces of information, such as updates to the command's syntax since inception. This could become, for instance: -info-gdb-mi-command symbol-list-lines ^done,command={exists="true",features=[]} (gdb) -info-gdb-mi-command catch-assert ^done,command={exists="true",features=["conditions"]} In the first case, it would mean that no extra features, while in the second, it announces that the -catch-assert command in this version of the debugger supports a feature called "condition" - exact semantics to be documented with combined with the rest of the queried command's documentation. But for now, we start small, and only worry about existance. And to bootstrap the process, I have added an entry in the output of the -list-features command as well ("info-gdb-mi-command"), allowing the graphical frontends to go through the following process: 1. Send -list-features, collect info from there as before; 2. Check if the output contains "info-gdb-mi-command". If it does, then support for various commands can be queried though -info-gdb-mi-command. Newer commands will be expected to always be checked via this new -info-gdb-mi-command. gdb/ChangeLog: * mi/mi-cmds.h (mi_cmd_info_gdb_mi_command): Declare. * mi/mi-cmd-info.c (mi_cmd_info_gdb_mi_command): New function. * mi/mi-cmds.c (mi_cmds): Add -info-gdb-mi-command command. * mi/mi-main.c (mi_cmd_list_features): Add "info-gdb-mi-command" field to output of "-list-features". * NEWS: Add entry for new -info-gdb-mi-command. gdb/doc/ChangeLog: * gdb.texinfo (GDB/MI Miscellaneous Commands): Document the new -info-gdb-mi-command GDB/MI command. Document the meaning of "-info-gdb-mi-command" in the output of -list-features. gdb/testsuite/ChangeLog: * gdb.mi/mi-i-cmd.exp: New file.
2013-12-02Record objfile->original_name as an absolute pathJan Kratochvil3-0/+35
gdb/ 2013-12-02 Doug Evans <dje@google.com> Jan Kratochvil <jan.kratochvil@redhat.com> * objfiles.c (allocate_objfile): Save original_name as an absolute path. * objfiles.h (struct objfile): Expand comment on original_name. * source.c (openp): Call gdb_abspath. * utils.c (gdb_abspath): New function. * utils.h (gdb_abspath): Declare. gdb/testsuite/ 2013-12-02 Doug Evans <dje@google.com> * gdb.dwarf/dwp-symlink.c: Fake out gdb to not load debug info at start. * gdb.dwarf/dwp-symlink.exp: Test trying to load dwp when the binary has been specified with a relative path and we have chdir'd before accessing the debug info.
2013-11-28Print entirely unavailable struct/union values as a single <unavailable>.Andrew Burgess2-23/+25
When printing an entirely optimized out structure/class/union, we print a single <optimized out> instead of printing <optimized out> for each field. This patch makes an entirely unavailable structure/class/union be likewise displayed with a single "<unavailable>" rather than the whole object with all fields <unavailable>. This seems good because this way the user can quickly tell whether the whole value is unavailable, rather than having to skim all fields. Consistency with optimized out values also seems to be a good thing to have. A few updates to gdb.trace/unavailable.exp where required. Tested on x86_64 Fedora 17, native gdbserver. gdb/ 2013-11-28 Andrew Burgess <aburgess@broadcom.com> Pedro Alves <palves@redhat.com> * valprint.c (value_check_printable): If the value is entirely unavailable, print a single "<unavailable>" instead of printing all subfields. gdb/testsuite/ 2013-11-28 Andrew Burgess <aburgess@broadcom.com> * gdb.trace/unavailable.exp (gdb_collect_args_test): Update expected results. (gdb_collect_locals_test): Likewise. (gdb_collect_globals_test): Likewise.
2013-11-28GDB perf test on disassembleYao Qi4-0/+127
This patch adds a test case to test the performance of GDB doing disassembly. gdb/testsuite/ 2013-11-28 Yao Qi <yao@codesourcery.com> * lib/gdb.exp (with_gdb_prompt): New proc. * gdb.perf/disassemble.exp: New. * gdb.perf/disassemble.py: New.
2013-11-27 * gdb.base/callfuncs.c (main): Assign malloc's return valueLuis Machado6-5/+21
and free it afterwards. * gdb.base/charset-malloc.c (malloc_stub): Likewise. * gdb.base/printcmds.c (main): Likewise. * gdb.base/randomize.c (main): Free "p" and change breakpoint marker position. * gdb.base/setvar.c (dummy): Assign malloc's return value and free it afterwards.
2013-11-26Tighten regexp in gdb.base/setshow.expAndrew Burgess2-2/+7
https://sourceware.org/ml/gdb-patches/2013-11/msg00817.html gdb/testsuite/ChangeLog * gdb.base/setshow.exp: Add $gdb_prompt to the patterns in gdb_test_multiple.
2013-11-26revert patch from 2013-11-22Tom Tromey4-287/+6
This reverts da2b2fdf57a96f7a5b6b153e94afb747e212b17f and some follow-up patches. They were incorrect. 2013-11-26 Tom Tromey <tromey@redhat.com> * dwarf2-frame.c (dwarf2_frame_cache): Revert patch from 2013-11-22. 2013-11-26 Tom Tromey <tromey@redhat.com> * gdb.dwarf2/dw2-unspecified-ret-addr.S: Remove. * gdb.dwarf2/dw2-unspecified-ret-addr.c: Remove. * gdb.dwarf2/dw2-unspecified-ret-addr.exp: Remove.
2013-11-25PR c++/14819: Explicit class:: inside class scope does not workKeith Seitz3-0/+271
https://sourceware.org/ml/gdb-patches/2013-11/msg00102.html
2013-11-25GDB perf test on backtraceYao Qi4-0/+176
gdb/testsuite/ 2013-11-25 Yao Qi <yao@codesourcery.com> * gdb.perf/backtrace.c: New. * gdb.perf/backtrace.exp: New. * gdb.perf/backtrace.py: New.
2013-11-24GDB perf test on single stepYao Qi4-0/+131
gdb/testsuite: 2013-11-24 Yao Qi <yao@codesourcery.com> * gdb.perf/single-step.c: New. * gdb.perf/single-step.exp: New. * gdb.perf/single-step.py: New.
2013-11-23 * gdb.base/ena-dis-br.exp: Add missing quote to "step after continueDoug Evans2-1/+6
with ignore count".
2013-11-23Test name tweaks for py-value.exp.Doug Evans2-5/+13
* gdb.python/py-value.exp (test_lazy_strings): Tweak test names. (test_subscript_regression): Ditto. (top level): Run test_subscript_regression for c++ with "c++" prefix.
2013-11-23 * gdb.python/py-type.exp (test_enums): Fix typo.Doug Evans2-1/+6
2013-11-23* gdb.python/py-symbol.exp: Add some comments. Make all test names unique.Doug Evans2-16/+34
2013-11-23* gdb.python/py-symbol.exp: Fix whitespace.Doug Evans2-4/+8
2013-11-23 * gdb.python/python.exp: Don't call skip_python_tests, we still wantDoug Evans2-3/+7
to test some things in the case where python is not configured in.
2013-11-22Rename gdb.dwarf2/dw2-bad-cfi.* to gdb.dwarf2/dw2-unspecified-ret-addr.*.Pedro Alves4-13/+22
gdb/testsuite/ 2013-11-22 Pedro Alves <palves@redhat.com> * gdb.dwarf2/dw2-bad-cfi.S: Rename to ... * gdb.dwarf2/dw2-unspecified-ret-addr.S: ... this. Adjust. * gdb.dwarf2/dw2-bad-cfi.c: Rename to ... * gdb.dwarf2/dw2-unspecified-ret-addr.c: ... this. * gdb.dwarf2/dw2-bad-cfi.exp: Rename to ... * gdb.dwarf2/dw2-unspecified-ret-addr.exp: ... this.
2013-11-22update comment in dw2-bad-cfi.S.Tom Tromey2-1/+6
Pedro asked me to add a comment to dw2-bad-cfi.S explaining the nature of the badness. I'm checking this in. 2013-11-22 Tom Tromey <tromey@redhat.com> * gdb.dwarf2/dw2-bad-cfi.S: Update comment.
2013-11-22handle an unspecified return address columnTom Tromey4-0/+292
Debugging PR 16155 further, I found that the DWARF unwinder found the function in question, but thought it had no registers saved (fs->regs.num_regs == 0). It seems to me that if a frame does not specify the return address column, or if the return address column is explicitly marked as DWARF2_FRAME_REG_UNSPECIFIED, then we should set the "undefined_retaddr" flag and let the DWARF unwinder gracefully stop. This patch implements that idea. With this patch the backtrace works properly: (gdb) bt #0 0x0000007fb7ed485c in nanosleep () from /lib64/libc.so.6 #1 0x0000007fb7ed4508 in sleep () from /lib64/libc.so.6 #2 0x00000000004008bc in thread_function (arg=0x4) at threadapply.c:73 #3 0x0000007fb7fad950 in start_thread () from /lib64/libpthread.so.0 #4 0x0000007fb7f0956c in clone () from /lib64/libc.so.6 2013-11-22 Tom Tromey <tromey@redhat.com> PR backtrace/16155: * dwarf2-frame.c (dwarf2_frame_cache): Set undefined_retaddr if the return address column is unspecified. 2013-11-22 Tom Tromey <tromey@redhat.com> * gdb.dwarf2/dw2-bad-cfi.c: New file. * gdb.dwarf2/dw2-bad-cfi.exp: New file. * gdb.dwarf2/dw2-bad-cfi.S: New file.
2013-11-22Don't let two frames with the same id end up in the frame chain.Pedro Alves4-0/+627
The UNWIND_SAME_ID check is done between THIS_FRAME and the next frame when we go try to unwind the previous frame. But at this point, it's already too late -- we ended up with two frames with the same ID in the frame chain. Each frame having its own ID is an invariant assumed throughout GDB. This patch applies the UNWIND_SAME_ID detection earlier, right after the previous frame is unwound, discarding the dup frame if a cycle is detected. The patch includes a new test that fails before the change. Before the patch, the test causes an infinite loop in GDB, after the patch, the UNWIND_SAME_ID logic kicks in and makes the backtrace stop with: Backtrace stopped: previous frame identical to this frame (corrupt stack?) The test uses dwarf CFI to emulate a corrupted stack with a cycle. It has a function with registers marked DW_CFA_same_value (most importantly RSP/RIP), so that GDB computes the same ID for that frame and its caller. IOW, something like this: #0 - frame_id_1 #1 - frame_id_2 #2 - frame_id_3 #3 - frame_id_4 #4 - frame_id_4 <<<< outermost (UNWIND_SAME_ID). (The test's code is just a copy of dw2-reg-undefined.S / dw2-reg-undefined.c, adjusted to use DW_CFA_same_value instead of DW_CFA_undefined, and to mark a different set of registers.) The infinite loop is here, in value_fetch_lazy: while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val)) { frame = frame_find_by_id (VALUE_FRAME_ID (new_val)); ... new_val = get_frame_register_value (frame, regnum); } get_frame_register_value can return a lazy register value pointing to the next frame. This means that the register wasn't clobbered by FRAME; the debugger should therefore retrieve its value from the next frame. To be clear, get_frame_register_value unwinds the value in question from the next frame: struct value * get_frame_register_value (struct frame_info *frame, int regnum) { return frame_unwind_register_value (frame->next, regnum); ^^^^^^^^^^^ } In other words, if we get a lazy lval_register, it should have the frame ID of the _next_ frame, never of FRAME. At this point in value_fetch_lazy, the whole relevant chunk of the stack up to frame #4 has already been unwound. The loop always "unlazies" lval_registers in the "next/innermost" direction, not in the "prev/unwind further/outermost" direction. So say we're looking at frame #4. get_frame_register_value in frame #4 can return a lazy register value of frame #3. So the next iteration, frame_find_by_id tries to read the register from frame #3. But, since frame #4 happens to have same id as frame #3, frame_find_by_id returns frame #4 instead. Rinse, repeat, and we have an infinite loop. This is an old latent problem, exposed by the recent addition of the frame stash. Before we had a stash, frame_find_by_id(frame_id_4) would walk over all frames starting at the current frame, and would always find #3 first. The stash happens to return #4 instead: struct frame_info * frame_find_by_id (struct frame_id id) { struct frame_info *frame, *prev_frame; ... /* Try using the frame stash first. Finding it there removes the need to perform the search by looping over all frames, which can be very CPU-intensive if the number of frames is very high (the loop is O(n) and get_prev_frame performs a series of checks that are relatively expensive). This optimization is particularly useful when this function is called from another function (such as value_fetch_lazy, case VALUE_LVAL (val) == lval_register) which already loops over all frames, making the overall behavior O(n^2). */ frame = frame_stash_find (id); if (frame) return frame; for (frame = get_current_frame (); ; frame = prev_frame) { gdb/ 2013-11-22 Pedro Alves <palves@redhat.com> PR 16155 * frame.c (get_prev_frame_1): Do the UNWIND_SAME_ID check between this frame and the new previous frame, not between this frame and the next frame. gdb/testsuite/ 2013-11-22 Pedro Alves <palves@redhat.com> PR 16155 * gdb.dwarf2/dw2-dup-frame.S: New file. * gdb.dwarf2/dw2-dup-frame.c: New file. * gdb.dwarf2/dw2-dup-frame.exp: New file.
2013-11-22Revert "Don't let two frames with the same id end up in the frame chain."Pedro Alves3-620/+0
This reverts commit be2c48b4d50b992ba83bc51f086e316621a03a14.
2013-11-22Don't let two frames with the same id end up in the frame chain.Pedro Alves3-0/+620
The UNWIND_SAME_ID check is done between THIS_FRAME and the next frame when we go try to unwind the previous frame. But at this point, it's already too late -- we ended up with two frames with the same ID in the frame chain. Each frame having its own ID is an invariant assumed throughout GDB. This patch applies the UNWIND_SAME_ID detection earlier, right after the previous frame is unwound, discarding the dup frame if a cycle is detected. The patch includes a new test that fails before the change. Before the patch, the test causes an infinite loop in GDB, after the patch, the UNWIND_SAME_ID logic kicks in and makes the backtrace stop with: Backtrace stopped: previous frame identical to this frame (corrupt stack?) The test uses dwarf CFI to emulate a corrupted stack with a cycle. It has a function with registers marked DW_CFA_same_value (most importantly RSP/RIP), so that GDB computes the same ID for that frame and its caller. IOW, something like this: #0 - frame_id_1 #1 - frame_id_2 #2 - frame_id_3 #3 - frame_id_4 #4 - frame_id_4 <<<< outermost (UNWIND_SAME_ID). (The test's code is just a copy of dw2-reg-undefined.S / dw2-reg-undefined.c, adjusted to use DW_CFA_same_value instead of DW_CFA_undefined, and to mark a different set of registers.) The infinite loop is here, in value_fetch_lazy: while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val)) { frame = frame_find_by_id (VALUE_FRAME_ID (new_val)); ... new_val = get_frame_register_value (frame, regnum); } get_frame_register_value can return a lazy register value pointing to the next frame. This means that the register wasn't clobbered by FRAME; the debugger should therefore retrieve its value from the next frame. To be clear, get_frame_register_value unwinds the value in question from the next frame: struct value * get_frame_register_value (struct frame_info *frame, int regnum) { return frame_unwind_register_value (frame->next, regnum); ^^^^^^^^^^^ } In other words, if we get a lazy lval_register, it should have the frame ID of the _next_ frame, never of FRAME. At this point in value_fetch_lazy, the whole relevant chunk of the stack up to frame #4 has already been unwound. The loop always "unlazies" lval_registers in the "next/innermost" direction, not in the "prev/unwind further/outermost" direction. So say we're looking at frame #4. get_frame_register_value in frame #4 can return a lazy register value of frame #3. So the next iteration, frame_find_by_id tries to read the register from frame #3. But, since frame #4 happens to have same id as frame #3, frame_find_by_id returns frame #4 instead. Rinse, repeat, and we have an infinite loop. This is an old latent problem, exposed by the recent addition of the frame stash. Before we had a stash, frame_find_by_id(frame_id_4) would walk over all frames starting at the current frame, and would always find #3 first. The stash happens to return #4 instead: struct frame_info * frame_find_by_id (struct frame_id id) { struct frame_info *frame, *prev_frame; ... /* Try using the frame stash first. Finding it there removes the need to perform the search by looping over all frames, which can be very CPU-intensive if the number of frames is very high (the loop is O(n) and get_prev_frame performs a series of checks that are relatively expensive). This optimization is particularly useful when this function is called from another function (such as value_fetch_lazy, case VALUE_LVAL (val) == lval_register) which already loops over all frames, making the overall behavior O(n^2). */ frame = frame_stash_find (id); if (frame) return frame; for (frame = get_current_frame (); ; frame = prev_frame) { gdb/ 2013-11-22 Pedro Alves <palves@redhat.com> PR 16155 * frame.c (get_prev_frame_1): Do the UNWIND_SAME_ID check between this frame and the new previous frame, not between this frame and the next frame. gdb/testsuite/ 2013-11-22 Pedro Alves <palves@redhat.com> PR 16155 * gdb.dwarf2/dw2-dup-frame.S: New file. * gdb.dwarf2/dw2-dup-frame.c: New file. * gdb.dwarf2/dw2-dup-frame.exp: New file.
2013-11-22Check has_more in mi_create_dynamic_varobjYao Qi3-9/+18
Hi, I find "has_more" is not checked when a dynamic varobj is created in proc mi_create_dynamic_varobj. This patch adds the check to "has_more". gdb/testsuite: 2013-11-22 Yao Qi <yao@codesourcery.com> * lib/mi-support.exp (mi_create_dynamic_varobj): Update comment and add one more argument "has_more". * gdb.python/py-mi.exp: Callers update.
2013-11-22Use mi_create_floating_varobjYao Qi2-2/+7
In gdb.python/py-mi.exp, two varobjs container and nscont are created when pretty-printing is still not enabled, so they are not dynamic varobj, IIUC. In this patch, we use mi_create_floating_varobj instead of mi_create_dynamic_varobj. gdb/testsuite: 2013-11-22 Yao Qi <yao@codesourcery.com> * gdb.python/py-mi.exp: Use mi_create_floating_varobj instead of mi_create_dynamic_varobj.