aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/testsuite')
-rw-r--r--gdb/testsuite/ChangeLog393
-rw-r--r--gdb/testsuite/gdb.arch/i386-avx512.c128
-rw-r--r--gdb/testsuite/gdb.arch/s390-vregs.exp18
-rw-r--r--gdb/testsuite/gdb.arch/sparc64-adi.c145
-rw-r--r--gdb/testsuite/gdb.arch/sparc64-adi.exp53
-rw-r--r--gdb/testsuite/gdb.arch/thumb2-it.exp4
-rw-r--r--gdb/testsuite/gdb.asm/asm-source.exp8
-rw-r--r--gdb/testsuite/gdb.base/break-main-file-remove-fail.exp2
-rw-r--r--gdb/testsuite/gdb.base/break-probes.exp2
-rw-r--r--gdb/testsuite/gdb.base/callfuncs.exp26
-rw-r--r--gdb/testsuite/gdb.base/checkpoint.exp44
-rw-r--r--gdb/testsuite/gdb.base/commands.exp129
-rw-r--r--gdb/testsuite/gdb.base/completion.exp2
-rw-r--r--gdb/testsuite/gdb.base/default.exp2
-rw-r--r--gdb/testsuite/gdb.base/dfp-test.c17
-rw-r--r--gdb/testsuite/gdb.base/dfp-test.exp59
-rw-r--r--gdb/testsuite/gdb.base/dmsym.c8
-rw-r--r--gdb/testsuite/gdb.base/dmsym.exp39
-rw-r--r--gdb/testsuite/gdb.base/dmsym_main.c10
-rw-r--r--gdb/testsuite/gdb.base/dprintf-detach.exp2
-rw-r--r--gdb/testsuite/gdb.base/ena-dis-br.exp2
-rw-r--r--gdb/testsuite/gdb.base/environ.exp3
-rw-r--r--gdb/testsuite/gdb.base/gnu_vector.exp27
-rw-r--r--gdb/testsuite/gdb.base/infcall-exec.exp2
-rw-r--r--gdb/testsuite/gdb.base/info-os.exp8
-rw-r--r--gdb/testsuite/gdb.base/list-ambiguous.exp79
-rw-r--r--gdb/testsuite/gdb.base/list-ambiguous0.c42
-rw-r--r--gdb/testsuite/gdb.base/list-ambiguous1.c41
-rw-r--r--gdb/testsuite/gdb.base/list.exp2
-rw-r--r--gdb/testsuite/gdb.base/nodebug.c48
-rw-r--r--gdb/testsuite/gdb.base/nodebug.exp213
-rw-r--r--gdb/testsuite/gdb.base/printcmds.exp11
-rw-r--r--gdb/testsuite/gdb.base/reread.exp226
-rw-r--r--gdb/testsuite/gdb.base/share-env-with-gdbserver.c40
-rw-r--r--gdb/testsuite/gdb.base/share-env-with-gdbserver.exp255
-rw-r--r--gdb/testsuite/gdb.base/sizeof.exp4
-rw-r--r--gdb/testsuite/gdb.base/solib-display.exp16
-rw-r--r--gdb/testsuite/gdb.base/starti.c30
-rw-r--r--gdb/testsuite/gdb.base/starti.exp51
-rw-r--r--gdb/testsuite/gdb.base/symbol-alias.c31
-rw-r--r--gdb/testsuite/gdb.base/symbol-alias.exp37
-rw-r--r--gdb/testsuite/gdb.base/symbol-alias2.c34
-rw-r--r--gdb/testsuite/gdb.base/whatis-ptype-typedefs.c143
-rw-r--r--gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp272
-rw-r--r--gdb/testsuite/gdb.compile/compile-ifunc.exp5
-rw-r--r--gdb/testsuite/gdb.compile/compile.exp10
-rw-r--r--gdb/testsuite/gdb.cp/local-static.c170
-rw-r--r--gdb/testsuite/gdb.cp/local-static.cc1
-rw-r--r--gdb/testsuite/gdb.cp/local-static.exp241
-rw-r--r--gdb/testsuite/gdb.cp/m-static.exp5
-rw-r--r--gdb/testsuite/gdb.cp/overload.exp34
-rw-r--r--gdb/testsuite/gdb.dlang/demangle.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.exp2
-rw-r--r--gdb/testsuite/gdb.dwarf2/fission-multi-cu.S374
-rw-r--r--gdb/testsuite/gdb.dwarf2/fission-multi-cu.exp67
-rw-r--r--gdb/testsuite/gdb.dwarf2/fission-multi-cu1.c22
-rw-r--r--gdb/testsuite/gdb.dwarf2/fission-multi-cu2.c24
-rw-r--r--gdb/testsuite/gdb.dwarf2/shortpiece.exp100
-rw-r--r--gdb/testsuite/gdb.dwarf2/var-access.exp8
-rw-r--r--gdb/testsuite/gdb.fortran/printing-types.exp35
-rw-r--r--gdb/testsuite/gdb.fortran/printing-types.f9027
-rw-r--r--gdb/testsuite/gdb.fortran/ptr-indentation.exp41
-rw-r--r--gdb/testsuite/gdb.fortran/ptr-indentation.f9030
-rw-r--r--gdb/testsuite/gdb.fortran/vla-ptype.exp6
-rw-r--r--gdb/testsuite/gdb.fortran/vla-value.exp15
-rw-r--r--gdb/testsuite/gdb.gdb/unittest.exp5
-rw-r--r--gdb/testsuite/gdb.gdb/xfullpath.exp60
-rw-r--r--gdb/testsuite/gdb.linespec/base/one/thefile.cc5
-rw-r--r--gdb/testsuite/gdb.linespec/base/two/thefile.cc5
-rw-r--r--gdb/testsuite/gdb.linespec/linespec.exp93
-rw-r--r--gdb/testsuite/gdb.linespec/ls-errs.exp27
-rw-r--r--gdb/testsuite/gdb.mi/mi-var-child-f.exp8
-rw-r--r--gdb/testsuite/gdb.mi/mi-vla-fortran.exp74
-rw-r--r--gdb/testsuite/gdb.multi/multi-arch-exec.exp24
-rw-r--r--gdb/testsuite/gdb.python/py-inferior.exp24
-rw-r--r--gdb/testsuite/gdb.python/py-infthread.exp12
-rw-r--r--gdb/testsuite/gdb.python/py-prettyprint.c9
-rw-r--r--gdb/testsuite/gdb.python/py-prettyprint.exp13
-rw-r--r--gdb/testsuite/gdb.python/py-prettyprint.py34
-rw-r--r--gdb/testsuite/gdb.python/py-thrhandle.c94
-rw-r--r--gdb/testsuite/gdb.python/py-thrhandle.exp102
-rw-r--r--gdb/testsuite/gdb.python/py-unwind.exp10
-rw-r--r--gdb/testsuite/gdb.rust/simple.exp17
-rw-r--r--gdb/testsuite/gdb.server/normal.c24
-rw-r--r--gdb/testsuite/gdb.server/run-without-local-binary.exp62
-rw-r--r--gdb/testsuite/gdb.server/unittest.exp41
-rw-r--r--gdb/testsuite/gdb.threads/siginfo-threads.exp7
-rw-r--r--gdb/testsuite/gdb.threads/tls-nodebug-pie.c28
-rw-r--r--gdb/testsuite/gdb.threads/tls-nodebug-pie.exp29
-rw-r--r--gdb/testsuite/gdb.threads/tls-nodebug.exp5
-rw-r--r--gdb/testsuite/gdb.trace/entry-values.exp6
-rw-r--r--gdb/testsuite/lib/gdb.exp74
92 files changed, 4338 insertions, 481 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 6160c4b..6584a23 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,396 @@
+2017-09-21 Kevin Buettner <kevinb@redhat.com>
+
+ * gdb.python/py-thrhandle.c, gdb.python/py-thrhandle.exp: New
+ files.
+
+2017-09-20 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/list-ambiguous.exp (test_list_ambiguous_symbol): Expect
+ symbol names in gdb's output.
+ * gdb.cp/overload.exp ("list all overloads"): Likewise.
+
+2017-09-20 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/list-ambiguous.exp (test_list_ambiguous_function):
+ Rename to ...
+ (test_list_ambiguous_symbol): ... this and add a symbol name
+ parameter. Adjust.
+ (test_list_ambiguous_function): Reimplement on top of
+ test_list_ambiguous_symbol and also test listing ambiguous
+ variables.
+ * gdb.base/list-ambiguous0.c (ambiguous): Rename to ...
+ (ambiguous_fun): ... this.
+ (ambiguous_var): New.
+ * gdb.base/list-ambiguous1.c (ambiguous): Rename to ...
+ (ambiguous_fun): ... this.
+ (ambiguous_var): New.
+
+2017-09-19 John Baldwin <jhb@FreeBSD.org>
+
+ * gdb.base/starti.c: New file.
+ * gdb.base/starti.exp: New file.
+ * lib/gdb.exp (gdb_starti_cmd): New procedure.
+
+2017-09-14 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/nodebug.exp (nodebug_runto): New procedure.
+ (top level): Use it instead of runto.
+
+2017-09-11 Tom Tromey <tom@tromey.com>
+
+ * gdb.base/ena-dis-br.exp (test_ena_dis_br): Update test.
+
+2017-09-11 Tom Tromey <tom@tromey.com>
+
+ * gdb.python/py-infthread.exp: Add tests for new_thread event.
+ * gdb.python/py-inferior.exp: Add tests for new inferior events.
+
+2017-09-08 Christoph Weinmann <christoph.t.weinmann@intel.com>
+
+ * gdb.fortran/printing-types.exp: New file.
+ * gdb.fortran/printing-types.exp: New file.
+
+2017-09-08 Bernhard Heckel <bernhard.heckel@intel.com>
+
+ * gdb.fortran/vla-ptype.exp: Fix typos.
+ * gdb.fortran/vla-value.exp: Same.
+
+2017-09-08 Bernhard Heckel <bernhard.heckel@intel.com>
+
+ * gdb.fortran/vla-value.exp: Use type names defined in libfortran.
+ * gdb.mi/mi-var-child-f.exp: Likewise.
+ * gdb.mi/mi-vla-fortran.exp: Likewise.
+
+2017-09-08 Frank Penczek <frank.penczek@intel.com>
+ Christoph Weinmann <christoph.t.weinmann@intel.com>
+ Bernhard Heckel <bernhard.heckel@intel.com>
+
+ * gdb.fortran/ptr-indentation.f90: New file.
+ * gdb.fortran/ptr-indentation.exp: New file.
+
+2017-09-05 Tom Tromey <tom@tromey.com>
+
+ PR gdb/22010:
+ * gdb.base/sizeof.exp (check_valueof): Cast char constant to int.
+
+2017-09-06 Thomas Preud'homme <thomas.preudhomme@arm.com>
+
+ * gdb.arch/thumb2-it.exp: Cast call to assembly defined function.
+
+2017-09-06 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * gdb.threads/tls-nodebug-pie.c: New file.
+ * gdb.threads/tls-nodebug-pie.exp: New file.
+
+2017-09-05 Tom Tromey <tom@tromey.com>
+
+ * lib/gdb.exp (gdb_compile): Don't use universal_compile_options
+ for rust.
+
+2017-09-05 Simon Marchi <simon.marchi@ericsson.com>
+
+ * gdb.multi/multi-arch-exec.exp: Test with different
+ "follow-exec-mode" settings.
+ (do_test): New procedure.
+
+2017-09-04 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/func-static.c (S::method const, S::method volatile)
+ (S::method volatile const): New methods.
+ (c_s, v_s, cv_s): New instances.
+ (main): Call method() on them.
+ * gdb.base/func-static.exp (syntax_re, cannot_resolve_re): New variables.
+ (cannot_resolve): New procedure.
+ (cxx_scopes_list): Test cv methods. Add print-scope-quote and
+ print-quote-unquoted columns.
+ (do_test): Test printing each scope too.
+
+2017-09-04 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/local-static.exp: Also test with
+ class::method::variable wholly quoted.
+ * gdb.cp/m-static.exp (class::method::variable): Remove test.
+
+2017-09-04 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/local-static.c: New.
+ * gdb.base/local-static.cc: New.
+ * gdb.base/local-static.exp: New.
+
+2017-09-04 Pedro Alves <palves@redhat.com>
+
+ * gdb.asm/asm-source.exp: Add casts to int.
+ * gdb.base/nodebug.c (dataglobal8, dataglobal32_1, dataglobal32_2)
+ (dataglobal64_1, dataglobal64_2): New globals.
+ * gdb.base/nodebug.exp: Test different expressions involving the
+ new globals, with print, whatis and ptype. Add casts to int.
+ * gdb.base/solib-display.exp: Add casts to int.
+ * gdb.compile/compile-ifunc.exp: Expect warning. Add cast to int.
+ * gdb.cp/m-static.exp: Add cast to int.
+ * gdb.dwarf2/dw2-skip-prologue.exp: Add cast to int.
+ * gdb.threads/tls-nodebug.exp: Check that gdb errors out printing
+ tls variable with no debug info without a cast. Test with a cast
+ to int too.
+ * gdb.trace/entry-values.exp: Add casts.
+
+2017-09-04 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/nodebug.exp: Test that ptype's error about functions
+ with unknown return type includes the function name too.
+
+2017-09-04 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/break-main-file-remove-fail.exp (test_remove_bp): Cast
+ return type of munmap in infcall.
+ * gdb.base/break-probes.exp: Cast return type of foo in infcall.
+ * gdb.base/checkpoint.exp: Simplify using for loop. Cast return
+ type of ftell in infcall.
+ * gdb.base/dprintf-detach.exp (dprintf_detach_test): Cast return
+ type of getpid in infcall.
+ * gdb.base/infcall-exec.exp: Cast return type of execlp in
+ infcall.
+ * gdb.base/info-os.exp: Cast return type of getpid in infcall.
+ Bail on failure to extract the pid.
+ * gdb.base/nodebug.c: #include <stdint.h>.
+ (multf, multf_noproto, mult, mult_noproto, add8, add8_noproto):
+ New functions.
+ * gdb.base/nodebug.exp (test_call_promotion): New procedure.
+ Change expected output of print/whatis/ptype with functions with
+ no debug info. Test all supported languages. Call
+ test_call_promotion.
+ * gdb.compile/compile.exp: Adjust expected output to expect
+ warning.
+ * gdb.threads/siginfo-threads.exp: Likewise.
+
+2017-09-04 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/callfuncs.exp (do_function_calls): New parameter
+ "prototypes". Test calling float functions via prototyped and
+ unprototyped function pointers.
+ (perform_all_tests): New parameter "prototypes". Pass it down.
+ (top level): Pass down "prototypes" parameter to
+ perform_all_tests.
+
+2017-09-04 Simon Marchi <simon.marchi@ericsson.com>
+
+ * gdb.base/commands.exp (loop_break_test, loop_continue_test):
+ Test with nested loops.
+
+2017-09-04 Simon Marchi <simon.marchi@ericsson.com>
+
+ * gdb.base/commands.exp: Call the new procedures.
+ (loop_break_test, loop_continue_test): New procedures.
+
+2017-09-04 Simon Marchi <simon.marchi@ericsson.com>
+
+ * gdb.base/commands.exp: Call new procedure.
+ (define_if_without_arg_test): New procedure.
+
+2017-09-04 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/list-ambiguous.exp: New file.
+ * gdb.base/list-ambiguous0.c: New file.
+ * gdb.base/list-ambiguous1.c: New file.
+ * gdb.base/list.exp (test_list_range): Adjust expected output.
+
+2017-08-31 Sergio Durigan Junior <sergiodj@redhat.com>
+
+ * gdb.base/share-env-with-gdbserver.c: New file.
+ * gdb.base/share-env-with-gdbserver.exp: Likewise.
+
+2017-08-28 Simon Marchi <simon.marchi@ericsson.com>
+
+ * gdb.base/commands.exp (gdbvar_simple_if_test,
+ gdbvar_simple_if_test, gdbvar_complex_if_while_test,
+ progvar_simple_if_test, progvar_simple_while_test,
+ progvar_complex_if_while_test, user_defined_command_test,
+ user_defined_command_args_eval,
+ user_defined_command_args_stack_test,
+ user_defined_command_manyargs_test, bp_deleted_in_command_test,
+ temporary_breakpoint_commands,
+ gdb_test_no_prompt, redefine_hook_test,
+ redefine_backtrace_test): Remove "global gdb_prompt".
+
+2017-08-28 Simon Marchi <simon.marchi@ericsson.com>
+
+ * gdb.base/commands.exp (user_defined_command_case_sensitivity):
+ New proc, call it from toplevel.
+
+2017-08-23 Sergio Durigan Junior <sergiodj@redhat.com>
+
+ PR remote/21852
+ * gdb.server/normal.c: New file, copied from gdb.base.
+ * gdb.server/run-without-local-binary.exp: New file.
+
+2017-08-07 Weimin Pan <weimin.pan@oracle.com>
+
+ * gdb.arch/sparc64-adi.exp: New file.
+ * gdb.arch/sparc64-adi.c: New file.
+
+2017-08-22 Pedro Alves <palves@redhat.com>
+
+ * gdb.cp/overload.exp (line_range_pattern): New procedure.
+ (top level): Add "list all overloads" tests.
+
+2017-08-22 Tom Tromey <tom@tromey.com>
+
+ * gdb.gdb/xfullpath.exp: Remove.
+
+2017-08-21 Pedro Alves <palves@redhat.com>
+
+ PR gdb/19487
+ * gdb.base/symbol-alias.c: New.
+ * gdb.base/symbol-alias2.c: New.
+ * gdb.base/symbol-alias.exp: New.
+
+2017-08-21 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/dfp-test.c
+ (d32_t, d64_t, d128_t, d32_t2, d64_t2, d128_t2, v_d32_t, v_d64_t)
+ (v_d128_t, v_d32_t2, v_d64_t2, v_d128_t2): New.
+ * gdb.base/dfp-test.exp: Add whatis/ptype/cast tests.
+ * gdb.base/gnu_vector.exp: Add whatis/ptype/cast tests.
+ * gdb.base/whatis-ptype-typedefs.c: New.
+ * gdb.base/whatis-ptype-typedefs.exp: New.
+ * gdb.python/py-prettyprint.c (int_type, int_type2): New typedefs.
+ (an_int, an_int_type, an_int_type2): New globals.
+ * gdb.python/py-prettyprint.exp (run_lang_tests): Add tests
+ involving typedefs and cast expressions.
+ * gdb.python/py-prettyprint.py (class pp_int_typedef): New.
+ (lookup_typedefs_function): New.
+ (typedefs_pretty_printers_dict): New.
+ (top level): Register lookup_typedefs_function in
+ gdb.pretty_printers.
+
+2017-08-18 Yao Qi <yao.qi@linaro.org>
+
+ * gdb.server/unittest.exp: New.
+
+2017-08-15 Sergio Durigan Junior <sergiodj@redhat.com>
+
+ PR gdb/21954
+ * gdb.base/environ.exp: Add test to check if 'unset environment'
+ works.
+
+2017-08-14 Andreas Arnez <arnez@linux.vnet.ibm.com>
+
+ * lib/gdb.exp (universal_compile_options): New caching proc.
+ (gdb_compile): Suppress GCC's coloring of messages.
+
+2017-08-14 Tom Tromey <tom@tromey.com>
+
+ PR gdb/21675:
+ * gdb.base/printcmds.exp (test_radices): New function.
+ * gdb.dwarf2/var-access.exp: Use p/u, not p/d.
+ * gdb.base/sizeof.exp (check_valueof): Use p/d.
+ * lib/gdb.exp (get_integer_valueof): Use p/d.
+
+2017-08-12 Simon Marchi <simon.marchi@ericsson.com>
+
+ * lib/gdb.exp (get_valueof): Don't capture end-of-line
+ characters.
+
+2017-08-05 Tom Tromey <tom@tromey.com>
+
+ * gdb.rust/simple.exp: Allow String to appear in a different
+ namespace.
+
+2017-07-26 Yao Qi <yao.qi@linaro.org>
+
+ * gdb.gdb/unittest.exp: Invoke command
+ "maintenance check xml-descriptions".
+
+2017-07-24 Andreas Arnez <arnez@linux.vnet.ibm.com>
+
+ * gdb.arch/s390-vregs.exp: Calculate parameters to hex128 in the
+ calling context.
+ (hex128): Drop erroneous calculation of parameters.
+
+2017-07-22 Simon Marchi <simon.marchi@ericsson.com>
+
+ * gdb.python/py-unwind.exp: Disable stack protection when
+ building test file.
+
+2017-07-20 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/default.exp (set language): Adjust expected output.
+
+2017-07-20 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/dmsym.c (pck__foo__bar__minsym): Rename to ...
+ (test_minsym): ... this, and make static.
+ (get_pck__foo__bar__minsym): Rename to ...
+ (get_test_minsym): ... this.
+ * gdb.base/dmsym.exp (): Remove "set language ada" call. Adjust
+ symbol names and comments.
+ * gdb.base/dmsym_main.c (get_pck__foo__bar__minsym): Rename to ...
+ (get_test_minsym): ... this.
+ (pck__foo__bar__minsym__2): Rename to ...
+ (test_minsym): ... this.
+ (main): Adjust.
+
+2017-07-17 Pedro Alves <palves@redhat.com>
+
+ * gdb.base/completion.exp: Adjust expected output.
+ * gdb.linespec/ls-errs.exp: Don't send tab characters, now that
+ the completer works.
+
+2017-07-17 Pedro Alves <palves@redhat.com>
+
+ * gdb.linespec/ls-errs.exp (do_test): Adjust expected output.
+
+2017-07-15 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * gdb.mi/mi-vla-fortran.exp: Make test names unique.
+
+2017-07-14 Tom Tromey <tom@tromey.com>
+
+ PR rust/21764:
+ * gdb.rust/simple.exp: Add tests.
+
+2017-07-14 Tom Tromey <tom@tromey.com>
+
+ * gdb.rust/simple.exp: Add regression test for PR rust/21763.
+
+2017-07-14 Pedro Alves <palves@redhat.com>
+
+ * gdb.linespec/base/one/thefile.cc (z1): New function.
+ * gdb.linespec/base/two/thefile.cc (z2): New function.
+ * gdb.linespec/linespec.exp: Add tests.
+
+2017-07-13 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * gdb.mi/mi-vla-fortran.exp: Correct even more parameter passing
+ to mi_create_breakpoint.
+
+2017-07-13 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * gdb.mi/mi-vla-fortran.exp: Correct parameter passing to
+ mi_create_breakpoint.
+
+2017-07-11 Iain Buclaw <ibuclaw@gdcproject.org>
+
+ * gdb.dlang/demangle.exp: Update for demangling changes.
+
+2017-07-09 Tom Tromey <tom@tromey.com>
+
+ * gdb.dwarf2/shortpiece.exp: New file.
+
+2017-07-06 David Blaikie <dblaikie@gmail.com>
+
+ * gdb.dwarf2/fission-multi-cu.S: Test containing multiple CUs in a DWO,
+ built from fissiont-multi-cu{1,2}.c.
+ * gdb.dwarf2/fission-multi-cu.exp: Test similar to fission-base.exp,
+ except putting 'main' and 'func' in separate CUs in the same DWO file.
+ * gdb.dwarf2/fission-multi-cu1.c: First CU for the multi-CU-single-DWO
+ test.
+ * gdb.dwarf2/fission-multi-cu2.c: Second CU in the multi-CU-single-DWO
+ test.
+
+2017-07-06 Pedro Alves <palves@redhat.com>
+
+ * gdb.python/py-unwind.exp: Test flushregs.
+
2017-06-30 Sergio Durigan Junior <sergiodj@redhat.com>
PR cli/21688
diff --git a/gdb/testsuite/gdb.arch/i386-avx512.c b/gdb/testsuite/gdb.arch/i386-avx512.c
index 52c0ead..3e955a4 100644
--- a/gdb/testsuite/gdb.arch/i386-avx512.c
+++ b/gdb/testsuite/gdb.arch/i386-avx512.c
@@ -127,44 +127,44 @@ move_k_data_to_memory (void)
void
move_zmm_data_to_reg (void)
{
- asm ("vmovaps 0(%0), %%zmm0\n\t"
- "vmovaps 64(%0), %%zmm1\n\t"
- "vmovaps 128(%0), %%zmm2\n\t"
- "vmovaps 192(%0), %%zmm3\n\t"
- "vmovaps 256(%0), %%zmm4\n\t"
- "vmovaps 320(%0), %%zmm5\n\t"
- "vmovaps 384(%0), %%zmm6\n\t"
- "vmovaps 448(%0), %%zmm7\n\t"
+ asm ("vmovups 0(%0), %%zmm0 \n\t"
+ "vmovups 64(%0), %%zmm1 \n\t"
+ "vmovups 128(%0), %%zmm2 \n\t"
+ "vmovups 192(%0), %%zmm3 \n\t"
+ "vmovups 256(%0), %%zmm4 \n\t"
+ "vmovups 320(%0), %%zmm5 \n\t"
+ "vmovups 384(%0), %%zmm6 \n\t"
+ "vmovups 448(%0), %%zmm7 \n\t"
: /* no output operands */
: "r" (zmm_data));
#ifdef __x86_64__
- asm ("vmovaps 512(%0), %%zmm8\n\t"
- "vmovaps 576(%0), %%zmm9\n\t"
- "vmovaps 640(%0), %%zmm10\n\t"
- "vmovaps 704(%0), %%zmm11\n\t"
- "vmovaps 768(%0), %%zmm12\n\t"
- "vmovaps 832(%0), %%zmm13\n\t"
- "vmovaps 896(%0), %%zmm14\n\t"
- "vmovaps 960(%0), %%zmm15\n\t"
+ asm ("vmovups 512(%0), %%zmm8 \n\t"
+ "vmovups 576(%0), %%zmm9 \n\t"
+ "vmovups 640(%0), %%zmm10 \n\t"
+ "vmovups 704(%0), %%zmm11 \n\t"
+ "vmovups 768(%0), %%zmm12 \n\t"
+ "vmovups 832(%0), %%zmm13 \n\t"
+ "vmovups 896(%0), %%zmm14 \n\t"
+ "vmovups 960(%0), %%zmm15 \n\t"
: /* no output operands */
: "r" (zmm_data));
- asm ("vmovaps 1024(%0), %%zmm16\n\t"
- "vmovaps 1088(%0), %%zmm17\n\t"
- "vmovaps 1152(%0), %%zmm18\n\t"
- "vmovaps 1216(%0), %%zmm19\n\t"
- "vmovaps 1280(%0), %%zmm20\n\t"
- "vmovaps 1344(%0), %%zmm21\n\t"
- "vmovaps 1408(%0), %%zmm22\n\t"
- "vmovaps 1472(%0), %%zmm23\n\t"
- "vmovaps 1536(%0), %%zmm24\n\t"
- "vmovaps 1600(%0), %%zmm25\n\t"
- "vmovaps 1664(%0), %%zmm26\n\t"
- "vmovaps 1728(%0), %%zmm27\n\t"
- "vmovaps 1792(%0), %%zmm28\n\t"
- "vmovaps 1856(%0), %%zmm29\n\t"
- "vmovaps 1920(%0), %%zmm30\n\t"
- "vmovaps 1984(%0), %%zmm31\n\t"
+ asm ("vmovups 1024(%0), %%zmm16 \n\t"
+ "vmovups 1088(%0), %%zmm17 \n\t"
+ "vmovups 1152(%0), %%zmm18 \n\t"
+ "vmovups 1216(%0), %%zmm19 \n\t"
+ "vmovups 1280(%0), %%zmm20 \n\t"
+ "vmovups 1344(%0), %%zmm21 \n\t"
+ "vmovups 1408(%0), %%zmm22 \n\t"
+ "vmovups 1472(%0), %%zmm23 \n\t"
+ "vmovups 1536(%0), %%zmm24 \n\t"
+ "vmovups 1600(%0), %%zmm25 \n\t"
+ "vmovups 1664(%0), %%zmm26 \n\t"
+ "vmovups 1728(%0), %%zmm27 \n\t"
+ "vmovups 1792(%0), %%zmm28 \n\t"
+ "vmovups 1856(%0), %%zmm29 \n\t"
+ "vmovups 1920(%0), %%zmm30 \n\t"
+ "vmovups 1984(%0), %%zmm31 \n\t"
: /* no output operands */
: "r" (zmm_data));
#endif
@@ -173,44 +173,44 @@ move_zmm_data_to_reg (void)
void
move_zmm_data_to_memory (void)
{
- asm ("vmovaps %%zmm0, 0(%0)\n\t"
- "vmovaps %%zmm1, 64(%0)\n\t"
- "vmovaps %%zmm2, 128(%0)\n\t"
- "vmovaps %%zmm3, 192(%0)\n\t"
- "vmovaps %%zmm4, 256(%0)\n\t"
- "vmovaps %%zmm5, 320(%0)\n\t"
- "vmovaps %%zmm6, 384(%0)\n\t"
- "vmovaps %%zmm7, 448(%0)\n\t"
+ asm ("vmovups %%zmm0, 0(%0)\n\t"
+ "vmovups %%zmm1, 64(%0)\n\t"
+ "vmovups %%zmm2, 128(%0)\n\t"
+ "vmovups %%zmm3, 192(%0)\n\t"
+ "vmovups %%zmm4, 256(%0)\n\t"
+ "vmovups %%zmm5, 320(%0)\n\t"
+ "vmovups %%zmm6, 384(%0)\n\t"
+ "vmovups %%zmm7, 448(%0)\n\t"
: /* no output operands */
: "r" (zmm_data));
#ifdef __x86_64__
- asm ("vmovaps %%zmm8, 512(%0)\n\t"
- "vmovaps %%zmm9, 576(%0)\n\t"
- "vmovaps %%zmm10, 640(%0)\n\t"
- "vmovaps %%zmm11, 704(%0)\n\t"
- "vmovaps %%zmm12, 768(%0)\n\t"
- "vmovaps %%zmm13, 832(%0)\n\t"
- "vmovaps %%zmm14, 896(%0)\n\t"
- "vmovaps %%zmm15, 960(%0)\n\t"
+ asm ("vmovups %%zmm8, 512(%0)\n\t"
+ "vmovups %%zmm9, 576(%0)\n\t"
+ "vmovups %%zmm10, 640(%0)\n\t"
+ "vmovups %%zmm11, 704(%0)\n\t"
+ "vmovups %%zmm12, 768(%0)\n\t"
+ "vmovups %%zmm13, 832(%0)\n\t"
+ "vmovups %%zmm14, 896(%0)\n\t"
+ "vmovups %%zmm15, 960(%0)\n\t"
: /* no output operands */
: "r" (zmm_data));
- asm ("vmovaps %%zmm16, 1024(%0)\n\t"
- "vmovaps %%zmm17, 1088(%0)\n\t"
- "vmovaps %%zmm18, 1152(%0)\n\t"
- "vmovaps %%zmm19, 1216(%0)\n\t"
- "vmovaps %%zmm20, 1280(%0)\n\t"
- "vmovaps %%zmm21, 1344(%0)\n\t"
- "vmovaps %%zmm22, 1408(%0)\n\t"
- "vmovaps %%zmm23, 1472(%0)\n\t"
- "vmovaps %%zmm24, 1536(%0)\n\t"
- "vmovaps %%zmm25, 1600(%0)\n\t"
- "vmovaps %%zmm26, 1664(%0)\n\t"
- "vmovaps %%zmm27, 1728(%0)\n\t"
- "vmovaps %%zmm28, 1792(%0)\n\t"
- "vmovaps %%zmm29, 1856(%0)\n\t"
- "vmovaps %%zmm30, 1920(%0)\n\t"
- "vmovaps %%zmm31, 1984(%0)\n\t"
+ asm ("vmovups %%zmm16, 1024(%0)\n\t"
+ "vmovups %%zmm17, 1088(%0)\n\t"
+ "vmovups %%zmm18, 1152(%0)\n\t"
+ "vmovups %%zmm19, 1216(%0)\n\t"
+ "vmovups %%zmm20, 1280(%0)\n\t"
+ "vmovups %%zmm21, 1344(%0)\n\t"
+ "vmovups %%zmm22, 1408(%0)\n\t"
+ "vmovups %%zmm23, 1472(%0)\n\t"
+ "vmovups %%zmm24, 1536(%0)\n\t"
+ "vmovups %%zmm25, 1600(%0)\n\t"
+ "vmovups %%zmm26, 1664(%0)\n\t"
+ "vmovups %%zmm27, 1728(%0)\n\t"
+ "vmovups %%zmm28, 1792(%0)\n\t"
+ "vmovups %%zmm29, 1856(%0)\n\t"
+ "vmovups %%zmm30, 1920(%0)\n\t"
+ "vmovups %%zmm31, 1984(%0)\n\t"
: /* no output operands */
: "r" (zmm_data));
#endif
diff --git a/gdb/testsuite/gdb.arch/s390-vregs.exp b/gdb/testsuite/gdb.arch/s390-vregs.exp
index 078c153..d2c31e1 100644
--- a/gdb/testsuite/gdb.arch/s390-vregs.exp
+++ b/gdb/testsuite/gdb.arch/s390-vregs.exp
@@ -147,14 +147,12 @@ gdb_continue_to_breakpoint "change vrs"
set vregs [capture_command_output "info registers vector" ""]
# Format a 128-bit value, given individual 4-byte values, as hex.
-# Leading zeros are suppressed.
+# Suppress leading zeros.
proc hex128 {a_high a_low b_high b_low} {
- set result [format %08x%08x%08x%08x \
- [expr $a_high * ($i + 1) * $a_high ] \
- [expr $a_low * ($i + 1) * $a_low ] \
- [expr $b_high * (32 - $i) * $b_high * 32] \
- [expr $b_low * (32 - $i) * $b_low * 32] ]
- return [regsub -- "^0*" $result ""]
+ set result [format "%x%08x%08x%08x" $a_high $a_low $b_high $b_low]
+ regsub -- "^0*" $result "" result
+ if { $result eq "" } { set result 0 }
+ return $result
}
set j 1
@@ -162,7 +160,11 @@ foreach {- r i val} [regexp -all -inline -line \
{^(\D*)(\d+)\s+.*?uint128 = 0x([0-9a-f]+?)} $vregs] {
if { $r ne "v" } {
fail "info registers vector: bad line $j"
- } elseif { $val ne [hex128 $a_high $a_low $b_high $b_low] } {
+ } elseif { $val ne [hex128 \
+ [expr $a_high * ($i + 1) * $a_high ] \
+ [expr $a_low * ($i + 1) * $a_low ] \
+ [expr $b_high * (32 - $i) * $b_high * 32] \
+ [expr $b_low * (32 - $i) * $b_low * 32] ] } {
fail "compare \$v$i"
}
incr j 1
diff --git a/gdb/testsuite/gdb.arch/sparc64-adi.c b/gdb/testsuite/gdb.arch/sparc64-adi.c
new file mode 100644
index 0000000..704fe26
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/sparc64-adi.c
@@ -0,0 +1,145 @@
+/* Application Data Integrity (ADI) test in sparc64.
+
+ Copyright 2017 Free Software Foundation, Inc.
+
+ This file is part of GDB.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <pthread.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <sys/errno.h>
+#include <sys/utsname.h>
+#include <sys/param.h>
+#include <malloc.h>
+#include <string.h>
+#include <signal.h>
+#include <sys/shm.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <poll.h>
+#include <setjmp.h>
+#include "adi.h"
+
+#define ONEKB 1024
+#define PAT 0xdeadbeaf
+
+#define MAPSIZE 8192
+#define SHMSIZE 102400
+#ifndef PROT_ADI
+#define PROT_ADI 0x10
+#endif
+
+static int
+memory_fill (char *addr, size_t size, int pattern)
+{
+ long *aligned_addr = (long *) addr;
+ long i;
+ for (i = 0; i < size / sizeof (long); i += ONEKB)
+ {
+ *aligned_addr = pattern;
+ aligned_addr = aligned_addr + ONEKB;
+ }
+ return (0);
+}
+
+int main ()
+{
+ char *haddr;
+ caddr_t vaddr;
+ int version;
+
+ /* Test ISM. */
+ int shmid = shmget (IPC_PRIVATE, SHMSIZE, IPC_CREAT | 0666);
+ if (shmid == -1)
+ exit(1);
+ char *shmaddr = (char *)shmat (shmid, NULL, 0x666 | SHM_RND);
+ if (shmaddr == (char *)-1)
+ {
+ shmctl (shmid, IPC_RMID, NULL);
+ exit(1);
+ }
+ /* Enable ADI on ISM segment. */
+ if (mprotect (shmaddr, SHMSIZE, PROT_READ|PROT_WRITE|PROT_ADI))
+ {
+ perror ("mprotect failed");
+ goto err_out;
+ }
+ if (memory_fill (shmaddr, SHMSIZE, PAT) != 0) /* line breakpoint here */
+ {
+ exit(1);
+ }
+ adi_clr_version (shmaddr, SHMSIZE);
+ caddr_t vshmaddr = adi_set_version (shmaddr, SHMSIZE, 0x8);
+ if (vshmaddr == 0)
+ exit(1);
+ /* Test mmap. */
+ int fd = open ("/dev/zero", O_RDWR);
+ if (fd < 0)
+ exit(1);
+ char *maddr = (char *)mmap (NULL, MAPSIZE, PROT_READ|PROT_WRITE,
+ MAP_PRIVATE, fd, 0);
+ if (maddr == (char *)-1)
+ exit(1);
+ /* Enable ADI. */
+ if (mprotect (shmaddr, MAPSIZE, PROT_READ|PROT_WRITE|PROT_ADI))
+ {
+ perror ("mprotect failed");
+ goto err_out;
+
+ }
+ if (memory_fill (maddr, MAPSIZE, PAT) != 0)
+ exit(1);
+ caddr_t vmaddr = adi_set_version (maddr, MAPSIZE, 0x8);
+
+ /* Test heap. */
+ haddr = (char*) memalign (MAPSIZE, MAPSIZE);
+ /* Enable ADI. */
+ if (mprotect (shmaddr, MAPSIZE, PROT_READ|PROT_WRITE|PROT_ADI))
+ {
+ perror ("mprotect failed");
+ goto err_out;
+ }
+
+ if (memory_fill (haddr, MAPSIZE, PAT) != 0)
+ exit(1);
+ adi_clr_version (haddr, MAPSIZE);
+ /* Set some ADP version number. */
+ caddr_t vaddr1, vaddr2, vaddr3, vaddr4;
+ vaddr = adi_set_version (haddr, 64*2, 0x8);
+ vaddr1 = adi_set_version (haddr+64*2, 64*2, 0x9);
+ vaddr2 = adi_clr_version (haddr+64*4, 64*2);
+ vaddr3 = adi_set_version (haddr+64*6, 64*2, 0xa);
+ vaddr4 = adi_set_version (haddr+64*8, 64*10, 0x3);
+ if (vaddr == 0)
+ exit(1);
+ char *versioned_p = vaddr;
+ *versioned_p = 'a';
+ char *uvp = haddr; // unversioned pointer
+ *uvp = 'b'; // version mismatch trap
+
+ return (0);
+err_out:
+ if (shmdt ((const void *)shmaddr) != 0)
+ perror ("Detach failure");
+ shmctl (shmid, IPC_RMID, NULL);
+ exit (1);
+}
diff --git a/gdb/testsuite/gdb.arch/sparc64-adi.exp b/gdb/testsuite/gdb.arch/sparc64-adi.exp
new file mode 100644
index 0000000..410bcf9
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/sparc64-adi.exp
@@ -0,0 +1,53 @@
+# Copyright 2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This file is part of the gdb testsuite.
+
+# Basic tests of examining/assigning ADI version tags, and reporting
+# precise mismatch.
+
+if ![istarget "sparc64*-*-linux*"] then {
+ verbose "Skipping sparc64 ADI test."
+ return 0
+}
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
+ [list debug libs=-ladi]] } {
+ return -1
+}
+
+if ![runto_main] then {
+ untested "could not run to main"
+ return -1
+}
+
+gdb_test "break [gdb_get_line_number "line breakpoint here"]" \
+ "Breakpoint .* at .*${srcfile}.*" \
+ "set line breakpoint in main"
+gdb_continue_to_breakpoint "continue to line breakpoint in main"
+
+##########################################
+set newadi "7"
+gdb_test "adi x shmaddr" "${hex}00:\t0" "examine ADI"
+gdb_test_no_output "adi a/100 shmaddr=${newadi}" "assign ADI"
+gdb_test "adi x/100 shmaddr" "${hex}00:\t${newadi} ${newadi}" \
+ "examine new ADI"
+gdb_test_no_output "adi a/100 shmaddr=0x0" "reset ADI"
+gdb_test "continue" \
+ [multi_line "Program received signal SIGSEGV, Segmentation fault.*" \
+ "ADI precise mismatch while accessing address $hex.*" ] \
+ "continue to sigsegv"
diff --git a/gdb/testsuite/gdb.arch/thumb2-it.exp b/gdb/testsuite/gdb.arch/thumb2-it.exp
index ab0dae3..e100d06 100644
--- a/gdb/testsuite/gdb.arch/thumb2-it.exp
+++ b/gdb/testsuite/gdb.arch/thumb2-it.exp
@@ -58,7 +58,7 @@ proc test_it_block { func } {
return
}
- gdb_test "call ${func}()" "Breakpoint.*@ Setup.*" "$func, call"
+ gdb_test "call (int) ${func}()" "Breakpoint.*@ Setup.*" "$func, call"
set expected 0
set reached 0
@@ -155,7 +155,7 @@ for { set i 1 } { $i <= 8 } { incr i } {
}
gdb_breakpoint "*it_breakpoints"
-gdb_test "call it_breakpoints()" "Breakpoint.*"
+gdb_test "call (int) it_breakpoints()" "Breakpoint.*"
for { set i 1 } { $i <= 7 } { incr i } {
test_it_break ${i}
}
diff --git a/gdb/testsuite/gdb.asm/asm-source.exp b/gdb/testsuite/gdb.asm/asm-source.exp
index e07e554..138609a 100644
--- a/gdb/testsuite/gdb.asm/asm-source.exp
+++ b/gdb/testsuite/gdb.asm/asm-source.exp
@@ -465,14 +465,14 @@ proc test_dis { command var } {
}
# See if we can look at a global variable, three ways
-gdb_test "print globalvar" ".* = 11" "look at global variable"
+gdb_test "print (int) globalvar" ".* = 11" "look at global variable"
test_dis "x/i &globalvar" "globalvar"
-test_dis "disassem &globalvar, &globalvar+1" "globalvar"
+test_dis "disassem &globalvar, (int *) &globalvar+1" "globalvar"
# See if we can look at a static variable, three ways
-gdb_test "print staticvar" ".* = 5" "look at static variable"
+gdb_test "print (int) staticvar" ".* = 5" "look at static variable"
test_dis "x/i &staticvar" "staticvar"
-test_dis "disassem &staticvar, &staticvar+1" "staticvar"
+test_dis "disassem &staticvar, (int *) &staticvar+1" "staticvar"
# See if we can look at a static function
gdb_test "disassem foostatic" ".*<\\+0>:.*End of assembler dump." \
diff --git a/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp b/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp
index eba72bc..080d193 100644
--- a/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp
+++ b/gdb/testsuite/gdb.base/break-main-file-remove-fail.exp
@@ -88,7 +88,7 @@ proc test_remove_bp { initial_load } {
# should warn the user about it.
set pagesize [get_integer_valueof "pg_size" 0]
set align_addr [expr $bp_addr - $bp_addr % $pagesize]
- set munmap [get_integer_valueof "munmap ($align_addr, $pagesize)" -1]
+ set munmap [get_integer_valueof "(int) munmap ($align_addr, $pagesize)" -1]
if {$munmap != 0} {
unsupported "can't munmap foo's page"
diff --git a/gdb/testsuite/gdb.base/break-probes.exp b/gdb/testsuite/gdb.base/break-probes.exp
index 929509a..318a219 100644
--- a/gdb/testsuite/gdb.base/break-probes.exp
+++ b/gdb/testsuite/gdb.base/break-probes.exp
@@ -86,5 +86,5 @@ if { $using_probes } {
}
# Call something to ensure that relocation occurred
- gdb_test "call foo(23)" "\\\$.* = 31.*\\\M.*"
+ gdb_test "call (int) foo(23)" "\\\$.* = 31.*\\\M.*"
}
diff --git a/gdb/testsuite/gdb.base/callfuncs.exp b/gdb/testsuite/gdb.base/callfuncs.exp
index 3651963..a537ebd 100644
--- a/gdb/testsuite/gdb.base/callfuncs.exp
+++ b/gdb/testsuite/gdb.base/callfuncs.exp
@@ -39,7 +39,7 @@ set skip_float_test [gdb_skip_float_test]
# specifies that the numeric value of a relational or logical expression
# (computed in the inferior) is 1 for true and 0 for false.
-proc do_function_calls {} {
+proc do_function_calls {prototypes} {
global gdb_prompt skip_float_test
# We need to up this because this can be really slow on some boards.
@@ -95,11 +95,25 @@ proc do_function_calls {} {
setup_xfail "mn10300-*-*"
if { [test_compiler_info "armcc-*"] } { setup_xfail "*-*-*" }
gdb_test "p t_float_values(float_val1,-2.3765)" " = 1"
+ # Same, via unprototyped function pointer (t_float_values is
+ # always unprototyped).
+ gdb_test "p ((int (*) ()) t_float_values)(float_val1,-2.3765)" " = 1"
# Test passing of arguments which might not be widened.
gdb_test "p t_float_values2(0.0,0.0)" " = 0"
+ # Same, via function pointer.
+ if {$prototypes} {
+ gdb_test "p ((int (*) (float, float)) t_float_values2)(0.0,0.0)" " = 0"
+ } else {
+ gdb_test "p ((int (*) ()) t_float_values2)(0.0,0.0)" " = 0"
+ }
gdb_test "p t_float_values2(3.14159,float_val2)" " = 1"
+ if {$prototypes} {
+ gdb_test "p ((int (*) (float, float)) t_float_values2)(3.14159,float_val2)" " = 1"
+ } else {
+ gdb_test "p ((int (*) ()) t_float_values2)(3.14159,float_val2)" " = 1"
+ }
gdb_test "p t_float_many_args (float_val1, float_val2, float_val3, float_val4, float_val5, float_val6, float_val7, float_val8, float_val9, float_val10, float_val11, float_val12, float_val13, float_val14, float_val15)" " = 1" "call function with many float arguments."
@@ -315,7 +329,7 @@ proc rerun_and_prepare {} {
"next to t_structs_c"
}
-proc perform_all_tests {} {
+proc perform_all_tests {prototypes} {
gdb_test_no_output "set print sevenbit-strings"
gdb_test_no_output "set print address off"
gdb_test_no_output "set width 0"
@@ -326,7 +340,7 @@ proc perform_all_tests {} {
set old_reg_content [fetch_all_registers "retrieve original register contents"]
# Perform function calls.
- do_function_calls
+ do_function_calls $prototypes
# Check if all registers still have the same value.
set new_reg_content [fetch_all_registers \
@@ -500,9 +514,11 @@ proc perform_all_tests {} {
# Perform all tests with and without function prototypes.
if { ![prepare_for_testing "failed to prepare" $testfile $srcfile "$compile_flags additional_flags=-DPROTOTYPES"] } {
- perform_all_tests
+ perform_all_tests 1
}
if { ![prepare_for_testing "failed to prepare" $testfile $srcfile "$compile_flags additional_flags=-DNO_PROTOTYPES"] } {
- with_test_prefix "noproto" perform_all_tests
+ with_test_prefix "noproto" {
+ perform_all_tests 0
+ }
}
diff --git a/gdb/testsuite/gdb.base/checkpoint.exp b/gdb/testsuite/gdb.base/checkpoint.exp
index 12c1d8a..677c389 100644
--- a/gdb/testsuite/gdb.base/checkpoint.exp
+++ b/gdb/testsuite/gdb.base/checkpoint.exp
@@ -224,45 +224,11 @@ gdb_test "shell diff $pi_txt $copy1_txt" \
delete_breakpoints
gdb_breakpoint $break2_loc
-gdb_test "restart 1" "if .c == EOF.*" "restart 1 three"
-gdb_test "continue" "breakpoint 2.*" "break2 1 one"
-gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 1"
-
-gdb_test "restart 2" "if .c == EOF.*" "restart 2 three"
-gdb_test "continue" "breakpoint 2.*" "break2 2 one"
-gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 2"
-
-gdb_test "restart 3" "if .c == EOF.*" "restart 3 three"
-gdb_test "continue" "breakpoint 2.*" "break2 3 one"
-gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 3"
-
-gdb_test "restart 4" "if .c == EOF.*" "restart 4 three"
-gdb_test "continue" "breakpoint 2.*" "break2 4 one"
-gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 4"
-
-gdb_test "restart 5" "if .c == EOF.*" "restart 5 three"
-gdb_test "continue" "breakpoint 2.*" "break2 5 one"
-gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 5"
-
-gdb_test "restart 6" "if .c == EOF.*" "restart 6 three"
-gdb_test "continue" "breakpoint 2.*" "break2 6 one"
-gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 6"
-
-gdb_test "restart 7" "if .c == EOF.*" "restart 7 three"
-gdb_test "continue" "breakpoint 2.*" "break2 7 one"
-gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 7"
-
-gdb_test "restart 8" "if .c == EOF.*" "restart 8 three"
-gdb_test "continue" "breakpoint 2.*" "break2 8 one"
-gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 8"
-
-gdb_test "restart 9" "if .c == EOF.*" "restart 9 three"
-gdb_test "continue" "breakpoint 2.*" "break2 9 one"
-gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 9"
-
-gdb_test "restart 10" "if .c == EOF.*" "restart 10 three"
-gdb_test "continue" "breakpoint 2.*" "break2 10 one"
-gdb_test "print ftell (out) > 100000" " = 1.*" "outfile still open 10"
+for {set num 1} {$num <= 10} {incr num} {
+ gdb_test "restart $num" "if .c == EOF.*" "restart $num three"
+ gdb_test "continue" "breakpoint 2.*" "break2 $num one"
+ gdb_test "print (long) ftell (out) > 100000" " = 1.*" "outfile still open $num"
+}
#
# Now confirm that if one fork exits, we automatically switch to another one.
diff --git a/gdb/testsuite/gdb.base/commands.exp b/gdb/testsuite/gdb.base/commands.exp
index 4963743..17f113c 100644
--- a/gdb/testsuite/gdb.base/commands.exp
+++ b/gdb/testsuite/gdb.base/commands.exp
@@ -34,7 +34,6 @@ proc runto_or_return {function} {
}
proc_with_prefix gdbvar_simple_if_test {} {
- global gdb_prompt
global valnum_re
gdb_test_no_output "set \$foo = 0" "set foo"
@@ -62,7 +61,6 @@ proc_with_prefix gdbvar_simple_if_test {} {
}
proc_with_prefix gdbvar_simple_while_test {} {
- global gdb_prompt
global valnum_re
gdb_test_no_output "set \$foo = 5" "set foo"
@@ -83,7 +81,6 @@ proc_with_prefix gdbvar_simple_while_test {} {
}
proc_with_prefix gdbvar_complex_if_while_test {} {
- global gdb_prompt
global valnum_re
gdb_test_no_output "set \$foo = 4" "set foo"
@@ -107,7 +104,6 @@ proc_with_prefix gdbvar_complex_if_while_test {} {
}
proc_with_prefix progvar_simple_if_test {} {
- global gdb_prompt
global valnum_re
runto_or_return factorial
@@ -139,7 +135,6 @@ proc_with_prefix progvar_simple_if_test {} {
}
proc_with_prefix progvar_simple_while_test {} {
- global gdb_prompt
global valnum_re
runto_or_return factorial
@@ -164,7 +159,6 @@ proc_with_prefix progvar_simple_while_test {} {
}
proc_with_prefix progvar_complex_if_while_test {} {
- global gdb_prompt
global valnum_re
runto_or_return factorial
@@ -289,7 +283,6 @@ proc_with_prefix breakpoint_command_test {} {
# Test a simple user defined command (with arguments)
proc_with_prefix user_defined_command_test {} {
- global gdb_prompt
global valnum_re
gdb_test_no_output "set \$foo = 4" "set foo"
@@ -352,11 +345,38 @@ proc_with_prefix user_defined_command_test {} {
"display user-defined empty command"
}
+# Test that the case with which the command was defined is preserved.
+
+proc_with_prefix user_defined_command_case_sensitivity {} {
+ # Define a first command with mixed case name.
+ set test "define Homer-Simpson"
+ gdb_test_multiple $test $test {
+ -re "End with" {
+ pass $test
+ }
+ }
+
+ gdb_test "print 123\nend" "" "enter commands 1"
+
+ # Define a second command, same name but different case.
+ set test "define HomeR-SimpsoN"
+ gdb_test_multiple $test $test {
+ -re "End with" {
+ pass $test
+ }
+ }
+
+ gdb_test "print 456\nend" "" "enter commands 2"
+
+ gdb_test "Homer-Simpson" " = 123" "execute command"
+ gdb_test "HomeR-SimpsoN" " = 456" "execute command"
+ gdb_test "HOMER-SIMPSON" "Undefined command.*" "try to call in upper case"
+ gdb_test "homer-simpson" "Undefined command.*" "try to call in lower case"
+}
+
# Test that "eval" in a user-defined command expands $argc/$argN.
proc_with_prefix user_defined_command_args_eval {} {
- global gdb_prompt
-
gdb_test_multiple "define command_args_eval" \
"define command_args_eval" {
-re "End with" {
@@ -387,8 +407,6 @@ proc_with_prefix user_defined_command_args_eval {} {
# user-defined command (or in this case, recurses).
proc_with_prefix user_defined_command_args_stack_test {} {
- global gdb_prompt
-
gdb_test_multiple "define args_stack_command" \
"define args_stack_command" {
-re "End with" {
@@ -444,8 +462,6 @@ proc_with_prefix user_defined_command_args_stack_test {} {
# used to have a hard coded limit of 10 arguments.
proc_with_prefix user_defined_command_manyargs_test {} {
- global gdb_prompt
-
set test "define command"
gdb_test_multiple "define manyargs" $test {
-re "End with" {
@@ -678,8 +694,6 @@ proc_with_prefix bp_deleted_in_command_test {} {
}
proc_with_prefix temporary_breakpoint_commands {} {
- global gdb_prompt
-
delete_breakpoints
# Create a temporary breakpoint, and associate a commands list to it.
@@ -795,8 +809,6 @@ end"
}
proc gdb_test_no_prompt { command result msg } {
- global gdb_prompt
-
set msg "$command - $msg"
set result "^[string_to_regexp $command]\r\n$result$"
gdb_test_multiple $command $msg {
@@ -943,8 +955,6 @@ proc_with_prefix error_clears_commands_left {} {
}
proc_with_prefix redefine_hook_test {} {
- global gdb_prompt
-
gdb_test \
[multi_line_input \
"define one"\
@@ -978,8 +988,6 @@ proc_with_prefix redefine_hook_test {} {
}
proc_with_prefix redefine_backtrace_test {} {
- global gdb_prompt
-
gdb_test_multiple "define backtrace" "define backtrace" {
-re "Really redefine built-in command \"backtrace\"\\? \\(y or n\\) $" {
pass "define backtrace"
@@ -1003,6 +1011,81 @@ proc_with_prefix redefine_backtrace_test {} {
gdb_test "bt" "hibob" "execute bt command"
}
+# Test using "if" and "while" without args when building a command list.
+
+proc define_if_without_arg_test {} {
+ foreach cmd {if while} {
+ set test "define some_command_$cmd"
+ gdb_test_multiple $test $test {
+ -re "End with" {
+ pass $test
+ }
+ }
+
+ gdb_test "$cmd" "if/while commands require arguments." "type $cmd without args"
+ }
+}
+
+# Test the loop_break command.
+
+proc_with_prefix loop_break_test {} {
+ gdb_test_no_output "set \$a = 0" "initialize \$a"
+ gdb_test_no_output "set \$total = 0" "initialize \$total"
+
+ gdb_test \
+ [multi_line_input \
+ "while \$a < 5" \
+ " if \$a == 4" \
+ " loop_break" \
+ " end" \
+ " set \$b = 0" \
+ " while \$b < 5" \
+ " if \$b == 2" \
+ " loop_break" \
+ " end" \
+ " set \$total = \$total + 1" \
+ " set \$b = \$b + 1" \
+ " end" \
+ " set \$a = \$a + 1" \
+ "end"] \
+ "" \
+ "run while loop"
+
+ gdb_test "print \$a" " = 4" "validate \$a"
+ gdb_test "print \$b" " = 2" "validate \$b"
+ gdb_test "print \$total" " = 8" "validate \$total"
+}
+
+# Test the loop_continue command.
+
+proc_with_prefix loop_continue_test {} {
+ gdb_test_no_output "set \$a = 0" "initialize \$a"
+ gdb_test_no_output "set \$total = 0" "initialize \$total"
+
+ gdb_test \
+ [multi_line_input \
+ "while \$a < 5" \
+ " set \$a = \$a + 1" \
+ " set \$b = 0" \
+ " if \$a == 4" \
+ " loop_continue" \
+ " end" \
+ " while \$b < 5" \
+ " set \$b = \$b + 1" \
+ " if \$b == 2" \
+ " loop_continue" \
+ " end" \
+ " set \$total = \$total + 1" \
+ " end" \
+ "end"] \
+ "" \
+ "run while loop"
+
+ gdb_test "print \$a" " = 5" "validate \$a"
+ gdb_test "print \$b" " = 5" "validate \$b"
+ gdb_test "print \$total" " = 16" "validate \$total"
+}
+
# Test an input line split with a continuation character (backslash)
# while entering a multi-line command (in a secondary prompt).
@@ -1052,6 +1135,7 @@ if_while_breakpoint_command_test
infrun_breakpoint_command_test
breakpoint_command_test
user_defined_command_test
+user_defined_command_case_sensitivity
user_defined_command_args_eval
user_defined_command_args_stack_test
user_defined_command_manyargs_test
@@ -1067,5 +1151,8 @@ if_commands_test
error_clears_commands_left
redefine_hook_test
backslash_in_multi_line_command_test
+define_if_without_arg_test
+loop_break_test
+loop_continue_test
# This one should come last, as it redefines "backtrace".
redefine_backtrace_test
diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp
index 6597ea7..f03bfc3 100644
--- a/gdb/testsuite/gdb.base/completion.exp
+++ b/gdb/testsuite/gdb.base/completion.exp
@@ -790,7 +790,7 @@ gdb_test_multiple "" $test {
-re "break\.c.*break1\.c.*$gdb_prompt " {
send_gdb "1\t\n"
gdb_test_multiple "" $test {
- -re ".*Function \"$srcfile2\" not defined\..*$gdb_prompt " {
+ -re "malformed linespec error: unexpected end of input\r\n$gdb_prompt " {
pass $test
}
-re "$gdb_prompt p$" {
diff --git a/gdb/testsuite/gdb.base/default.exp b/gdb/testsuite/gdb.base/default.exp
index 8c0b29c..c25069a 100644
--- a/gdb/testsuite/gdb.base/default.exp
+++ b/gdb/testsuite/gdb.base/default.exp
@@ -511,7 +511,7 @@ gdb_test "set history size" "Argument required .integer to set it to.*" "set his
#test set history
gdb_test "set history" "\"set history\" must be followed by the name of a history subcommand.(\[^\r\n\]*\[\r\n\])+List of set history subcommands:(\[^\r\n\]*\[\r\n\])+set history expansion -- Set history expansion on command input(\[^\r\n\]*\[\r\n\])+set history filename -- Set the filename in which to record the command history(\[^\r\n\]*\[\r\n\])+set history save -- Set saving of the history record on exit(\[^\r\n\]*\[\r\n\])+set history size -- Set the size of the command history(\[^\r\n\]*\[\r\n\])+Type \"help set history\" followed by set history subcommand name for full documentation.(\[^\r\n\]*\[\r\n\])+Command name abbreviations are allowed if unambiguous." "set history"
#test set language
-gdb_test "set language" "Requires an argument. Valid arguments are ada, c, c.., asm, minimal, d, fortran, go, auto, local, unknown, modula-2, objective-c, opencl, pascal, rust." "set language"
+gdb_test "set language" "Requires an argument. Valid arguments are auto, local, unknown, ada, asm, c, c.., d, fortran, go, minimal, modula-2, objective-c, opencl, pascal, rust." "set language"
#test set listsize
gdb_test "set listsize" "Argument required .integer to set it to.*" "set listsize"
#test set print "p" abbreviation
diff --git a/gdb/testsuite/gdb.base/dfp-test.c b/gdb/testsuite/gdb.base/dfp-test.c
index 3af2b4d..a184acb 100644
--- a/gdb/testsuite/gdb.base/dfp-test.c
+++ b/gdb/testsuite/gdb.base/dfp-test.c
@@ -91,6 +91,23 @@ volatile _Decimal32 d32;
volatile _Decimal64 d64;
volatile _Decimal128 d128;
+/* Typedefs and typedefs of typedefs, for ptype/whatis testing. */
+typedef _Decimal32 d32_t;
+typedef _Decimal64 d64_t;
+typedef _Decimal128 d128_t;
+
+typedef d32_t d32_t2;
+typedef d64_t d64_t2;
+typedef d128_t d128_t2;
+
+d32_t v_d32_t;
+d64_t v_d64_t;
+d128_t v_d128_t;
+
+d32_t2 v_d32_t2;
+d64_t2 v_d64_t2;
+d128_t2 v_d128_t2;
+
struct decstruct
{
int int4;
diff --git a/gdb/testsuite/gdb.base/dfp-test.exp b/gdb/testsuite/gdb.base/dfp-test.exp
index 5f7b13d..c3a51a4 100644
--- a/gdb/testsuite/gdb.base/dfp-test.exp
+++ b/gdb/testsuite/gdb.base/dfp-test.exp
@@ -274,6 +274,10 @@ gdb_test "ptype d64 + ds.dec32" " = volatile _Decimal64"
gdb_test "ptype d128 + ds.dec32" " = volatile _Decimal128"
gdb_test "ptype d128 + ds.dec64" " = volatile _Decimal128"
+gdb_test "whatis d64 + ds.dec32" " = volatile _Decimal64"
+gdb_test "whatis d128 + ds.dec32" " = volatile _Decimal128"
+gdb_test "whatis d128 + ds.dec64" " = volatile _Decimal128"
+
# Mixture of Decimal and integral operands
gdb_test "p d32 + 1" " = 1.1"
gdb_test "p 2 + d64" " = 2.1"
@@ -331,3 +335,58 @@ gdb_test "print ds.dec128 = -ds.double8" " = 0.(0999.*|1000.*)"
gdb_test "print ds.dec128 = ds.dec32" " = -0.1"
gdb_test "print ds.dec32 = ds.int4" " = 1"
gdb_test "print ds.int4 = 7.3dl" " = 7"
+
+# Test "whatis"/"ptype" of expressions involving casts to/from dfp
+# typedefs.
+
+# This list is composed by sub-lists, and their elements are (in
+# order):
+#
+# - Type to cast to. This is also what "whatis" should print.
+# - What "ptype" should print.
+
+# Columns in the sublists represent:
+ # to/whatis # ptype
+foreach elem {
+ {"_Decimal32" "_Decimal32"}
+ {"_Decimal64" "_Decimal64"}
+ {"_Decimal128" "_Decimal128"}
+ {"d32_t" "_Decimal32"}
+ {"d64_t" "_Decimal64"}
+ {"d128_t" "_Decimal128"}
+ {"d32_t2" "_Decimal32"}
+ {"d64_t2" "_Decimal64"}
+ {"d128_t2" "_Decimal128"}
+} {
+ set type [lindex $elem 0]
+ set ptype [lindex $elem 1]
+ gdb_test "whatis ($type) 0" " = $type"
+ gdb_test "ptype ($type) 0" " = $ptype"
+}
+
+# Test:
+# - whatis/ptype of variables of typedef type.
+# - whatis/ptype of typedef type names.
+# - whatis/ptype of typedef-of-typedef type names.
+
+# Columns in the sublists represent:
+ # Type name # whatis # ptype
+foreach elem {
+ {"v_d32_t" "d32_t" "_Decimal32"}
+ {"v_d64_t" "d64_t" "_Decimal64"}
+ {"v_d128_t" "d128_t" "_Decimal128"}
+
+ {"d32_t" "_Decimal32" "_Decimal32"}
+ {"d64_t" "_Decimal64" "_Decimal64"}
+ {"d128_t" "_Decimal128" "_Decimal128"}
+
+ {"d32_t2" "d32_t" "_Decimal32"}
+ {"d64_t2" "d64_t" "_Decimal64"}
+ {"d128_t2" "d128_t" "_Decimal128"}
+} {
+ set type [lindex $elem 0]
+ set whatis [lindex $elem 1]
+ set ptype [lindex $elem 2]
+ gdb_test "whatis $type" " = $whatis"
+ gdb_test "ptype $type" " = $ptype"
+}
diff --git a/gdb/testsuite/gdb.base/dmsym.c b/gdb/testsuite/gdb.base/dmsym.c
index f358b51..dccea23 100644
--- a/gdb/testsuite/gdb.base/dmsym.c
+++ b/gdb/testsuite/gdb.base/dmsym.c
@@ -15,11 +15,11 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-int pck__foo__bar__minsym = 123;
+static int test_minsym = 123;
int
-get_pck__foo__bar__minsym (void)
+get_test_minsym (void)
{
- pck__foo__bar__minsym++;
- return pck__foo__bar__minsym;
+ test_minsym++;
+ return test_minsym;
}
diff --git a/gdb/testsuite/gdb.base/dmsym.exp b/gdb/testsuite/gdb.base/dmsym.exp
index a318080..191a319 100644
--- a/gdb/testsuite/gdb.base/dmsym.exp
+++ b/gdb/testsuite/gdb.base/dmsym.exp
@@ -44,42 +44,31 @@ clean_restart ${testfile}
set num "\[0-9\]+"
set addr "0x\[0-9a-zA-Z\]+"
-# Although the test program is written in C, the original problem
-# occurs only when the language is Ada. The use of a C program is
-# only a convenience to be able to exercise the original problem
-# without requiring an Ada compiler. In the meantime, temporarily
-# force the language to Ada.
-
-gdb_test_no_output "set lang ada"
-
-# Verify that setting a breakpoint on `pck__foo__bar__minsym' only
-# results in one location found (function pck__foo__bar__minsym__2).
-# A mistake would be to also insert a breakpoint where
-# pck__foo__bar__minsym is defined. Despite the fact that there is
-# no debugging info available, this is a data symbol and thus should
-# not be used for breakpoint purposes.
-
-gdb_test "break pck__foo__bar__minsym" \
+# Verify that setting a breakpoint on `test_minsym' only results in
+# one location found. A mistake would be to also insert a breakpoint
+# in the test_minsym data symbol in dmsym.c. Despite the fact that
+# there is no debugging info available, this is a data symbol and thus
+# should not be used for breakpoint purposes.
+
+gdb_test "break test_minsym" \
"Breakpoint $num at $addr.: file .*dmsym_main\\.c, line $num\\."
# However, verify that the `info line' command, on the other hand,
# finds both locations.
-gdb_test "info line pck__foo__bar__minsym" \
- "Line $num of \".*dmsym_main\\.c\" .*\r\nNo line number information available for address $addr <pck__foo__bar__minsym>"
-
-gdb_test_no_output "set lang auto"
+gdb_test "info line test_minsym" \
+ "Line $num of \".*dmsym_main\\.c\" .*\r\nNo line number information available for address $addr <test_minsym>"
-# Now, run the program until we get past the call to
-# pck__foo__bar__minsym__2. Except when using hardware breakpoints,
-# inferior behavior is going to be affected if a breakpoint was
-# incorrectly inserted at pck__foo__bar__minsym.
+# Now, run the program until we get past the call to test_minsym.
+# Except when using hardware breakpoints, inferior behavior is going
+# to be affected if a breakpoint was incorrectly inserted at
+# test_minsym.
gdb_breakpoint dmsym_main.c:[gdb_get_line_number "BREAK" dmsym_main.c]
gdb_run_cmd
gdb_test "" \
- "Breakpoint $num, pck__foo__bar__minsym__2 \\(\\) at.*" \
+ "Breakpoint $num, test_minsym \\(\\) at.*" \
"run until breakpoint at BREAK"
gdb_test "continue" \
diff --git a/gdb/testsuite/gdb.base/dmsym_main.c b/gdb/testsuite/gdb.base/dmsym_main.c
index 99589b8..0338dc7 100644
--- a/gdb/testsuite/gdb.base/dmsym_main.c
+++ b/gdb/testsuite/gdb.base/dmsym_main.c
@@ -15,18 +15,18 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-extern int get_pck__foo__bar__minsym (void);
+extern int get_test_minsym (void);
-int
-pck__foo__bar__minsym__2 (void)
+static int
+test_minsym (void)
{
- return get_pck__foo__bar__minsym ();
+ return get_test_minsym ();
}
int
main (void)
{
- int val = pck__foo__bar__minsym__2 ();
+ int val = test_minsym ();
if (val != 124) /* BREAK */
return 1;
diff --git a/gdb/testsuite/gdb.base/dprintf-detach.exp b/gdb/testsuite/gdb.base/dprintf-detach.exp
index 4c6ef1c..940a9ef 100644
--- a/gdb/testsuite/gdb.base/dprintf-detach.exp
+++ b/gdb/testsuite/gdb.base/dprintf-detach.exp
@@ -53,7 +53,7 @@ proc dprintf_detach_test { breakpoint_always_inserted dprintf_style disconnected
# Get PID of test program.
set inferior_pid -1
set test "get inferior process ID"
- gdb_test_multiple "call getpid ()" $test {
+ gdb_test_multiple "call (int) getpid ()" $test {
-re ".* = ($decimal).*$gdb_prompt $" {
set inferior_pid $expect_out(1,string)
pass $test
diff --git a/gdb/testsuite/gdb.base/ena-dis-br.exp b/gdb/testsuite/gdb.base/ena-dis-br.exp
index 8abca35..d407408 100644
--- a/gdb/testsuite/gdb.base/ena-dis-br.exp
+++ b/gdb/testsuite/gdb.base/ena-dis-br.exp
@@ -369,7 +369,7 @@ proc test_ena_dis_br { what } {
# Now enable(disable) $b1 fooo.1, it should give error on fooo.
gdb_test "$what $b1 fooo.1" \
- "Bad breakpoint number 'fooo'" \
+ "Bad breakpoint number 'fooo\\.1'" \
"$what \$b1 fooo.1"
# $b1 should be enabled(disabled).
diff --git a/gdb/testsuite/gdb.base/environ.exp b/gdb/testsuite/gdb.base/environ.exp
index 0b69a80..bb52063 100644
--- a/gdb/testsuite/gdb.base/environ.exp
+++ b/gdb/testsuite/gdb.base/environ.exp
@@ -46,6 +46,9 @@ gdb_test "unset environment" "" "unset all environment variables" \
"Delete all environment variables. .y or n. $" \
"y"
+gdb_test_no_output "show environment" \
+ "all environment variables have been unset"
+
# Verify that we can set a specific environment variable.
test_set_show_env_var "EDITOR" "emacs" "set environment variable"
diff --git a/gdb/testsuite/gdb.base/gnu_vector.exp b/gdb/testsuite/gdb.base/gnu_vector.exp
index 44b1405..dac1714 100644
--- a/gdb/testsuite/gdb.base/gnu_vector.exp
+++ b/gdb/testsuite/gdb.base/gnu_vector.exp
@@ -95,6 +95,17 @@ gdb_test "print -f4a" "\\\$$decimal = \\{-2, -4, -8, -16\\}"
gdb_test "print (char4) 0x01010101" "\\\$$decimal = \\{1, 1, 1, 1\\}"
gdb_test "print (int2) lla" "\\\$$decimal = \\{1, 1\\}"
+# Check that "whatis" doesn't peel off the destination type's typedef
+# by mistake, in expressions that involve a cast to typedef type.
+gdb_test "whatis (char4) 0x01010101" "type = char4"
+gdb_test "whatis (int2) lla" "type = int2"
+# Check that OTOH "ptype" does peel off the destination type's
+# typedef.
+gdb_test "ptype (char4) 0x01010101" \
+ "type = char __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+gdb_test "ptype (int2) lla" \
+ "type = int __attribute__ \\(\\(vector_size\\(2\\)\\)\\)"
+
if { ![string compare $endian big] } then {
gdb_test "print (char4) ia" "\\\$$decimal = \\{0, 0, 0, 2\\}"
} else {
@@ -167,16 +178,30 @@ gdb_test "print (double2) f2" "Cannot convert between vector values of different
gdb_test "print (int4) c4" "Cannot convert between vector values of different sizes"
gdb_test "print (char4) i4a" "Cannot convert between vector values of different sizes"
-# Test ptype on vector types.
+# Test ptype/whatis on vector types/vars.
gdb_test "ptype c4" "type = char __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+gdb_test "whatis c4" "type = char4"
+
gdb_test "ptype char4" "type = char __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+gdb_test "whatis char4" "type = char __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+
gdb_test "ptype i4a" "type = int __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+gdb_test "whatis i4a" "type = int4"
+
gdb_test "ptype int4" "type = int __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+gdb_test "whatis int4" "type = int __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+
gdb_test "ptype f4b" "type = float __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+gdb_test "whatis f4b" "type = float4"
+
gdb_test "ptype float4" "type = float __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
+gdb_test "whatis float4" "type = float __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
gdb_test "ptype union_with_vector_1" "type = union {\r\n\[\t \]+int i;\r\n\[\t \]+char cv __attribute__ \\(\\(vector_size\\(4\\)\\)\\);\r\n}"
+gdb_test "whatis union_with_vector_1" {type = union {...}}
+
gdb_test "ptype struct_with_vector_1" "type = struct {\r\n\[\t \]+int i;\r\n\[\t \]+char cv __attribute__ \\(\\(vector_size\\(4\\)\\)\\);\r\n\[\t \]+float4 f4;\r\n}"
+gdb_test "whatis struct_with_vector_1" {type = struct {...}}
# Test inferior function calls with vector arguments and/or vector
# return values.
diff --git a/gdb/testsuite/gdb.base/infcall-exec.exp b/gdb/testsuite/gdb.base/infcall-exec.exp
index 3984076..8419905 100644
--- a/gdb/testsuite/gdb.base/infcall-exec.exp
+++ b/gdb/testsuite/gdb.base/infcall-exec.exp
@@ -44,5 +44,5 @@ append expected_result "\[\r\n\]+.*"
append expected_result "Breakpoint 1, main .*at .*$srcfile2:$decimal"
append expected_result ".*"
-gdb_test "call execlp \(\"$binfile2\", \"$binfile2\", \(char \*\)0\)" \
+gdb_test "call (int) execlp \(\"$binfile2\", \"$binfile2\", \(char \*\)0\)" \
$expected_result "call execlp"
diff --git a/gdb/testsuite/gdb.base/info-os.exp b/gdb/testsuite/gdb.base/info-os.exp
index 0168ccb..574da26 100644
--- a/gdb/testsuite/gdb.base/info-os.exp
+++ b/gdb/testsuite/gdb.base/info-os.exp
@@ -39,14 +39,18 @@ if ![runto_main] then {
}
# Get PID of test program.
-set inferior_pid -1
+set inferior_pid ""
set test "get inferior process ID"
-gdb_test_multiple "call getpid()" $test {
+gdb_test_multiple "call (int) getpid()" $test {
-re ".* = ($decimal).*$gdb_prompt $" {
set inferior_pid $expect_out(1,string)
pass $test
}
}
+if {$inferior_pid == ""} {
+ untested "failed to get pid"
+ return
+}
gdb_breakpoint ${srcfile}:[gdb_get_line_number "Set breakpoint here"]
gdb_continue_to_breakpoint "Set breakpoint here"
diff --git a/gdb/testsuite/gdb.base/list-ambiguous.exp b/gdb/testsuite/gdb.base/list-ambiguous.exp
new file mode 100644
index 0000000..ace3494
--- /dev/null
+++ b/gdb/testsuite/gdb.base/list-ambiguous.exp
@@ -0,0 +1,79 @@
+# Copyright 2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test the "list" command with linespecs that expand to multiple
+# locations.
+
+standard_testfile list-ambiguous0.c list-ambiguous1.c
+
+if {[prepare_for_testing "failed to prepare" $testfile [list $srcfile $srcfile2] \
+ {debug}]} {
+ return -1
+}
+
+# Build source listing pattern based on an inclusive line range.
+
+proc line_range_pattern { range_start range_end } {
+ global line_re
+
+ for {set i $range_start} {$i <= $range_end} {incr i} {
+ append pattern "\r\n$i\[ \t\]\[^\r\n\]*"
+ }
+
+ verbose -log "pattern $pattern"
+ return $pattern
+}
+
+# Test the "list" command with linespecs that expand to multiple
+# locations.
+
+proc test_list_ambiguous_symbol {symbol_line symbol} {
+ global srcfile srcfile2
+
+ set lineno0 [gdb_get_line_number $symbol_line $srcfile]
+ set lineno1 [gdb_get_line_number $symbol_line $srcfile2]
+ set lines0_re [line_range_pattern [expr $lineno0 - 5] [expr $lineno0 + 4]]
+ set lines1_re [line_range_pattern [expr $lineno1 - 5] [expr $lineno1 + 4]]
+
+ set any "\[^\r\n\]*"
+ set h0_re "file: \"${any}list-ambiguous0.c\", line number: $lineno0, symbol: \"$symbol\""
+ set h1_re "file: \"${any}list-ambiguous1.c\", line number: $lineno1, symbol: \"$symbol\""
+ gdb_test "list $symbol" "${h0_re}${lines0_re}\r\n${h1_re}${lines1_re}"
+
+ gdb_test "list main,$symbol" \
+ "Specified last line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
+ gdb_test "list ,$symbol" \
+ "Specified last line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
+ gdb_test "list $symbol,main" \
+ "Specified first line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
+ gdb_test "list $symbol,$symbol" \
+ "Specified first line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
+ gdb_test "list $symbol," \
+ "Specified first line '$symbol' is ambiguous:\r\n${h0_re}\r\n${h1_re}"
+
+ # While at it, test the "edit" command as well, since it shares
+ # code with "list".
+ gdb_test "edit $symbol" \
+ "Specified line is ambiguous:\r\n${h0_re}\r\n${h1_re}"
+}
+
+proc test_list_ambiguous_function {} {
+ test_list_ambiguous_symbol "ambiguous_fun (void)" "ambiguous_fun"
+ test_list_ambiguous_symbol "ambiguous_var" "ambiguous_var"
+}
+
+gdb_test_no_output "set listsize 10"
+
+test_list_ambiguous_function
diff --git a/gdb/testsuite/gdb.base/list-ambiguous0.c b/gdb/testsuite/gdb.base/list-ambiguous0.c
new file mode 100644
index 0000000..afd9457
--- /dev/null
+++ b/gdb/testsuite/gdb.base/list-ambiguous0.c
@@ -0,0 +1,42 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2017 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+
+
+
+
+/* These symbols are defined in both
+ list-ambiguous0.c/list-ambiguous1.c files, in order to test
+ "list"'s behavior with ambiguous linespecs. */
+
+static void __attribute__ ((used)) ambiguous_fun (void) {}
+
+static int ambiguous_var;
+
+
+
+
+
+
+
+
+
+int
+main (void)
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/list-ambiguous1.c b/gdb/testsuite/gdb.base/list-ambiguous1.c
new file mode 100644
index 0000000..69db11e
--- /dev/null
+++ b/gdb/testsuite/gdb.base/list-ambiguous1.c
@@ -0,0 +1,41 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2017 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+
+
+
+
+
+
+
+
+/* These symbols are defined in both
+ list-ambiguous0.c/list-ambiguous1.c files, in order to test
+ "list"'s behavior with ambiguous linespecs. */
+static void __attribute__ ((used)) ambiguous_fun (void) {}
+
+static int ambiguous_var;
+
+
+
+
+
+
+
+
+
+/* last line */
diff --git a/gdb/testsuite/gdb.base/list.exp b/gdb/testsuite/gdb.base/list.exp
index 5377571..d554c9e 100644
--- a/gdb/testsuite/gdb.base/list.exp
+++ b/gdb/testsuite/gdb.base/list.exp
@@ -361,7 +361,7 @@ proc test_list_range {} {
gdb_test "list ${past_end},${much_past_end}" "Line number ${past_end} out of range; .*list0.c has ${last_line} lines." "list range; both bounds past EOF"
- gdb_test "list list0.c:2,list1.c:17" "Specified start and end are in different files." "list range, must be same files"
+ gdb_test "list list0.c:2,list1.c:17" "Specified first and last lines are in different files." "list range, must be same files"
}
#
diff --git a/gdb/testsuite/gdb.base/nodebug.c b/gdb/testsuite/gdb.base/nodebug.c
index eb5d661..c7bc939 100644
--- a/gdb/testsuite/gdb.base/nodebug.c
+++ b/gdb/testsuite/gdb.base/nodebug.c
@@ -1,4 +1,6 @@
#include <stdlib.h>
+#include <stdint.h>
+
/* Test that things still (sort of) work when compiled without -g. */
int dataglobal = 3; /* Should go in global data */
@@ -6,6 +8,13 @@ static int datalocal = 4; /* Should go in local data */
int bssglobal; /* Should go in global bss */
static int bsslocal; /* Should go in local bss */
+/* Non-int-sized global data variables. */
+uint8_t dataglobal8 = 0xff;
+uint32_t dataglobal32_1 = 0x7fffffff;
+uint32_t dataglobal32_2 = 0x000000ff;
+uint64_t dataglobal64_1 = 0x7fffffffffffffff;
+uint64_t dataglobal64_2 = 0x00000000000000ff;
+
int
inner (int x)
{
@@ -43,3 +52,42 @@ int array_index (char *arr, int i)
free (x);
return retval;
}
+
+float
+multf (float v1, float v2)
+{
+ return v1 * v2;
+}
+
+float
+multf_noproto (v1, v2)
+ float v1, v2;
+{
+ return v1 * v2;
+}
+
+double
+mult (double v1, double v2)
+{
+ return v1 * v2;
+}
+
+double
+mult_noproto (v1, v2)
+ double v1, v2;
+{
+ return v1 * v2;
+}
+
+uint8_t
+add8 (uint8_t v1, uint8_t v2)
+{
+ return v1 + v2;
+}
+
+uint8_t
+add8_noproto (v1, v2)
+ uint8_t v1, v2;
+{
+ return v1 + v2;
+}
diff --git a/gdb/testsuite/gdb.base/nodebug.exp b/gdb/testsuite/gdb.base/nodebug.exp
index a54e5bb..3a2a821 100644
--- a/gdb/testsuite/gdb.base/nodebug.exp
+++ b/gdb/testsuite/gdb.base/nodebug.exp
@@ -39,7 +39,56 @@ if { [gdb_compile $srcdir/$subdir/$srcfile $binfile executable $exec_opts] != "
clean_restart $binfile
-if [runto inner] then {
+# Run to FUNC and unload symbols from system shared libraries, to
+# avoid conflicts with the minsyms in the program. E.g.,
+# intl/plural-exp.h has 'enum expression_operator {..., mult, ...}'.
+
+proc nodebug_runto {func} {
+ with_test_prefix $func {
+ if ![runto $func] {
+ return false
+ }
+ gdb_test_no_output "nosharedlibrary" \
+ "unload symbols from system libraries"
+ return true
+ }
+}
+
+# Test calling no-debug functions involving argument types that may
+# require coercion/promotion, both prototyped and unprototyped, both
+# return-type-cast style, and function-pointer-cast styles.
+proc test_call_promotion {} {
+ if [target_info exists gdb,cannot_call_functions] {
+ return
+ }
+
+ # Call prototyped function with float parameters via both
+ # return-type cast and function-pointer cast. This checks that
+ # GDB doesn't do float->double coercion.
+ gdb_test "p (float) multf(2.0f, 3.0f)" " = 6"
+ gdb_test "p ((float (*) (float, float)) multf)(2, 3)" " = 6"
+ gdb_test "p ((float (*) (float, float)) multf)(2.0f, 3.0f)" " = 6"
+
+ # Call unprototyped function with float parameters via
+ # function-pointer cast, only. return-type cast assumes
+ # protototyped. Check that GDB does float->double coercion.
+ gdb_test "p ((float (*) ()) multf_noproto)(2.0f, 3.0f)" " = 6"
+ gdb_test "p ((float (*) ()) multf_noproto)(2.0, 3.0)" " = 6"
+
+ # Same, but for double.
+ gdb_test "p (double) mult (2.0, 3.0)" " = 6"
+ gdb_test "p ((double (*) (double, double)) mult)(2.0f, 3.0f)" " = 6"
+ gdb_test "p ((double (*) (double, double)) mult)(2, 3)" " = 6"
+ gdb_test "p ((double (*) ()) mult_noproto)(2.0f, 3.0f)" " = 6"
+ gdb_test "p ((double (*) ()) mult_noproto)(2.0, 3.0)" " = 6"
+
+ # Check that GDB promotes char->int correctly.
+ gdb_test "p /d (uint8) add8((uint8) 2, (uint8) 3)" " = 5"
+ gdb_test "p /d ((uint8 (*) (uint8, uint8)) add8)((uint8) 2, (uint8) 3)" " = 5"
+ gdb_test "p /d ((uint8 (*) ()) add8_noproto)((uint8) 2, (uint8) 3)" " = 5"
+}
+
+if [nodebug_runto inner] then {
# Expect to find global/local symbols in each of text/data/bss.
@@ -59,22 +108,116 @@ if [runto inner] then {
# out debugging info for non-aggregate return values of functions
# even without -g, which should be accepted.
- gdb_test "p top" \
- "\{(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))\} \[0-9a-fx]* <\\.?top(\\(int\\)|)>"
- gdb_test "whatis top" \
- "(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))"
- gdb_test "ptype top" "(short|int) \\((|void|int|<non-float parameter>|<non-float parameter>, <non-float parameter>)\\)"
-
- gdb_test "p middle" \
- "\{(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))\} \[0-9a-fx]* <\\.?middle(\\(int\\)|)>"
- gdb_test "whatis middle" \
- "(<(text variable|function), no debug info>|short \\(int\\)|short \\(\\))"
- gdb_test "ptype middle" "(short|int) \\((|void|int|<non-float parameter>|<non-float parameter>, <non-float parameter>)\\)"
-
- gdb_test "p dataglobal" "= 3"
- gdb_test "whatis dataglobal" \
- "<(data variable|variable), no debug info>|int"
- gdb_test "ptype dataglobal" "<(data variable|variable), no debug info>|int"
+ with_test_prefix "func" {
+ # Most languages default to printing like C.
+ set c_print_re " = \\{<text variable, no debug info>\\} $hex <top>"
+ set c_whatis_re " = <text variable, no debug info>"
+ set c_ptype_re "= <unknown return type> \\(\\)"
+
+ set cxx_ptype_re "= <unknown return type> \\(void\\)"
+
+ set ada_ptype_re " = function return <unknown return type>"
+
+ set m2_print_re " = \\{PROCEDURE <text variable, no debug info> \\(\\) : <unknown return type>\\} $hex <top>"
+ set m2_whatis_re "PROCEDURE <text variable, no debug info> \\(\\) : <unknown return type>"
+ set m2_ptype_re $m2_whatis_re
+
+ # Rust can't access minsyms?
+ set rust_nosym "No symbol 'top' in current context"
+
+ set pascal_ptype_re "type = procedure : <unknown return type>"
+
+ #LANG #PRINT #WHATIS #PTYPE
+ foreach lang_line {
+ {"ada" $c_print_re $c_whatis_re $ada_ptype_re}
+ {"asm" $c_print_re $c_whatis_re $c_ptype_re}
+ {"c" $c_print_re $c_whatis_re $c_ptype_re}
+ {"c++" $c_print_re $c_whatis_re $cxx_ptype_re}
+ {"d" $c_print_re $c_whatis_re $c_ptype_re}
+ {"fortran" $c_print_re $c_whatis_re $c_ptype_re}
+ {"go" $c_print_re $c_whatis_re $c_ptype_re}
+ {"minimal" $c_print_re $c_whatis_re $c_ptype_re}
+ {"modula-2" $m2_print_re $m2_whatis_re $m2_ptype_re}
+ {"objective-c" $c_print_re $c_whatis_re $c_ptype_re}
+ {"opencl" $c_print_re $c_whatis_re $c_ptype_re}
+ {"pascal" $c_print_re $c_whatis_re $pascal_ptype_re}
+ {"rust" $rust_nosym $rust_nosym $rust_nosym}
+ } {
+ set lang [lindex $lang_line 0]
+ set print_re [lindex $lang_line 1]
+ set whatis_re [lindex $lang_line 2]
+ set ptype_re [lindex $lang_line 3]
+
+ set print_re [subst "$print_re"]
+ set whatis_re [subst "$whatis_re"]
+ set ptype_re [subst "$ptype_re"]
+
+ with_test_prefix "$lang" {
+ gdb_test_no_output "set language $lang"
+ gdb_test "p top" $print_re
+ gdb_test "whatis top" $whatis_re
+ gdb_test "ptype top" $ptype_re
+ }
+ }
+ }
+
+ gdb_test_no_output "set language auto"
+
+ # We can't rely on uintXX_t being available/known to GDB because
+ # we may or may not have debug info for those (depending on
+ # whether we have debug info for the C runtime, for example).
+ gdb_test_no_output "macro define uint8 unsigned char"
+ gdb_test_no_output "macro define uint32 unsigned int"
+ gdb_test_no_output "macro define uint64 unsigned long long"
+
+ set data_var_type "<data variable, no debug info>"
+ set unk_type_re "has unknown type.*to its declared type"
+ set ptr_math_re "Cannot perform pointer math on incomplete type \"$data_var_type\", try casting to a known type, or void \\*\\."
+ set not_mem_re "Attempt to take address of value not located in memory\\."
+
+ set dataglobal_unk_re "dataglobal.*$unk_type_re"
+
+ #exp #fmt #print #ptype/whatis
+ foreach line {
+ {"dataglobal" "" $dataglobal_unk_re " = $data_var_type"}
+ {"(int) dataglobal" "" "= 3" " = int"}
+ {"sizeof(dataglobal)" "" $dataglobal_unk_re $dataglobal_unk_re}
+ {"sizeof(dataglobal + 1)" "" $dataglobal_unk_re $dataglobal_unk_re}
+ {"sizeof((int) dataglobal)" "" " = $decimal" " = int"}
+ {"dataglobal + 1" "" $dataglobal_unk_re $dataglobal_unk_re}
+ {"&dataglobal" "" "\\($data_var_type \\*\\) $hex <dataglobal>" " = $data_var_type \\*"}
+ {"&dataglobal + 1" "" $ptr_math_re $ptr_math_re}
+ {"(int *) &dataglobal + 1" "" " = \\(int \\*\\) $hex <datalocal>" "int \\*"}
+ {"&(int) dataglobal + 1" "" $not_mem_re $not_mem_re}
+ {"&dataglobal, &dataglobal" "" "\\($data_var_type \\*\\) $hex <dataglobal>" " = $data_var_type \\*"}
+ {"*dataglobal" "" $dataglobal_unk_re $dataglobal_unk_re}
+
+ {"dataglobal8" "/x" $dataglobal_unk_re " = $data_var_type"}
+ {"(uint8) dataglobal8" "/x" " = 0xff" "unsigned char"}
+
+ {"dataglobal32_1" "/x" $dataglobal_unk_re " = $data_var_type"}
+ {"(uint32) dataglobal32_1" "/x" " = 0x7fffffff" "unsigned int"}
+ {"dataglobal32_2" "/x" $dataglobal_unk_re " = $data_var_type"}
+ {"(uint32) dataglobal32_2" "/x" " = 0xff" "unsigned int"}
+
+ {"dataglobal64_1" "/x" $dataglobal_unk_re " = $data_var_type"}
+ {"(uint64) dataglobal64_1" "/x" " = 0x7fffffffffffffff" "unsigned long long"}
+ {"dataglobal64_2" "/x" $dataglobal_unk_re " = $data_var_type"}
+ {"(uint64) dataglobal64_2" "/x" " = 0xff" "unsigned long long"}
+ } {
+ set exp [lindex $line 0]
+ # Expand variables.
+ set fmt [subst -nobackslashes [lindex $line 1]]
+ set print [subst -nobackslashes [lindex $line 2]]
+ set whatis [subst -nobackslashes [lindex $line 3]]
+ if {$fmt == ""} {
+ gdb_test "p $exp" $print
+ } else {
+ gdb_test "p $fmt $exp" $print
+ }
+ gdb_test "whatis $exp" $whatis
+ gdb_test "ptype $exp" $whatis
+ }
# The only symbol xcoff puts out for statics is for the TOC entry.
# Possible, but hairy, for gdb to deal. Right now it doesn't, it
@@ -82,35 +225,39 @@ if [runto inner] then {
setup_xfail "rs6000*-*-aix*"
setup_xfail "powerpc*-*-aix*"
- gdb_test "p datalocal" "= 4"
+ gdb_test "p datalocal" "datalocal.*$unk_type_re"
+ gdb_test "p (int) datalocal" "= 4"
setup_xfail "rs6000*-*-aix*"
setup_xfail "powerpc*-*-aix*"
- gdb_test "whatis datalocal" "<(data variable|variable), no debug info>"
+ gdb_test "whatis datalocal" "datalocal.*$data_var_type"
setup_xfail "rs6000*-*-aix*"
setup_xfail "powerpc*-*-aix*"
- gdb_test "ptype datalocal" "<(data variable|variable), no debug info>"
- gdb_test "p bssglobal" "= 0"
- gdb_test "whatis bssglobal" "<(data variable|variable), no debug info>|int"
- gdb_test "ptype bssglobal" "<(data variable|variable), no debug info>|int"
+ gdb_test "ptype datalocal" "datalocal.*$data_var_type"
+
+ gdb_test "p bssglobal" "bssglobal.*$unk_type_re"
+ gdb_test "p (int) bssglobal" "= 0"
+ gdb_test "whatis bssglobal" $data_var_type
+ gdb_test "ptype bssglobal" $data_var_type
setup_xfail "rs6000*-*-aix*"
setup_xfail "powerpc*-*-aix*"
- gdb_test "p bsslocal" "= 0"
+ gdb_test "p bsslocal" "bsslocal.*$unk_type_re"
+ gdb_test "p (int) bsslocal" "= 0"
setup_xfail "rs6000*-*-aix*"
setup_xfail "powerpc*-*-aix*"
- gdb_test "whatis bsslocal" "<(data variable|variable), no debug info>"
+ gdb_test "whatis bsslocal" $data_var_type
setup_xfail "rs6000*-*-aix*"
setup_xfail "powerpc*-*-aix*"
- gdb_test "ptype bsslocal" "<(data variable|variable), no debug info>"
+ gdb_test "ptype bsslocal" $data_var_type
gdb_test "backtrace 10" "#0.*inner.*#1.*middle.*#2.*top.*#3.*main.*" \
"backtrace from inner in nodebug.exp"
@@ -122,20 +269,26 @@ if [runto inner] then {
# This test is not as obscure as it might look. `p getenv ("TERM")'
# is a real-world example, at least on many systems.
+ foreach cmd {"p/c" "ptype" "whatis"} {
+ gdb_test "$cmd array_index(\"abcdef\",2)" \
+ "'array_index' has unknown return type; cast the call to its declared return type"
+ }
if [target_info exists gdb,cannot_call_functions] {
- unsupported "p/c array_index(\"abcdef\",2)"
+ unsupported "p/c (int) array_index(\"abcdef\",2)"
} else {
# We need to up this because this can be really slow on some boards.
# (malloc() is called as part of the test).
set prev_timeout $timeout
set timeout 60
- gdb_test {p/c array_index("abcdef",2)} " = 99 'c'"
+ gdb_test {p/c (int) array_index("abcdef",2)} " = 99 'c'"
set timeout $prev_timeout
}
-
+
+ test_call_promotion
+
# Now, try that we can give names of file-local symbols which happen
# to be unique, and have it still work
- if [runto middle] then {
+ if [nodebug_runto middle] then {
gdb_test "backtrace 10" "#0.*middle.*#1.*top.*#2.*main.*" \
"backtrace from middle in nodebug.exp"
}
diff --git a/gdb/testsuite/gdb.base/printcmds.exp b/gdb/testsuite/gdb.base/printcmds.exp
index 323ca73..9409c6a 100644
--- a/gdb/testsuite/gdb.base/printcmds.exp
+++ b/gdb/testsuite/gdb.base/printcmds.exp
@@ -155,6 +155,16 @@ proc test_float_rejected {} {
test_print_reject "p 1.1ll"
}
+# Regression test for PR gdb/21675
+proc test_radices {} {
+ gdb_test "print/o 16777211" " = 077777773"
+ gdb_test "print/d 1.5" " = 1"
+ gdb_test "print/u 1.5" " = 1"
+
+ gdb_test "print/u (char) -1" " = 255"
+ gdb_test "print/d (unsigned char) -1" " = -1"
+}
+
proc test_print_all_chars {} {
global gdb_prompt
@@ -981,3 +991,4 @@ test_printf
test_printf_with_dfp
test_print_symbol
test_repeat_bytes
+test_radices
diff --git a/gdb/testsuite/gdb.base/reread.exp b/gdb/testsuite/gdb.base/reread.exp
index cc0f577..4e611ce 100644
--- a/gdb/testsuite/gdb.base/reread.exp
+++ b/gdb/testsuite/gdb.base/reread.exp
@@ -15,111 +15,131 @@
set prototypes 1
-# build the first test case
+# Build programs in PIE mode, to reproduce PR 21555.
+foreach_with_prefix opts {
+ { "" "" }
+ { "-fPIE" "ldflags=-pie" } } {
-set testfile1 "reread1"
-set srcfile1 ${testfile1}.c
-# Cygwin needs $EXEEXT.
-set binfile1 [standard_output_file ${testfile1}$EXEEXT]
-
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {debug nowarnings}] != "" } {
- untested "failed to compile first testcase"
- return -1
-}
-
-# build the second test case
-
-set testfile2 "reread2"
-set srcfile2 ${testfile2}.c
-set binfile2 [standard_output_file ${testfile2}$EXEEXT]
-
-if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug nowarnings}] != ""
- && [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" executable {debug nowarnings additional_flags=-DNO_SECTIONS}] != ""} {
- untested "failed to compile second testcase"
- return -1
-}
-
-# Start with a fresh gdb.
-
-set testfile "reread"
-set binfile [standard_output_file ${testfile}$EXEEXT]
-
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-
-# Load the first executable.
-
-gdb_rename_execfile ${binfile1} ${binfile}
-gdb_load ${binfile}
-
-# Set a breakpoint at foo
-
-gdb_test "break foo" \
- "Breakpoint.*at.* file .*$srcfile1, line 14.*" \
- "breakpoint foo in first file"
-
-
-# Run, should see "Breakpoint 1, foo () at hello1.c:14"
-
-gdb_run_cmd
-gdb_test "" "Breakpoint.* foo .* at .*$srcfile1:14.*" "run to foo()"
-
-# Restore first executable to its original name, and move
-# second executable into its place. Ensure that the new
-# executable is at least a second newer than the old.
-
-gdb_rename_execfile ${binfile} ${binfile1}
-gdb_rename_execfile ${binfile2} ${binfile}
-gdb_test "shell sleep 1" ".*" ""
-gdb_touch_execfile ${binfile}
-
-# Run a second time; GDB should detect that the executable has changed
-# and reset the breakpoints correctly.
-# Should see "Breakpoint 1, foo () at reread2.c:9"
-
-set test "run to foo() second time"
-if [is_remote target] {
- unsupported $test
-} else {
- gdb_run_cmd
- gdb_test "" "Breakpoint.* foo .* at .*:9.*" $test
-}
-
-
-### Second pass: verify that GDB checks the executable file's
-### timestamp when the program is *restarted*, not just when it exits.
-
-if [is_remote target] {
- unsupported "second pass: GDB should check for changes before running"
-} else {
-
- # Put the older executable back in place.
- gdb_rename_execfile ${binfile} ${binfile2}
- gdb_rename_execfile ${binfile1} ${binfile}
-
- # Restart GDB entirely.
- clean_restart ${binfile}
-
- # Set a breakpoint on foo and run to it.
- gdb_test "break foo" \
- "Breakpoint.*at.* file .*$srcfile1, line 14.*" \
- "second pass: breakpoint foo in first file"
- gdb_run_cmd
- gdb_test "" "Breakpoint.* foo .* at .*$srcfile1:14.*" "second pass: run to foo()"
-
- # This time, let the program run to completion. If GDB checks the
- # executable file's timestamp now, it won't notice any change.
- gdb_continue_to_end "second pass"
-
- # Now move the newer executable into place, and re-run. GDB
- # should still notice that the executable file has changed,
- # and still re-set the breakpoint appropriately.
- gdb_rename_execfile ${binfile} ${binfile1}
- gdb_rename_execfile ${binfile2} ${binfile}
- gdb_run_cmd
- gdb_test "" "Breakpoint.* foo .* at .*:9.*" "second pass: run to foo() second time"
-}
+ # build the first test case
+ set testfile1 "reread1"
+ set srcfile1 ${testfile1}.c
+ # Cygwin needs $EXEEXT.
+ set binfile1 [standard_output_file ${testfile1}$EXEEXT]
+
+ set testfile1_opt [list debug nowarnings \
+ additional_flags=[lindex $opts 0] \
+ [lindex $opts 1] ]
+ if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" \
+ executable ${testfile1_opt}] != "" } {
+ untested "failed to compile first testcase"
+ return -1
+ }
+
+ # build the second test case
+
+ set testfile2 "reread2"
+ set srcfile2 ${testfile2}.c
+ set binfile2 [standard_output_file ${testfile2}$EXEEXT]
+
+ set testfile2_opt1 [list debug nowarnings \
+ additional_flags=[lindex $opts 0] \
+ [lindex $opts 1]]
+ set testfile2_op2 [list debug nowarnings \
+ "additional_flags=-DNO_SECTIONS [lindex $opts 0]" \
+ [lindex $opts 1]]
+ if { [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" \
+ executable ${testfile2_opt1}] != ""
+ && [gdb_compile "${srcdir}/${subdir}/${srcfile2}" "${binfile2}" \
+ executable ${testfile2_opt2}] != ""} {
+ untested "failed to compile second testcase"
+ return -1
+ }
+
+ # Start with a fresh gdb.
+
+ set testfile "reread"
+ set binfile [standard_output_file ${testfile}$EXEEXT]
+
+ gdb_start
+ gdb_reinitialize_dir $srcdir/$subdir
+
+ # Load the first executable.
+
+ gdb_rename_execfile ${binfile1} ${binfile}
+ gdb_load ${binfile}
+
+ # Set a breakpoint at foo
+
+ gdb_test "break foo" \
+ "Breakpoint.*at.* file .*$srcfile1, line 14.*" \
+ "breakpoint foo in first file"
+
+
+ # Run, should see "Breakpoint 1, foo () at hello1.c:14"
+
+ gdb_run_cmd
+ gdb_test "" "Breakpoint.* foo .* at .*$srcfile1:14.*" "run to foo()"
+
+ # Restore first executable to its original name, and move
+ # second executable into its place. Ensure that the new
+ # executable is at least a second newer than the old.
+
+ gdb_rename_execfile ${binfile} ${binfile1}
+ gdb_rename_execfile ${binfile2} ${binfile}
+ gdb_test "shell sleep 1" ".*" ""
+ gdb_touch_execfile ${binfile}
+
+ # Run a second time; GDB should detect that the executable has changed
+ # and reset the breakpoints correctly.
+ # Should see "Breakpoint 1, foo () at reread2.c:9"
+
+ set test "run to foo() second time"
+ if [is_remote target] {
+ unsupported $test
+ } else {
+ gdb_run_cmd
+ gdb_test "" "Breakpoint.* foo .* at .*:9.*" $test
+ }
+
+
+ ### Second pass: verify that GDB checks the executable file's
+ ### timestamp when the program is *restarted*, not just when it exits.
+
+ if [is_remote target] {
+ unsupported "second pass: GDB should check for changes before running"
+ } else {
+
+ # Put the older executable back in place.
+ gdb_rename_execfile ${binfile} ${binfile2}
+ gdb_rename_execfile ${binfile1} ${binfile}
+
+ # Restart GDB entirely.
+ clean_restart ${binfile}
+
+ # Set a breakpoint on foo and run to it.
+ gdb_test "break foo" \
+ "Breakpoint.*at.* file .*$srcfile1, line 14.*" \
+ "second pass: breakpoint foo in first file"
+ gdb_run_cmd
+ gdb_test "" "Breakpoint.* foo .* at .*$srcfile1:14.*" \
+ "second pass: run to foo()"
+
+ # This time, let the program run to completion. If GDB checks the
+ # executable file's timestamp now, it won't notice any change.
+ gdb_continue_to_end "second pass"
+
+ # Now move the newer executable into place, and re-run. GDB
+ # should still notice that the executable file has changed,
+ # and still re-set the breakpoint appropriately.
+ gdb_rename_execfile ${binfile} ${binfile1}
+ gdb_rename_execfile ${binfile2} ${binfile}
+ gdb_run_cmd
+ gdb_test "" "Breakpoint.* foo .* at .*:9.*" \
+ "second pass: run to foo() second time"
+ }
+
+ }
# End of tests.
return 0
diff --git a/gdb/testsuite/gdb.base/share-env-with-gdbserver.c b/gdb/testsuite/gdb.base/share-env-with-gdbserver.c
new file mode 100644
index 0000000..740bd0f
--- /dev/null
+++ b/gdb/testsuite/gdb.base/share-env-with-gdbserver.c
@@ -0,0 +1,40 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2017 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Wrapper around getenv for GDB. */
+
+static const char *
+my_getenv (const char *name)
+{
+ return getenv (name);
+}
+
+int
+main (int argc, char *argv[])
+{
+ const char *myvar = getenv ("GDB_TEST_VAR");
+
+ if (myvar != NULL)
+ printf ("It worked! myvar = '%s'\n", myvar);
+ else
+ printf ("It failed.");
+
+ return 0; /* break-here */
+}
diff --git a/gdb/testsuite/gdb.base/share-env-with-gdbserver.exp b/gdb/testsuite/gdb.base/share-env-with-gdbserver.exp
new file mode 100644
index 0000000..7521be1
--- /dev/null
+++ b/gdb/testsuite/gdb.base/share-env-with-gdbserver.exp
@@ -0,0 +1,255 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This test doesn't make sense on native-gdbserver.
+if { [use_gdb_stub] } {
+ untested "not supported"
+ return
+}
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" $testfile $srcfile debug] } {
+ return -1
+}
+
+set test_var_name "GDB_TEST_VAR"
+
+# Helper function that performs a check on the output of "getenv".
+#
+# - VAR_NAME is the name of the variable to be checked.
+#
+# - VAR_VALUE is the value expected.
+#
+# - TEST_MSG, if not empty, is the test message to be used by the
+# "gdb_test".
+#
+# - EMPTY_VAR_P, if non-zero, means that the variable is not expected
+# to exist. In this case, VAR_VALUE is not considered.
+
+proc check_getenv { var_name var_value { test_msg "" } { empty_var_p 0 } } {
+ global hex decimal
+
+ if { $test_msg == "" } {
+ set test_msg "print result of getenv for $var_name"
+ }
+
+ if { $empty_var_p } {
+ set var_value_match "0x0"
+ } else {
+ set var_value_match "$hex \"$var_value\""
+ }
+
+ gdb_test "print my_getenv (\"$var_name\")" "\\\$$decimal = $var_value_match" \
+ $test_msg
+}
+
+# Helper function to re-run to main and breaking at the "break-here"
+# label.
+
+proc do_prepare_inferior { } {
+ global decimal hex
+
+ if { ![runto_main] } {
+ return -1
+ }
+
+ gdb_breakpoint [gdb_get_line_number "break-here"]
+
+ gdb_test "continue" "Breakpoint $decimal, main \\\(argc=1, argv=$hex\\\) at.*" \
+ "continue until breakpoint"
+}
+
+# Helper function that does the actual testing.
+#
+# - VAR_VALUE is the value of the environment variable.
+#
+# - VAR_NAME is the name of the environment variable. If empty,
+# defaults to $test_var_name.
+#
+# - VAR_NAME_MATCH is the name (regex) that will be used to query the
+# environment about the variable (via getenv). This is useful when
+# we're testing variables with strange names (e.g., with an equal
+# sign in the name) and we know that the variable will actually be
+# set using another name. If empty, defatults, to $var_name.
+#
+# - VAR_VALUE_MATCH is the value (regex) that will be used to match
+# the result of getenv. The rationale is the same as explained for
+# VAR_NAME_MATCH. If empty, defaults, to $var_value.
+
+proc do_test { var_value { var_name "" } { var_name_match "" } { var_value_match "" } } {
+ global binfile test_var_name
+
+ clean_restart $binfile
+
+ if { $var_name == "" } {
+ set var_name $test_var_name
+ }
+
+ if { $var_name_match == "" } {
+ set var_name_match $var_name
+ }
+
+ if { $var_value_match == "" } {
+ set var_value_match $var_value
+ }
+
+ if { $var_value != "" } {
+ gdb_test_no_output "set environment $var_name = $var_value" \
+ "set $var_name = $var_value"
+ } else {
+ gdb_test "set environment $var_name =" \
+ "Setting environment variable \"$var_name\" to null value." \
+ "set $var_name to null value"
+ }
+
+ do_prepare_inferior
+
+ check_getenv "$var_name_match" "$var_value_match" \
+ "print result of getenv for $var_name"
+}
+
+with_test_prefix "long var value" {
+ do_test "this is my test variable; testing long vars; {}"
+}
+
+with_test_prefix "empty var" {
+ do_test ""
+}
+
+with_test_prefix "strange named var" {
+ # In this test we're doing the following:
+ #
+ # (gdb) set environment 'asd =' = 123 43; asd b ### [];;;
+ #
+ # However, due to how GDB parses this line, the environment
+ # variable will end up named <'asd> (without the <>), and its
+ # value will be <' = 123 43; asd b ### [];;;> (without the <>).
+ do_test "123 43; asd b ### \[\];;;" "'asd ='" "'asd" \
+ [string_to_regexp "' = 123 43; asd b ### \[\];;;"]
+}
+
+# Test setting and unsetting environment variables in various
+# fashions.
+
+proc test_set_unset_vars { } {
+ global binfile
+
+ clean_restart $binfile
+
+ with_test_prefix "set 3 environment variables" {
+ # Set some environment variables
+ gdb_test_no_output "set environment A = 1" \
+ "set A to 1"
+ gdb_test_no_output "set environment B = 2" \
+ "set B to 2"
+ gdb_test_no_output "set environment C = 3" \
+ "set C to 3"
+
+ do_prepare_inferior
+
+ # Check that the variables are known by the inferior
+ check_getenv "A" "1"
+ check_getenv "B" "2"
+ check_getenv "C" "3"
+ }
+
+ with_test_prefix "unset one variable, reset one" {
+ # Now, unset/reset some values
+ gdb_test_no_output "unset environment A" \
+ "unset A"
+ gdb_test_no_output "set environment B = 4" \
+ "set B to 4"
+
+ do_prepare_inferior
+
+ check_getenv "A" "" "" 1
+ check_getenv "B" "4"
+ check_getenv "C" "3"
+ }
+
+ with_test_prefix "unset two variables, reset one" {
+ # Unset more values
+ gdb_test_no_output "unset environment B" \
+ "unset B"
+ gdb_test_no_output "set environment A = 1" \
+ "set A to 1 again"
+ gdb_test_no_output "unset environment C" \
+ "unset C"
+
+ do_prepare_inferior
+
+ check_getenv "A" "1"
+ check_getenv "B" "" "" 1
+ check_getenv "C" "" "" 1
+ }
+}
+
+with_test_prefix "test set/unset of vars" {
+ test_set_unset_vars
+}
+
+# Test that unsetting works.
+
+proc test_unset { } {
+ global hex decimal binfile gdb_prompt
+
+ clean_restart $binfile
+
+ do_prepare_inferior
+
+ set test_msg "check if unset works"
+ set found_home 0
+ gdb_test_multiple "print my_getenv (\"HOME\")" $test_msg {
+ -re "\\\$$decimal = $hex \".*\"\r\n$gdb_prompt $" {
+ pass $test_msg
+ set found_home 1
+ }
+ -re "\\\$$decimal = 0x0\r\n$gdb_prompt $" {
+ untested $test_msg
+ }
+ }
+
+ if { $found_home == 1 } {
+ with_test_prefix "simple unset" {
+ # We can do the test, because $HOME exists (and therefore can
+ # be unset).
+ gdb_test_no_output "unset environment HOME" "unset HOME"
+
+ do_prepare_inferior
+
+ # $HOME now must be empty
+ check_getenv "HOME" "" "" 1
+ }
+
+ with_test_prefix "set-then-unset" {
+ clean_restart $binfile
+
+ # Test if setting and then unsetting $HOME works.
+ gdb_test_no_output "set environment HOME = test" "set HOME as test"
+ gdb_test_no_output "unset environment HOME" "unset HOME again"
+
+ do_prepare_inferior
+
+ check_getenv "HOME" "" "" 1
+ }
+ }
+}
+
+with_test_prefix "test unset of vars" {
+ test_unset
+}
diff --git a/gdb/testsuite/gdb.base/sizeof.exp b/gdb/testsuite/gdb.base/sizeof.exp
index d7ada65..13d36f8 100644
--- a/gdb/testsuite/gdb.base/sizeof.exp
+++ b/gdb/testsuite/gdb.base/sizeof.exp
@@ -81,12 +81,12 @@ check_sizeof "long double" ${sizeof_long_double}
proc check_valueof { exp val } {
gdb_test "next" "" ""
- gdb_test "p value" " = ${val}" "check valueof \"$exp\""
+ gdb_test "p /d value" " = ${val}" "check valueof \"$exp\""
}
# Check that GDB and the target agree over the sign of a character.
-set signof_byte [get_integer_valueof "'\\377'" -1]
+set signof_byte [get_integer_valueof "(int) '\\377'" -1]
set signof_char [get_integer_valueof "(int) (char) -1" -1]
set signof_signed_char [get_integer_valueof "(int) (signed char) -1" -1]
set signof_unsigned_char [get_integer_valueof "(int) (unsigned char) -1" -1]
diff --git a/gdb/testsuite/gdb.base/solib-display.exp b/gdb/testsuite/gdb.base/solib-display.exp
index 1e26853..6df9f26 100644
--- a/gdb/testsuite/gdb.base/solib-display.exp
+++ b/gdb/testsuite/gdb.base/solib-display.exp
@@ -94,9 +94,9 @@ foreach libsepdebug {NO IN SEP} { with_test_prefix "$libsepdebug" {
return 0
}
- gdb_test "display a_global" "1: a_global = 41"
- gdb_test "display b_global" "2: b_global = 42"
- gdb_test "display c_global" "3: c_global = 43"
+ gdb_test "display (int) a_global" "1: \\(int\\) a_global = 41"
+ gdb_test "display (int) b_global" "2: \\(int\\) b_global = 42"
+ gdb_test "display (int) c_global" "3: \\(int\\) c_global = 43"
if { [gdb_start_cmd] < 0 } {
fail "can't run to main (2)"
@@ -104,9 +104,9 @@ foreach libsepdebug {NO IN SEP} { with_test_prefix "$libsepdebug" {
}
gdb_test "" [multi_line \
- "1: a_global = 41" \
- "2: b_global = 42" \
- "3: c_global = 43" \
+ "1: \\(int\\) a_global = 41" \
+ "2: \\(int\\) b_global = 42" \
+ "3: \\(int\\) c_global = 43" \
] "after rerun"
# Now rebuild the library without b_global
@@ -132,9 +132,9 @@ foreach libsepdebug {NO IN SEP} { with_test_prefix "$libsepdebug" {
gdb_test "" [multi_line \
- "1: a_global = 41" \
+ "1: \\(int\\) a_global = 41" \
"warning: .*b_global.*" \
- "3: c_global = 43" \
+ "3: \\(int\\) c_global = 43" \
] "after rerun (2)"
# Now verify that displays which are not in the shared library
diff --git a/gdb/testsuite/gdb.base/starti.c b/gdb/testsuite/gdb.base/starti.c
new file mode 100644
index 0000000..f1f359d
--- /dev/null
+++ b/gdb/testsuite/gdb.base/starti.c
@@ -0,0 +1,30 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2017 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int x;
+
+__attribute__((constructor)) void
+ctor ()
+{
+ x = 1;
+}
+
+int
+main ()
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/starti.exp b/gdb/testsuite/gdb.base/starti.exp
new file mode 100644
index 0000000..98167ce
--- /dev/null
+++ b/gdb/testsuite/gdb.base/starti.exp
@@ -0,0 +1,51 @@
+# Copyright 2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+standard_testfile
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
+ return -1
+}
+
+# Define a stop hook that outputs the value of 'x'
+
+gdb_test_multiple "define hook-stop" "hook-stop" {
+ -re "Type commands for definition of \"hook-stop\".\r\nEnd with a line saying just \"end\".\r\n>$" {
+ gdb_test "print x\nend" "" "hook-stop"
+ }
+}
+
+if { [gdb_starti_cmd] < 0 } {
+ untested starti
+ return -1
+}
+
+# The program should stop at the first instruction, so the constructor
+# should not have run yet and 'x' should be 0.
+
+gdb_test_sequence "" "starti" {
+ "Program stopped."
+ "\\$1 = 0"
+}
+
+# Continue to the start of main(). The constructor should have run so
+# 'x' should be 1.
+
+gdb_breakpoint main
+gdb_test_sequence "continue" "" {
+ "\\$2 = 1"
+ ".*Breakpoint .*main \\(\\) at .*starti.c.*"
+}
diff --git a/gdb/testsuite/gdb.base/symbol-alias.c b/gdb/testsuite/gdb.base/symbol-alias.c
new file mode 100644
index 0000000..cc5d104
--- /dev/null
+++ b/gdb/testsuite/gdb.base/symbol-alias.c
@@ -0,0 +1,31 @@
+/* This test is part of GDB, the GNU debugger.
+
+ Copyright 2017 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+struct S
+{
+ int field1;
+ int field2;
+};
+
+extern struct S *func_alias (void);
+
+int
+main (void)
+{
+ struct S *s = func_alias ();
+ return s->field1 - s->field1;
+}
diff --git a/gdb/testsuite/gdb.base/symbol-alias.exp b/gdb/testsuite/gdb.base/symbol-alias.exp
new file mode 100644
index 0000000..dc63eb1
--- /dev/null
+++ b/gdb/testsuite/gdb.base/symbol-alias.exp
@@ -0,0 +1,37 @@
+# Test for printing alias symbols.
+# Copyright 2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+standard_testfile symbol-alias.c symbol-alias2.c
+
+if { [prepare_for_testing "failed to prepare" ${testfile} [list $srcfile $srcfile2]] } {
+ return -1
+}
+
+if ![runto_main] then {
+ fail "can't run to main"
+ continue
+}
+
+# Functions.
+foreach f {"func" "func_alias"} {
+ gdb_test "p $f" " = {struct S \\*\\(void\\)} $hex <func>"
+ gdb_test "p *${f}()" "= {field1 = 1, field2 = 2}"
+}
+
+# Variables.
+foreach v {"g_var_s" "g_var_s_alias"} {
+ gdb_test "p $v" "= {field1 = 1, field2 = 2}"
+}
diff --git a/gdb/testsuite/gdb.base/symbol-alias2.c b/gdb/testsuite/gdb.base/symbol-alias2.c
new file mode 100644
index 0000000..aedd520
--- /dev/null
+++ b/gdb/testsuite/gdb.base/symbol-alias2.c
@@ -0,0 +1,34 @@
+/* This test is part of GDB, the GNU debugger.
+
+ Copyright 2017 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+struct S
+{
+ int field1;
+ int field2;
+};
+
+struct S g_var_s = { 1, 2 };
+
+static struct S *
+func (void)
+{
+ return &g_var_s;
+}
+
+struct S *func_alias (void) __attribute__ ((alias ("func")));
+
+extern struct S g_var_s_alias __attribute__ ((alias ("g_var_s")));
diff --git a/gdb/testsuite/gdb.base/whatis-ptype-typedefs.c b/gdb/testsuite/gdb.base/whatis-ptype-typedefs.c
new file mode 100644
index 0000000..5711a96
--- /dev/null
+++ b/gdb/testsuite/gdb.base/whatis-ptype-typedefs.c
@@ -0,0 +1,143 @@
+/* This test program is part of GDB, the GNU debugger.
+
+ Copyright 2017 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Define typedefs of different types, for testing the "whatis" and
+ "ptype" commands. */
+
+/* Helper macro used to consistently define variables/typedefs using
+ the same name scheme. BASE is the shared part of the name of all
+ typedefs/variables generated. Defines a variable of the given
+ typedef type, and then a typedef of that typedef and a variable of
+ that new typedef type. The "double typedef" is useful to checking
+ that whatis only strips one typedef level. For example, if BASE is
+ "int", we get:
+
+ int_typedef v_int_typedef; // "v_" stands for variable of typedef type
+ typedef int_typedef int_typedef2; // typedef-of-typedef
+ int_typedef2 v_int_typedef2; // var of typedef-of-typedef
+*/
+#define DEF(base) \
+ base ## _typedef v_ ## base ## _typedef; \
+ \
+ typedef base ## _typedef base ## _typedef2; \
+ base ## _typedef2 v_ ## base ## _typedef2
+
+/* Void. */
+
+/* (Can't have variables of void type.) */
+
+typedef void void_typedef;
+typedef void_typedef void_typedef2;
+
+void_typedef *v_void_typedef_ptr;
+void_typedef2 *v_void_typedef_ptr2;
+
+/* Integers. */
+
+typedef int int_typedef;
+DEF (int);
+
+/* Floats. */
+
+typedef float float_typedef;
+DEF (float);
+
+/* Enums. */
+
+typedef enum colors {red, green, blue} colors_typedef;
+DEF (colors);
+
+/* Structures. */
+
+typedef struct t_struct
+{
+ int member;
+} t_struct_typedef;
+DEF (t_struct);
+
+/* Unions. */
+
+typedef union t_union
+{
+ int member;
+} t_union_typedef;
+DEF (t_union);
+
+/* Arrays. */
+
+typedef int int_array_typedef[3];
+DEF (int_array);
+
+/* An array the same size of t_struct_typedef, so we can test casting. */
+typedef unsigned char uchar_array_t_struct_typedef[sizeof (t_struct_typedef)];
+DEF (uchar_array_t_struct);
+
+/* A struct and a eunion the same size as t_struct, so we can test
+ casting. */
+
+typedef struct t_struct_wrapper
+{
+ struct t_struct base;
+} t_struct_wrapper_typedef;
+DEF (t_struct_wrapper);
+
+typedef union t_struct_union_wrapper
+{
+ struct t_struct base;
+} t_struct_union_wrapper_typedef;
+DEF (t_struct_union_wrapper);
+
+/* Functions / function pointers. */
+
+typedef void func_ftype (void);
+func_ftype *v_func_ftype;
+
+typedef func_ftype func_ftype2;
+func_ftype2 *v_func_ftype2;
+
+/* C++ methods / method pointers. */
+
+#ifdef __cplusplus
+
+namespace ns {
+
+struct Struct { void method (); };
+void Struct::method () {}
+
+typedef Struct Struct_typedef;
+DEF (Struct);
+
+/* Typedefs/vars in a namespace. */
+typedef void (Struct::*method_ptr_typedef) ();
+DEF (method_ptr);
+
+}
+
+/* Similar, but in the global namespace. */
+typedef ns::Struct ns_Struct_typedef;
+DEF (ns_Struct);
+
+typedef void (ns::Struct::*ns_method_ptr_typedef) ();
+DEF (ns_method_ptr);
+
+#endif
+
+int
+main (void)
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp b/gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp
new file mode 100644
index 0000000..d333d81
--- /dev/null
+++ b/gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp
@@ -0,0 +1,272 @@
+# Copyright 2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Test "whatis"/"ptype" of different typedef types, and of expressions
+# involving casts to/from different typedefs.
+#
+# Particularly, when "whatis" is given a type name directly, it should
+# strip one (and only one) typedef level. Otherwise, it should not
+# strip any typedef at all. GDB used to incorrectly strip typedefs of
+# expressions involving casts to typedef types. E.g., (gdb) print
+# (int_typedef)0" shall result in a value of type "int_typedef", not
+# "int".
+
+standard_testfile
+
+# Prepare for testing in language LANG. Lang can be "c" or "c++".
+
+proc prepare {lang} {
+ global srcfile testfile
+
+ if [target_info exists no_long_long] {
+ set options [list debug additional_flags=-DNO_LONG_LONG]
+ } else {
+ set options [list debug]
+ }
+
+ if {$lang == "c++"} {
+ lappend options c++
+ set out $testfile-cxx
+ } else {
+ set out $testfile-c
+ }
+
+ if { [prepare_for_testing "failed to prepare" \
+ ${out} [list $srcfile] $options] } {
+ return -1
+ }
+
+ if ![runto_main] then {
+ fail "can't run to main"
+ return 0
+ }
+}
+
+# The following list is layed out as a table. It is composed by
+# sub-lists (lines), with each line representing one whatis/ptype
+# test. The sub-list (line) elements (columns) are (in order):
+#
+# EXP - The user expression passed to whatis/ptype.
+#
+# WHATIS - What "whatis" should print.
+#
+# If the EXP column is a type name, then this will be the same type,
+# with one (and only one) typedef level removed. Otherwise, this is
+# the type of the expression on the first column, with all typedefs
+# preserved.
+#
+# PTYPE - What "ptype" should print.
+#
+# This is always the type of the input type/expression stripped from
+# all typedefs.
+#
+# LANGUAGE - If the line is language-specific, which language.
+#
+# This can be "c" or "c++".
+#
+# Columns in the table represent:
+ # EXP # whatis # ptype # language
+set table {
+ {"void_typedef" "void" "void"}
+ {"void_typedef2" "void_typedef" "void"}
+
+ {"int_typedef" "int" "int"}
+ {"int_typedef2" "int_typedef" "int"}
+ {"v_int_typedef" "int_typedef" "int"}
+ {"v_int_typedef2" "int_typedef2" "int"}
+
+ {"float_typedef" "float" "float"}
+ {"float_typedef2" "float_typedef" "float"}
+ {"v_float_typedef" "float_typedef" "float"}
+ {"v_float_typedef2" "float_typedef2" "float"}
+
+ {"colors_typedef" "(enum )?colors" "enum colors( : unsigned int)? {red, green, blue}"}
+ {"colors_typedef2" "colors_typedef" "enum colors( : unsigned int)? {red, green, blue}"}
+ {"v_colors_typedef" "colors_typedef" "enum colors( : unsigned int)? {red, green, blue}"}
+ {"v_colors_typedef2" "colors_typedef2" "enum colors( : unsigned int)? {red, green, blue}"}
+
+ {"func_ftype" "void \\(void\\)" "void \\(void\\)"}
+ {"func_ftype2" "func_ftype" "void \\(void\\)"}
+
+ {"func_ftype *" "func_ftype \\*" "void \\(\\*\\)\\(void\\)"}
+ {"func_ftype2 *" "func_ftype2 \\*" "void \\(\\*\\)\\(void\\)"}
+ {"v_func_ftype" "func_ftype \\*" "void \\(\\*\\)\\(void\\)"}
+ {"v_func_ftype2" "func_ftype2 \\*" "void \\(\\*\\)\\(void\\)"}
+
+ {"v_t_struct_typedef" "t_struct_typedef" "struct t_struct {.* member;.*}"}
+ {"v_t_struct_typedef2" "t_struct_typedef2" "struct t_struct {.* member;.*}"}
+ {"v_t_struct_union_wrapper_typedef" "t_struct_union_wrapper_typedef" "union t_struct_union_wrapper {.*base;.*}"}
+ {"v_t_struct_union_wrapper_typedef2" "t_struct_union_wrapper_typedef2" "union t_struct_union_wrapper {.*base;.*}"}
+ {"v_uchar_array_t_struct_typedef" "uchar_array_t_struct_typedef" "unsigned char \\[.*\\]"}
+ {"v_uchar_array_t_struct_typedef2" "uchar_array_t_struct_typedef2" "unsigned char \\[.*\\]"}
+
+ {"v_ns_Struct_typedef" "ns_Struct_typedef" "struct ns::Struct {.* method.*}" "c++"}
+
+ {"ns_method_ptr_typedef"
+ "void \\(ns::Struct::\\*\\)\\(ns::Struct \\* const\\)"
+ "void \\(ns::Struct::\\*\\)\\(ns::Struct \\* const\\)"
+ "c++"}
+
+ {"ns::method_ptr_typedef"
+ "void \\(ns::Struct::\\*\\)\\(ns::Struct \\* const\\)"
+ "void \\(ns::Struct::\\*\\)\\(ns::Struct \\* const\\)"
+ "c++"}
+
+ {"ns_method_ptr_typedef2"
+ "ns_method_ptr_typedef"
+ "void \\(ns::Struct::\\*\\)\\(ns::Struct \\* const\\)"
+ "c++"}
+
+ {"ns::method_ptr_typedef2"
+ "ns::method_ptr_typedef"
+ "void \\(ns::Struct::\\*\\)\\(ns::Struct \\* const\\)"
+ "c++"}
+
+ {"ns::Struct::method"
+ "void \\(ns::Struct \\* const\\)"
+ "void \\(ns::Struct \\* const\\)"
+ "c++"}
+}
+
+# The 4th column above is optional. If present, it indicates that the
+# line should only be tested in the specified language. This is a
+# helper function that checks whether LINE's language matches LANG.
+proc line_lang_match {line lang} {
+ if {[llength $line] <= 3} {
+ return true
+ }
+
+ set line_lang [lindex $line 3]
+ if {$line_lang == "" || $lang == $line_lang} {
+ return true
+ }
+
+ return false
+}
+
+# Run tests in language LANG.
+
+proc run_tests {lang} {
+ global table
+ global gdb_prompt
+
+ # Test passing all EXP in the list/table above to whatis/ptype,
+ # and check what comes out.
+ with_test_prefix "whatis/ptype" {
+ foreach line $table {
+ set type [lindex $line 0]
+ set whatis [lindex $line 1]
+ set ptype [lindex $line 2]
+
+ if {![line_lang_match $line $lang]} {
+ continue
+ }
+
+ # GCC doesn't record the target type of "typedef of
+ # typedef of void" types in the DWARF. See
+ # <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81267>.
+ # Handle that case manually in order to be able to xfail
+ # it.
+ if {$type == "void_typedef2"} {
+ set test "whatis $type"
+ gdb_test_multiple $test $test {
+ -re "type = void\r\n$gdb_prompt $" {
+ # gcc/81267.
+ setup_xfail "*-*-*"
+ fail "$test (void)"
+ }
+ -re "type = void_typedef\r\n$gdb_prompt $" {
+ pass $test
+ }
+ }
+ } else {
+ gdb_test "whatis $type" "type = $whatis"
+ }
+
+ gdb_test "ptype $type" "type = $ptype"
+ }
+ }
+
+ # Test converting/casting all variables in the first column of the
+ # table to all types (found in the first column of the table).
+ # The aggregates are all defined to be the same size so that
+ # casting actually works. (GDB's casting operator is more general
+ # than a C cast.)
+ #
+ # The main idea here is testing all the different paths in the
+ # value casting code in GDB (value_cast), making sure typedefs are
+ # preserved.
+ with_test_prefix "cast" {
+ foreach line1 $table {
+ set from [lindex $line1 0]
+
+ if {![line_lang_match $line1 $lang]} {
+ continue
+ }
+
+ foreach line2 $table {
+ set to [lindex $line2 0]
+ set whatis [lindex $line2 1]
+ set ptype [lindex $line2 2]
+
+ if {![line_lang_match $line2 $lang]} {
+ continue
+ }
+
+ # We try all combinations, even those that don't
+ # parse, or are invalid, to catch the case of a
+ # regression making them inadvertently valid. For
+ # example, these convertions are invalid:
+ #
+ # float <-> array
+ # array -> function (not function pointer)
+ # array -> member_ptr
+ #
+ # while these are invalid syntax:
+ #
+ # (anything) type
+ # (var) anything
+ # (method) anything [not method pointer]
+ # (float) method
+ #
+ if {([string match "v_*" $to]
+ || (![string match "v_*" $from] && ![string match "*method" $from])
+ || [string match "*method" $to])} {
+ gdb_test "whatis ($to) $from" "syntax error.*" "whatis ($to) $from (syntax)"
+ gdb_test "ptype ($to) $from" "syntax error.*" "ptype ($to) $from (syntax)"
+ } elseif {([string match "*float*" $from] && [string match "*array*" $to])
+ || ([string match "float*" $to] && [string match "*array*" $from])
+ || ([string match "float*" $to] && [string match "*method" $from])
+ || ([string match "*ftype" $to] && [string match "*array*" $from])
+ || ([string match "*ftype2" $to] && [string match "*array*" $from])
+ || ([string match "*ftype" $to] && [string match "*method" $from])
+ || ([string match "*ftype2" $to] && [string match "*method" $from])
+ || ([string match "*method_ptr*" $to] && [string match "*method" $from])
+ || ([string match "*method_ptr*" $to] && [string match "*array*" $from])} {
+ gdb_test "whatis ($to) $from" "Invalid cast." "whatis ($to) $from (invalid)"
+ gdb_test "ptype ($to) $from" "Invalid cast." "ptype ($to) $from (invalid)"
+ } else {
+ gdb_test "whatis ($to) $from" "type = [string_to_regexp $to]"
+ gdb_test "ptype ($to) $from" "type = $ptype"
+ }
+ }
+ }
+ }
+}
+
+foreach_with_prefix lang {"c" "c++"} {
+ prepare $lang
+ run_tests $lang
+}
diff --git a/gdb/testsuite/gdb.compile/compile-ifunc.exp b/gdb/testsuite/gdb.compile/compile-ifunc.exp
index dc442ff..b591939 100644
--- a/gdb/testsuite/gdb.compile/compile-ifunc.exp
+++ b/gdb/testsuite/gdb.compile/compile-ifunc.exp
@@ -36,9 +36,10 @@ with_test_prefix "nodebug" {
return -1
}
- gdb_test_no_output "compile code resultvar = gnu_ifunc (10);"
+ gdb_test "compile code resultvar = gnu_ifunc (10);" \
+ "warning: variable has unknown type; assuming int"
- gdb_test "p resultvar" " = 11"
+ gdb_test "p (int) resultvar" " = 11"
}
diff --git a/gdb/testsuite/gdb.compile/compile.exp b/gdb/testsuite/gdb.compile/compile.exp
index b221870..c23ff6a 100644
--- a/gdb/testsuite/gdb.compile/compile.exp
+++ b/gdb/testsuite/gdb.compile/compile.exp
@@ -296,12 +296,14 @@ gdb_test "p globalvar" " = 77" "expect 77"
# Test reference to minimal_symbol, not (full) symbol.
-gdb_test_no_output "compile code globalvar = func_nodebug (75);" \
+gdb_test "compile code globalvar = func_nodebug (75);" \
+ "warning: function has unknown return type; assuming int" \
"call func_nodebug"
gdb_test "p globalvar" " = -75" "expect -75"
-gdb_test_no_output \
- "compile code int (*funcp) (int) = func_nodebug; globalvar = funcp (76);" \
- "call func_nodebug indirectly"
+gdb_test \
+ "compile code int (*funcp) (int) = func_nodebug; globalvar = funcp (76);" \
+ "warning: function has unknown return type; assuming int" \
+ "call func_nodebug indirectly"
gdb_test "p globalvar" " = -76" "expect -76"
diff --git a/gdb/testsuite/gdb.cp/local-static.c b/gdb/testsuite/gdb.cp/local-static.c
new file mode 100644
index 0000000..0f4c4f0
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/local-static.c
@@ -0,0 +1,170 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2002-2017 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+struct aggregate
+{
+ int i1;
+ int i2;
+ int i3;
+};
+
+void keepalive_float (double *var) { }
+void keepalive_int (int *var) { }
+void keepalive_aggregate (struct aggregate *var) { }
+
+#define PREFIXIFY(PREFIX, VAR) \
+ PREFIX ## _ ## VAR
+
+#define DEF_STATICS(PREFIX) \
+ static int PREFIXIFY(PREFIX, s_var_int) = 4; \
+ static double PREFIXIFY(PREFIX, s_var_float) = 3.14f; \
+ static struct aggregate PREFIXIFY(PREFIX, s_var_aggregate) \
+ = { 1, 2, 3 }; \
+ \
+ keepalive_int (&PREFIXIFY(PREFIX, s_var_int)); \
+ keepalive_float (&PREFIXIFY(PREFIX, s_var_float)); \
+ keepalive_aggregate (&PREFIXIFY(PREFIX, s_var_aggregate));
+
+#ifdef __cplusplus
+
+struct S
+{
+ void inline_method ()
+ {
+ DEF_STATICS (S_IM);
+ }
+ static void static_inline_method ()
+ {
+ DEF_STATICS (S_SIM);
+ }
+
+ void method ();
+ void method () const;
+ void method () volatile;
+ void method () volatile const;
+
+ static void static_method ();
+};
+
+S s;
+const S c_s = {};
+volatile S v_s = {};
+const volatile S cv_s = {};
+
+void
+S::method ()
+{
+ DEF_STATICS (S_M);
+}
+
+void
+S::method () const
+{
+ DEF_STATICS (S_M_C);
+}
+
+void
+S::method () volatile
+{
+ DEF_STATICS (S_M_V);
+}
+
+void
+S::method () const volatile
+{
+ DEF_STATICS (S_M_CV);
+}
+
+void
+S::static_method ()
+{
+ DEF_STATICS (S_SM);
+}
+
+template <typename T>
+struct S2
+{
+ void method ();
+ static void static_method ();
+
+ void inline_method ()
+ {
+ DEF_STATICS (S2_IM);
+ }
+
+ static void static_inline_method ()
+ {
+ DEF_STATICS (S2_SIM);
+ }
+};
+
+template<typename T>
+void
+S2<T>::method ()
+{
+ DEF_STATICS (S2_M);
+}
+
+template<typename T>
+void
+S2<T>::static_method ()
+{
+ DEF_STATICS (S2_SM);
+}
+
+S2<int> s2;
+
+#endif
+
+void
+free_func (void)
+{
+ DEF_STATICS (FF);
+}
+
+static inline void
+free_inline_func (void)
+{
+ DEF_STATICS (FIF);
+}
+
+int
+main ()
+{
+ for (int i = 0; i < 1000; i++)
+ {
+ free_func ();
+ free_inline_func ();
+
+#ifdef __cplusplus
+ s.method ();
+ c_s.method ();
+ v_s.method ();
+ cv_s.method ();
+ s.inline_method ();
+ S::static_method ();
+ S::static_inline_method ();
+
+ s2.method ();
+ s2.inline_method ();
+ S2<int>::static_method ();
+ S2<int>::static_inline_method ();
+#endif
+ }
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.cp/local-static.cc b/gdb/testsuite/gdb.cp/local-static.cc
new file mode 100644
index 0000000..f2bffbe
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/local-static.cc
@@ -0,0 +1 @@
+#include "local-static.c"
diff --git a/gdb/testsuite/gdb.cp/local-static.exp b/gdb/testsuite/gdb.cp/local-static.exp
new file mode 100644
index 0000000..5e8eaaa
--- /dev/null
+++ b/gdb/testsuite/gdb.cp/local-static.exp
@@ -0,0 +1,241 @@
+# Copyright 2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Tests for function local static variables, both C and C++.
+
+# This file is part of the gdb testsuite.
+
+standard_testfile .c
+
+# A few expected errors.
+set syntax_re "A syntax error in expression, near.*"
+set cannot_resolve_re "Cannot resolve method S::method to any overloaded instance"
+
+# Build an "Cannot resolve method ..." expected error string for
+# method METH.
+#
+proc cannot_resolve {meth} {
+ return "Cannot resolve method $meth to any overloaded instance"
+}
+
+# A list of scopes that have the static variables that we want to
+# print. Each entry has, in order, the scope/function name, and the
+# prefix used by the static variables. The prefix exists both to make
+# it easier to debug the test if something goes wrong, and, to make
+# sure that printing the static local of one method overload doesn't
+# find the variables of the wrong overload.
+#
+# While at it, we also try printing each scope without the static
+# local, to check that the parse copes with cv overloads without
+# quoting. That's what the third and forth columns are for. Note
+# that printing "func()" is different from "func(void)". The former
+# is an inferior function call, while the latter is a reference to the
+# function.
+
+ #SCOPE #PREFIX #PRINT-SCOPE-QUOTED
+ #PRINT-SCOPE-UNQUOTED (opt)
+set cxx_scopes_list {
+ {"S::method()" "S_M" {= \\{void \\(S \\* const\\)\\} $hex <S::method\\(\\)>}
+ {[cannot_resolve "S::method"]}}
+
+ {"S::method() const" "S_M_C" {= \\{void \\(const S \\* const\\)\\} $hex <S::method\\(\\) const>}
+ $syntax_re}
+
+ {"S::method() volatile" "S_M_V" {= \\{void \\(volatile S \\* const\\)\\} $hex <S::method\\(\\) volatile>}
+ $syntax_re}
+
+ {"S::method() const volatile" "S_M_CV" {= \\{void \\(const volatile S \\* const\\)\\} $hex <S::method\\(\\) const volatile>}
+ $syntax_re}
+
+ {"S::method() volatile const" "S_M_CV" {= \\{void \\(const volatile S \\* const\\)\\} $hex <S::method\\(\\) const volatile>}
+ $syntax_re}
+
+ {"S::method(void)" "S_M" {= \\{void \\(S \\* const\\)\\} $hex <S::method\\(\\)>}}
+ {"S::method(void) const" "S_M_C" {= \\{void \\(const S \\* const\\)\\} $hex <S::method\\(\\) const>}}
+ {"S::method(void) volatile" "S_M_V" {= \\{void \\(volatile S \\* const\\)\\} $hex <S::method\\(\\) volatile>}}
+ {"S::method(void) const volatile" "S_M_CV" {= \\{void \\(const volatile S \\* const\\)\\} $hex <S::method\\(\\) const volatile>}}
+ {"S::method(void) volatile const" "S_M_CV" {= \\{void \\(const volatile S \\* const\\)\\} $hex <S::method\\(\\) const volatile>}}
+
+ {"S::static_method()" "S_SM" {= \\{void \\(void\\)\\} $hex <S::static_method\\(\\)>}
+ "void"}
+
+ {"S::static_method(void)" "S_SM" {= \\{void \\(void\\)\\} $hex <S::static_method\\(\\)>}}
+
+ {"S::inline_method()" "S_IM" {= \\{void \\(S \\* const\\)\\} $hex <S::inline_method\\(\\)>}
+ {[cannot_resolve "S::inline_method"]}}
+
+ {"S::inline_method(void)" "S_IM" {= \\{void \\(S \\* const\\)\\} $hex <S::inline_method\\(\\)>}}
+
+ {"S::static_inline_method()" "S_SIM" {= \\{void \\(void\\)\\} $hex <S::static_inline_method\\(\\)>}
+ "void"}
+
+ {"S::static_inline_method(void)" "S_SIM" {= \\{void \\(void\\)\\} $hex <S::static_inline_method\\(\\)>}}
+
+ {"S2<int>::method()" "S2_M" {= \\{void \\(S2<int> \\* const\\)\\} $hex <S2<int>::method\\(\\)>}
+ {[cannot_resolve "S2<int>::method"]}}
+
+ {"S2<int>::static_method()" "S2_SM" {= \\{void \\(void\\)\\} $hex <S2<int>::static_method\\(\\)>}
+ "void"}
+
+ {"S2<int>::inline_method()" "S2_IM" {= \\{void \\(S2<int> \\* const\\)\\} $hex <S2<int>::inline_method\\(\\)>}
+ {[cannot_resolve "S2<int>::inline_method"]}}
+
+ {"S2<int>::static_inline_method()" "S2_SIM" {= \\{void \\(void\\)\\} $hex <S2<int>::static_inline_method\\(\\)>}
+ "void"}
+
+ {"free_func" "FF" {= \\{void \\(void\\)\\} $hex <free_func\\(\\)>}}
+
+ {"free_func()" "FF" {= \\{void \\(void\\)\\} $hex <free_func\\(\\)>}
+ "void"}
+
+ {"free_func(void)" "FF" {= \\{void \\(void\\)\\} $hex <free_func\\(\\)>}}
+
+ {"free_inline_func()" "FIF" {= \\{void \\(void\\)\\} $hex <free_inline_func\\(\\)>}
+ "void"}
+
+ {"free_inline_func(void)" "FIF" {= \\{void \\(void\\)\\} $hex <free_inline_func\\(\\)>}}
+}
+
+set c_scopes_list {
+ {"free_func" "FF" {= \\{void \\(void\\)\\} $hex <free_func>}}
+ {"free_inline_func" "FIF" {= \\{void \\(void\\)\\} $hex <free_inline_func>}}
+}
+
+# A list of all the static varibles defined in each scope. The first
+# column is the name of the variable, without the prefix, and the
+# second column is a regex matching what printing the variable should
+# output.
+
+ #VAR #PRINT
+set vars_list {
+ {"s_var_int" " = 4"}
+ {"s_var_float" " = 3.14.*"}
+ {"s_var_aggregate" " = \\{i1 = 1, i2 = 2, i3 = 3\\}"}
+}
+
+proc do_test {lang} {
+ global c_scopes_list
+ global cxx_scopes_list
+ global vars_list
+ global srcfile testfile
+
+ set options {debug}
+
+ if {$lang == "c++"} {
+ if { [skip_cplus_tests] } {
+ return
+ }
+ lappend options $lang
+ set src ${srcfile}c
+ } else {
+ set src ${srcfile}
+ }
+
+ if {[prepare_for_testing "failed to prepare" $testfile-$lang \
+ [list $src] $options]} {
+ return -1
+ }
+
+ if ![runto_main] then {
+ fail "couldn't run to breakpoint"
+ return
+ }
+
+ gdb_test "show language" " currently [string_to_regexp $lang]\"\\."
+
+ if {$lang == "c"} {
+ set scopes_list $c_scopes_list
+ } else {
+ set scopes_list $cxx_scopes_list
+ }
+
+ # Print each scope/function using these syntaxes:
+ #
+ # "(gdb) p 'S::method() const'" # quoted
+ # "(gdb) p S::method() const" # unquoted
+ #
+ foreach scope_line $scopes_list {
+ set scope [lindex $scope_line 0]
+
+ set print_quoted_re [lindex $scope_line 2]
+ set print_quoted_re [uplevel 1 "subst -nobackslashes -nocommands \"$print_quoted_re\""]
+
+ set print_unquoted_re [lindex $scope_line 3]
+ set print_unquoted_re [uplevel 1 "subst -nobackslashes -nocommands \"$print_unquoted_re\""]
+
+ gdb_test "print '${scope}'" $print_quoted_re
+
+ if {$print_unquoted_re != ""} {
+ gdb_test "print ${scope}" $print_unquoted_re
+ } else {
+ gdb_test "print ${scope}" $print_quoted_re
+ }
+ }
+
+ # Print each variable using these syntaxes:
+ #
+ # 'func()'::var
+ # func()::var
+ # 'func()::var'
+ #
+ # In C++, the latter case makes sure that symbol lookup finds the
+ # debug symbol instead of the minimal symbol with that exact same
+ # name.
+
+ foreach scope_line $scopes_list {
+ set scope [lindex $scope_line 0]
+ set var_prefix [lindex $scope_line 1]
+ foreach var_line $vars_list {
+ set var [lindex $var_line 0]
+ set print_re [lindex $var_line 1]
+
+ gdb_test "print '${scope}'::${var_prefix}_${var}" $print_re
+ gdb_test "print ${scope}::${var_prefix}_${var}" $print_re
+
+ set sym "${scope}::${var_prefix}_${var}"
+ if {$lang == "c++"} {
+ gdb_test "print '${sym}'" $print_re
+ } else {
+ gdb_test "print '${sym}'" "No symbol \"$sym\" in current context\\."
+ }
+ }
+ }
+
+ # Now run to each function, and print its variables using the
+ # localy-visible name.
+ foreach scope_line $scopes_list {
+ set scope [lindex $scope_line 0]
+ set var_prefix [lindex $scope_line 1]
+
+ with_test_prefix "$scope" {
+ delete_breakpoints
+ gdb_breakpoint "$scope"
+ gdb_continue_to_breakpoint "$scope"
+
+ foreach var_line $vars_list {
+ set var [lindex $var_line 0]
+ set print_re [lindex $var_line 1]
+
+ gdb_test "print ${var_prefix}_${var}" $print_re
+ }
+ }
+ }
+}
+
+foreach lang {"c" "c++"} {
+ with_test_prefix $lang {
+ do_test $lang
+ }
+}
diff --git a/gdb/testsuite/gdb.cp/m-static.exp b/gdb/testsuite/gdb.cp/m-static.exp
index 52eea1a..10239a3 100644
--- a/gdb/testsuite/gdb.cp/m-static.exp
+++ b/gdb/testsuite/gdb.cp/m-static.exp
@@ -52,11 +52,6 @@ gdb_continue_to_breakpoint "end of constructors"
# One.
-# simple object, static const int, accessing via 'class::method::variable'
-# Regression test for PR c++/15203 and PR c++/15210
-gdb_test "print 'gnu_obj_1::method()::sintvar'" "\\$\[0-9\]+ = 4" \
- "simple object, static const int, accessing via 'class::method::variable"
-
# simple object, static const bool
gdb_test "print test1.test" "\\$\[0-9\]* = true" "simple object, static const bool"
diff --git a/gdb/testsuite/gdb.cp/overload.exp b/gdb/testsuite/gdb.cp/overload.exp
index 77a2505..3bf2a6a 100644
--- a/gdb/testsuite/gdb.cp/overload.exp
+++ b/gdb/testsuite/gdb.cp/overload.exp
@@ -263,10 +263,24 @@ gdb_test "print bar(d)" "= 22"
# List overloaded functions.
+gdb_test_no_output "set listsize 1" ""
+
+# Build source listing pattern based on an inclusive line range.
+
+proc line_range_pattern { range_start range_end } {
+ global line_re
+
+ for {set i $range_start} {$i <= $range_end} {incr i} {
+ append pattern "\r\n$i\[ \t\]\[^\r\n\]*"
+ }
+
+ verbose -log "pattern $pattern"
+ return $pattern
+}
+
# The void case is tricky because some compilers say "(void)"
# and some compilers say "()".
-gdb_test_no_output "set listsize 1" ""
gdb_test_multiple "info func overloadfnarg" "list overloaded function with no args" {
-re ".*overloadfnarg\\(void\\).*$gdb_prompt $" {
# gcc 2
@@ -324,6 +338,24 @@ gdb_test "print N::nsoverload ()" " = 1"
gdb_test "print N::nsoverload (2)" " = 2"
gdb_test "print N::nsoverload (2, 3)" " = 5"
+# Test "list function" when there are multiple "function" overloads.
+
+with_test_prefix "list all overloads" {
+ # Bump up listsize again, to make sure the number of lines to
+ # display before/after each location is computed correctly.
+ gdb_test_no_output "set listsize 10"
+
+ set line_bar_A [gdb_get_line_number "int bar (A)"]
+ set line_bar_B [gdb_get_line_number "int bar (B)"]
+ set lines1 [line_range_pattern [expr $line_bar_A - 5] [expr $line_bar_A + 4]]
+ set lines2 [line_range_pattern [expr $line_bar_B - 5] [expr $line_bar_B + 4]]
+
+ set any "\[^\r\n\]*"
+ set h1_re "file: \"${any}overload.cc\", line number: $line_bar_A, symbol: \"bar\\(A\\)\""
+ set h2_re "file: \"${any}overload.cc\", line number: $line_bar_B, symbol: \"bar\\(B\\)\""
+ gdb_test "list bar" "${h1_re}${lines1}\r\n${h2_re}${lines2}"
+}
+
if ![runto 'XXX::marker2'] then {
perror "couldn't run to XXX::marker2"
continue
diff --git a/gdb/testsuite/gdb.dlang/demangle.exp b/gdb/testsuite/gdb.dlang/demangle.exp
index baf6d6f..fcb353a 100644
--- a/gdb/testsuite/gdb.dlang/demangle.exp
+++ b/gdb/testsuite/gdb.dlang/demangle.exp
@@ -146,7 +146,7 @@ proc test_d_demangling {} {
test_demangling "_D8demangle4testFPFNdNfNaZaZv" "demangle.test(char() @property @safe pure function)"
test_demangling "_D8demangle4test6__vtblZ" "vtable for demangle.test"
- test_demangling "_D8demangle4test6__initZ" "demangle.test.init$"
+ test_demangling "_D8demangle4test6__initZ" "initializer for demangle.test"
test_demangling "_D8demangle4test12__ModuleInfoZ" "ModuleInfo for demangle.test"
test_demangling "_D8demangle4test7__ClassZ" "ClassInfo for demangle.test"
test_demangling "_D8demangle4test11__InterfaceZ" "Interface for demangle.test"
diff --git a/gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.exp b/gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.exp
index 458809b..6338e6d 100644
--- a/gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.exp
+++ b/gdb/testsuite/gdb.dwarf2/dw2-skip-prologue.exp
@@ -79,4 +79,4 @@ gdb_continue_to_breakpoint "func"
# Sanity check GDB has really found 2 locations
gdb_test {info break $bpnum} "\r\n2\\.1\[ \t\]\[^\n\]*\r\n2\\.2\[ \t\]\[^\n\]*" "2 locations found"
-gdb_test "p v" " = 0" "no statement got executed"
+gdb_test "p (int) v" " = 0" "no statement got executed"
diff --git a/gdb/testsuite/gdb.dwarf2/fission-multi-cu.S b/gdb/testsuite/gdb.dwarf2/fission-multi-cu.S
new file mode 100644
index 0000000..d09a7e5
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/fission-multi-cu.S
@@ -0,0 +1,374 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2012-2017 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ This file was created by doing:
+
+ clang fission-multi-cu*.c -g -fno-split-dwarf-inlining -emit-llvm -S -c
+ llvm-link fission-multi-cu*.ll -S -o fission-multi-cu.ll
+ clang-tot fission-multi-cu.ll -gsplit-dwarf -S
+
+ and then massaging the output.
+*/
+ .text
+ .file "llvm-link"
+ .globl func
+ .p2align 4, 0x90
+ .type func,@function
+func: # @func
+.Lfunc_begin0:
+ .file 1 "fission-multi-cu1.c"
+ .loc 1 20 0 # fission-multi-cu1.c:20:0
+ .cfi_startproc
+# BB#0: # %entry
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset %rbp, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register %rbp
+ movl %edi, -4(%rbp)
+ .loc 1 21 10 prologue_end # fission-multi-cu1.c:21:10
+ movl -4(%rbp), %edi
+ .loc 1 21 14 is_stmt 0 # fission-multi-cu1.c:21:14
+ addl $1, %edi
+ .loc 1 21 3 # fission-multi-cu1.c:21:3
+ movl %edi, %eax
+ popq %rbp
+ retq
+.Lfunc_end0:
+ .size func, .Lfunc_end0-func
+ .cfi_endproc
+
+ .globl main
+ .p2align 4, 0x90
+ .type main,@function
+main: # @main
+.Lfunc_begin1:
+ .file 2 "fission-multi-cu2.c"
+ .loc 2 23 0 is_stmt 1 # fission-multi-cu2.c:23:0
+ .cfi_startproc
+# BB#0: # %entry
+ pushq %rbp
+ .cfi_def_cfa_offset 16
+ .cfi_offset %rbp, -16
+ movq %rsp, %rbp
+ .cfi_def_cfa_register %rbp
+ movl $4294967295, %edi # imm = 0xFFFFFFFF
+ .loc 2 24 3 prologue_end # fission-multi-cu2.c:24:3
+ movb $0, %al
+ callq func
+ xorl %eax, %eax
+ .loc 2 25 1 # fission-multi-cu2.c:25:1
+ popq %rbp
+ retq
+.Lfunc_end1:
+ .size main, .Lfunc_end1-main
+ .cfi_endproc
+
+ .section .debug_str,"MS",@progbits,1
+.Lskel_string0:
+ .asciz "fission-multi-cu.dwo" # string offset=0
+.Lskel_string1:
+ .asciz "/tmp/src/gdb/testsuite" # string offset=21
+ .section .debug_loc.dwo,"",@progbits
+ .section .debug_abbrev,"",@progbits
+ .byte 1 # Abbreviation Code
+ .byte 17 # DW_TAG_compile_unit
+ .byte 0 # DW_CHILDREN_no
+ .byte 16 # DW_AT_stmt_list
+ .byte 23 # DW_FORM_sec_offset
+ .ascii "\260B" # DW_AT_GNU_dwo_name
+ .byte 14 # DW_FORM_strp
+ .byte 27 # DW_AT_comp_dir
+ .byte 14 # DW_FORM_strp
+ .ascii "\261B" # DW_AT_GNU_dwo_id
+ .byte 7 # DW_FORM_data8
+ .ascii "\263B" # DW_AT_GNU_addr_base
+ .byte 23 # DW_FORM_sec_offset
+ .byte 17 # DW_AT_low_pc
+ .byte 1 # DW_FORM_addr
+ .byte 18 # DW_AT_high_pc
+ .byte 6 # DW_FORM_data4
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 0 # EOM(3)
+ .section .debug_info,"",@progbits
+.Lcu_begin0:
+ .long 44 # Length of Unit
+ .short 4 # DWARF version number
+ .long .debug_abbrev # Offset Into Abbrev. Section
+ .byte 8 # Address Size (in bytes)
+ .byte 1 # Abbrev [1] 0xb:0x25 DW_TAG_compile_unit
+ .long .Lline_table_start0 # DW_AT_stmt_list
+ .long .Lskel_string0 # DW_AT_GNU_dwo_name
+ .long .Lskel_string1 # DW_AT_comp_dir
+ .quad 7615852067747431413 # DW_AT_GNU_dwo_id
+ .long .debug_addr # DW_AT_GNU_addr_base
+ .quad .Lfunc_begin0 # DW_AT_low_pc
+ .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
+.Lcu_begin1:
+ .long 44 # Length of Unit
+ .short 4 # DWARF version number
+ .long .debug_abbrev # Offset Into Abbrev. Section
+ .byte 8 # Address Size (in bytes)
+ .byte 1 # Abbrev [1] 0xb:0x25 DW_TAG_compile_unit
+ .long .Lline_table_start0 # DW_AT_stmt_list
+ .long .Lskel_string0 # DW_AT_GNU_dwo_name
+ .long .Lskel_string1 # DW_AT_comp_dir
+ .quad 2037650261599692324 # DW_AT_GNU_dwo_id
+ .long .debug_addr # DW_AT_GNU_addr_base
+ .quad .Lfunc_begin1 # DW_AT_low_pc
+ .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc
+ .section .debug_ranges,"",@progbits
+ .section .debug_macinfo,"",@progbits
+.Lcu_macro_begin1:
+.Lcu_macro_begin3:
+ .byte 0 # End Of Macro List Mark
+ .section .debug_str.dwo,"MS",@progbits,1
+.Linfo_string0:
+ .asciz "fission-multi-cu.dwo" # string offset=0
+.Linfo_string1:
+ .asciz "clang version 5.0.0 (trunk 302855) (llvm/trunk 302853)" # string offset=21
+.Linfo_string2:
+ .asciz "fission-multi-cu1.c" # string offset=76
+.Linfo_string3:
+ .asciz "fission-multi-cu2.c" # string offset=96
+.Linfo_string4:
+ .asciz "func" # string offset=116
+.Linfo_string5:
+ .asciz "int" # string offset=121
+.Linfo_string6:
+ .asciz "main" # string offset=125
+.Linfo_string7:
+ .asciz "arg" # string offset=130
+ .section .debug_str_offsets.dwo,"",@progbits
+ .long 0
+ .long 21
+ .long 76
+ .long 96
+ .long 116
+ .long 121
+ .long 125
+ .long 130
+ .section .debug_info.dwo,"",@progbits
+ .long 53 # Length of Unit
+ .short 4 # DWARF version number
+ .long 0 # Offset Into Abbrev. Section
+ .byte 8 # Address Size (in bytes)
+ .byte 1 # Abbrev [1] 0xb:0x2e DW_TAG_compile_unit
+ .byte 0 # DW_AT_GNU_dwo_name
+ .byte 1 # DW_AT_producer
+ .short 12 # DW_AT_language
+ .byte 2 # DW_AT_name
+ .quad 7615852067747431413 # DW_AT_GNU_dwo_id
+ .byte 2 # Abbrev [2] 0x19:0x1b DW_TAG_subprogram
+ .byte 0 # DW_AT_low_pc
+ .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
+ .byte 1 # DW_AT_frame_base
+ .byte 86
+ .byte 4 # DW_AT_name
+ .byte 1 # DW_AT_decl_file
+ .byte 19 # DW_AT_decl_line
+ # DW_AT_prototyped
+ .long 52 # DW_AT_type
+ # DW_AT_external
+ .byte 3 # Abbrev [3] 0x28:0xb DW_TAG_formal_parameter
+ .byte 2 # DW_AT_location
+ .byte 145
+ .byte 124
+ .byte 7 # DW_AT_name
+ .byte 1 # DW_AT_decl_file
+ .byte 19 # DW_AT_decl_line
+ .long 52 # DW_AT_type
+ .byte 0 # End Of Children Mark
+ .byte 4 # Abbrev [4] 0x34:0x4 DW_TAG_base_type
+ .byte 5 # DW_AT_name
+ .byte 5 # DW_AT_encoding
+ .byte 4 # DW_AT_byte_size
+ .byte 0 # End Of Children Mark
+ .long 41 # Length of Unit
+ .short 4 # DWARF version number
+ .long 0 # Offset Into Abbrev. Section
+ .byte 8 # Address Size (in bytes)
+ .byte 1 # Abbrev [1] 0xb:0x22 DW_TAG_compile_unit
+ .byte 0 # DW_AT_GNU_dwo_name
+ .byte 1 # DW_AT_producer
+ .short 12 # DW_AT_language
+ .byte 3 # DW_AT_name
+ .quad 2037650261599692324 # DW_AT_GNU_dwo_id
+ .byte 5 # Abbrev [5] 0x19:0xf DW_TAG_subprogram
+ .byte 1 # DW_AT_low_pc
+ .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc
+ .byte 1 # DW_AT_frame_base
+ .byte 86
+ .byte 6 # DW_AT_name
+ .byte 2 # DW_AT_decl_file
+ .byte 22 # DW_AT_decl_line
+ .long 40 # DW_AT_type
+ # DW_AT_external
+ .byte 4 # Abbrev [4] 0x28:0x4 DW_TAG_base_type
+ .byte 5 # DW_AT_name
+ .byte 5 # DW_AT_encoding
+ .byte 4 # DW_AT_byte_size
+ .byte 0 # End Of Children Mark
+ .section .debug_abbrev.dwo,"",@progbits
+ .byte 1 # Abbreviation Code
+ .byte 17 # DW_TAG_compile_unit
+ .byte 1 # DW_CHILDREN_yes
+ .ascii "\260B" # DW_AT_GNU_dwo_name
+ .ascii "\202>" # DW_FORM_GNU_str_index
+ .byte 37 # DW_AT_producer
+ .ascii "\202>" # DW_FORM_GNU_str_index
+ .byte 19 # DW_AT_language
+ .byte 5 # DW_FORM_data2
+ .byte 3 # DW_AT_name
+ .ascii "\202>" # DW_FORM_GNU_str_index
+ .ascii "\261B" # DW_AT_GNU_dwo_id
+ .byte 7 # DW_FORM_data8
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 2 # Abbreviation Code
+ .byte 46 # DW_TAG_subprogram
+ .byte 1 # DW_CHILDREN_yes
+ .byte 17 # DW_AT_low_pc
+ .ascii "\201>" # DW_FORM_GNU_addr_index
+ .byte 18 # DW_AT_high_pc
+ .byte 6 # DW_FORM_data4
+ .byte 64 # DW_AT_frame_base
+ .byte 24 # DW_FORM_exprloc
+ .byte 3 # DW_AT_name
+ .ascii "\202>" # DW_FORM_GNU_str_index
+ .byte 58 # DW_AT_decl_file
+ .byte 11 # DW_FORM_data1
+ .byte 59 # DW_AT_decl_line
+ .byte 11 # DW_FORM_data1
+ .byte 39 # DW_AT_prototyped
+ .byte 25 # DW_FORM_flag_present
+ .byte 73 # DW_AT_type
+ .byte 19 # DW_FORM_ref4
+ .byte 63 # DW_AT_external
+ .byte 25 # DW_FORM_flag_present
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 3 # Abbreviation Code
+ .byte 5 # DW_TAG_formal_parameter
+ .byte 0 # DW_CHILDREN_no
+ .byte 2 # DW_AT_location
+ .byte 24 # DW_FORM_exprloc
+ .byte 3 # DW_AT_name
+ .ascii "\202>" # DW_FORM_GNU_str_index
+ .byte 58 # DW_AT_decl_file
+ .byte 11 # DW_FORM_data1
+ .byte 59 # DW_AT_decl_line
+ .byte 11 # DW_FORM_data1
+ .byte 73 # DW_AT_type
+ .byte 19 # DW_FORM_ref4
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 4 # Abbreviation Code
+ .byte 36 # DW_TAG_base_type
+ .byte 0 # DW_CHILDREN_no
+ .byte 3 # DW_AT_name
+ .ascii "\202>" # DW_FORM_GNU_str_index
+ .byte 62 # DW_AT_encoding
+ .byte 11 # DW_FORM_data1
+ .byte 11 # DW_AT_byte_size
+ .byte 11 # DW_FORM_data1
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 5 # Abbreviation Code
+ .byte 46 # DW_TAG_subprogram
+ .byte 0 # DW_CHILDREN_no
+ .byte 17 # DW_AT_low_pc
+ .ascii "\201>" # DW_FORM_GNU_addr_index
+ .byte 18 # DW_AT_high_pc
+ .byte 6 # DW_FORM_data4
+ .byte 64 # DW_AT_frame_base
+ .byte 24 # DW_FORM_exprloc
+ .byte 3 # DW_AT_name
+ .ascii "\202>" # DW_FORM_GNU_str_index
+ .byte 58 # DW_AT_decl_file
+ .byte 11 # DW_FORM_data1
+ .byte 59 # DW_AT_decl_line
+ .byte 11 # DW_FORM_data1
+ .byte 73 # DW_AT_type
+ .byte 19 # DW_FORM_ref4
+ .byte 63 # DW_AT_external
+ .byte 25 # DW_FORM_flag_present
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 0 # EOM(3)
+ .section .debug_line.dwo,"",@progbits
+.Ltmp4:
+ .long (.Ltmp5-.Ltmp4)-4
+ .short 2
+ .long (.Ltmp6-.Ltmp4)-10
+ .byte 1
+ .byte 1
+ .byte -5
+ .byte 14
+ .byte 1
+ .byte 0
+ .byte 0
+.Ltmp6:
+.Ltmp5:
+ .section .debug_addr,"",@progbits
+ .quad .Lfunc_begin0
+ .quad .Lfunc_begin1
+ .section .debug_pubnames,"",@progbits
+ .long .LpubNames_end0-.LpubNames_begin0 # Length of Public Names Info
+.LpubNames_begin0:
+ .short 2 # DWARF Version
+ .long .Lcu_begin0 # Offset of Compilation Unit Info
+ .long 48 # Compilation Unit Length
+ .long 25 # DIE offset
+ .asciz "func" # External Name
+ .long 0 # End Mark
+.LpubNames_end0:
+ .long .LpubNames_end1-.LpubNames_begin1 # Length of Public Names Info
+.LpubNames_begin1:
+ .short 2 # DWARF Version
+ .long .Lcu_begin1 # Offset of Compilation Unit Info
+ .long 48 # Compilation Unit Length
+ .long 25 # DIE offset
+ .asciz "main" # External Name
+ .long 0 # End Mark
+.LpubNames_end1:
+ .section .debug_pubtypes,"",@progbits
+ .long .LpubTypes_end0-.LpubTypes_begin0 # Length of Public Types Info
+.LpubTypes_begin0:
+ .short 2 # DWARF Version
+ .long .Lcu_begin0 # Offset of Compilation Unit Info
+ .long 48 # Compilation Unit Length
+ .long 52 # DIE offset
+ .asciz "int" # External Name
+ .long 0 # End Mark
+.LpubTypes_end0:
+ .long .LpubTypes_end1-.LpubTypes_begin1 # Length of Public Types Info
+.LpubTypes_begin1:
+ .short 2 # DWARF Version
+ .long .Lcu_begin1 # Offset of Compilation Unit Info
+ .long 48 # Compilation Unit Length
+ .long 40 # DIE offset
+ .asciz "int" # External Name
+ .long 0 # End Mark
+.LpubTypes_end1:
+
+ .ident "clang version 5.0.0 (trunk 302855) (llvm/trunk 302853)"
+ .ident "clang version 5.0.0 (trunk 302855) (llvm/trunk 302853)"
+ .section ".note.GNU-stack","",@progbits
+ .section .debug_line,"",@progbits
+.Lline_table_start0:
diff --git a/gdb/testsuite/gdb.dwarf2/fission-multi-cu.exp b/gdb/testsuite/gdb.dwarf2/fission-multi-cu.exp
new file mode 100644
index 0000000..1f23c5b6
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/fission-multi-cu.exp
@@ -0,0 +1,67 @@
+# Copyright 2012-2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+load_lib dwarf.exp
+
+# We run objcopy locally to split out the .dwo file.
+if [is_remote host] {
+ return 0
+}
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+if ![dwarf2_support] {
+ return 0
+}
+
+# This test can only be run on x86-64 targets.
+if {![istarget x86_64-*] || ![is_lp64_target]} {
+ return 0
+}
+
+standard_testfile .S
+
+if [build_executable_from_fission_assembler \
+ "$testfile.exp" "$binfile" "$srcfile" {nodebug}] {
+ return -1
+}
+
+gdb_exit
+gdb_start
+gdb_reinitialize_dir $srcdir/$subdir
+# Make sure we can find the .dwo file, regardless of whether we're
+# running in parallel mode.
+gdb_test_no_output "set debug-file-directory [file dirname $binfile]" \
+ "set debug-file-directory"
+gdb_load $binfile
+
+if ![runto_main] {
+ return -1
+}
+
+# Do a few basic things to verify we're finding the DWO debug info.
+
+gdb_test "ptype main" "type = int \\(\\)"
+gdb_test "ptype func" "type = int \\(int\\)"
+
+gdb_test "frame" "#0 *main \\(\\) at ${testfile}2\\.c:$decimal.*" \
+ "frame in main"
+
+gdb_test "break func" "Breakpoint.*at.* file .*${testfile}1\\.c, line .*"
+
+gdb_test "continue" "Breakpoint.* func \\(arg=-1\\).*" \
+ "continue to func"
+
+gdb_test "frame" "#0 *func \\(arg=-1\\) at ${testfile}1\\.c:$decimal.*" \
+ "frame in func"
diff --git a/gdb/testsuite/gdb.dwarf2/fission-multi-cu1.c b/gdb/testsuite/gdb.dwarf2/fission-multi-cu1.c
new file mode 100644
index 0000000..d93e2f9
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/fission-multi-cu1.c
@@ -0,0 +1,22 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2012-2017 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+int
+func (int arg)
+{
+ return arg + 1;
+}
diff --git a/gdb/testsuite/gdb.dwarf2/fission-multi-cu2.c b/gdb/testsuite/gdb.dwarf2/fission-multi-cu2.c
new file mode 100644
index 0000000..053b3ea
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/fission-multi-cu2.c
@@ -0,0 +1,24 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2012-2017 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+void func ();
+
+int
+main ()
+{
+ func (-1);
+}
diff --git a/gdb/testsuite/gdb.dwarf2/shortpiece.exp b/gdb/testsuite/gdb.dwarf2/shortpiece.exp
new file mode 100644
index 0000000..8526a70
--- /dev/null
+++ b/gdb/testsuite/gdb.dwarf2/shortpiece.exp
@@ -0,0 +1,100 @@
+# Copyright 2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+load_lib dwarf.exp
+
+# This test can only be run on targets which support DWARF-2 and use gas.
+if {![dwarf2_support]} {
+ return 0
+}
+
+standard_testfile main.c shortpiece-dw.S
+
+# Make some DWARF for the test.
+set asm_file [standard_output_file $srcfile2]
+Dwarf::assemble $asm_file {
+ global pair
+
+ cu { addr_size 4 } {
+ compile_unit {} {
+ declare_labels int_label ushort_label struct_label
+
+ int_label: DW_TAG_base_type {
+ {DW_AT_byte_size 4 DW_FORM_udata}
+ {DW_AT_encoding @DW_ATE_unsigned}
+ {DW_AT_name "myint"}
+ }
+ ushort_label: DW_TAG_base_type {
+ {DW_AT_byte_size 2 DW_FORM_udata}
+ {DW_AT_encoding @DW_ATE_unsigned}
+ {DW_AT_name "myushort"}
+ }
+
+ struct_label: DW_TAG_structure_type {
+ {DW_AT_name "S"}
+ {DW_AT_byte_size 8 DW_FORM_udata}
+ } {
+ DW_TAG_member {
+ {DW_AT_name "a"}
+ {DW_AT_type :${int_label}}
+ {DW_AT_data_member_location 0 DW_FORM_udata}
+ }
+
+ DW_TAG_member {
+ {DW_AT_name "b"}
+ {DW_AT_type :${ushort_label}}
+ {DW_AT_data_member_location 4 DW_FORM_udata}
+ }
+ }
+
+ DW_TAG_variable {
+ {DW_AT_name "s1"}
+ {DW_AT_type :${struct_label}}
+ {DW_AT_external 1 DW_FORM_flag}
+ {DW_AT_location {
+ DW_OP_constu 1
+ DW_OP_stack_value
+ DW_OP_piece 4
+ DW_OP_constu 0
+ DW_OP_stack_value
+ DW_OP_piece 2
+ } SPECIAL_expr}
+ }
+
+ DW_TAG_variable {
+ {DW_AT_name "s2"}
+ {DW_AT_type :${struct_label}}
+ {DW_AT_external 1 DW_FORM_flag}
+ {DW_AT_location {
+ DW_OP_constu 1
+ DW_OP_stack_value
+ DW_OP_piece 4
+ DW_OP_constu 0
+ DW_OP_stack_value
+ DW_OP_piece 8
+ } SPECIAL_expr}
+ }
+ }
+ }
+}
+
+if { [prepare_for_testing "failed to prepare" ${testfile} \
+ [list $srcfile $asm_file] {nodebug}] } {
+ return -1
+}
+
+gdb_test "p s1" " = {a = 1, b = 0}"
+gdb_test "p s2" \
+ "access outside bounds of object referenced via synthetic pointer"
diff --git a/gdb/testsuite/gdb.dwarf2/var-access.exp b/gdb/testsuite/gdb.dwarf2/var-access.exp
index 8ebad6a..9180c88 100644
--- a/gdb/testsuite/gdb.dwarf2/var-access.exp
+++ b/gdb/testsuite/gdb.dwarf2/var-access.exp
@@ -282,16 +282,16 @@ gdb_test_no_output "set var \$[lindex $regname 0] = 81" \
"init reg for s2.a"
gdb_test_no_output "set var \$[lindex $regname 1] = 28" \
"init reg for s2.c"
-gdb_test "print/d s2" " = \\{a = 81, b = 4, c = 28, d = 5\\}" \
+gdb_test "print/u s2" " = \\{a = 81, b = 4, c = 28, d = 5\\}" \
"initialized s2 from mem and regs"
gdb_test_no_output "set var s2.c += s2.a + s2.b - s2.d"
-gdb_test "print/d s2" " = \\{a = 81, b = 4, c = 108, d = 5\\}" \
+gdb_test "print/u s2" " = \\{a = 81, b = 4, c = 108, d = 5\\}" \
"verify s2.c"
-gdb_test "print/d \$[lindex $regname 1]" " = 108" \
+gdb_test "print/u \$[lindex $regname 1]" " = 108" \
"verify s2.c through reg"
gdb_test_no_output "set var s2 = {191, 73, 231, 123}" \
"re-initialize s2"
-gdb_test "print/d s2" " = \\{a = 191, b = 73, c = 231, d = 123\\}" \
+gdb_test "print/u s2" " = \\{a = 191, b = 73, c = 231, d = 123\\}" \
"verify re-initialized s2"
# Unaligned bitfield access through byte-aligned pieces.
diff --git a/gdb/testsuite/gdb.fortran/printing-types.exp b/gdb/testsuite/gdb.fortran/printing-types.exp
new file mode 100644
index 0000000..085de4f
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/printing-types.exp
@@ -0,0 +1,35 @@
+# Copyright 2017 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if {[skip_fortran_tests]} { return -1 }
+
+standard_testfile .f90
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
+ return -1
+}
+
+if {![runto MAIN__]} then {
+ untested "Could not run to breakpoint MAIN__"
+ return -1
+}
+
+gdb_breakpoint [gdb_get_line_number "write"]
+gdb_continue_to_breakpoint "write"
+
+gdb_test "print oneByte" " = 1"
+gdb_test "print twobytes" " = 2"
+gdb_test "print chvalue" " = \'a\'"
+gdb_test "print logvalue" " = \.TRUE\."
diff --git a/gdb/testsuite/gdb.fortran/printing-types.f90 b/gdb/testsuite/gdb.fortran/printing-types.f90
new file mode 100644
index 0000000..749aa7c
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/printing-types.f90
@@ -0,0 +1,27 @@
+! Copyright 2017 Free Software Foundation, Inc.
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 3 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License
+! along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+program prog
+ integer(1) :: oneByte
+ integer(2) :: twoBytes
+ character :: chValue
+ logical(1) :: logValue
+
+ oneByte = 1
+ twoBytes = 2
+ chValue = 'a'
+ logValue = .true.
+ write(*,*) s
+end
diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.exp b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
new file mode 100644
index 0000000..ea510f1
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/ptr-indentation.exp
@@ -0,0 +1,41 @@
+# Copyright 2017 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+if {[skip_fortran_tests]} { return -1 }
+
+standard_testfile .f90
+load_lib fortran.exp
+
+if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug f90}]} {
+ return -1
+}
+
+if {![runto MAIN__]} then {
+ untested "couldn't run to breakpoint MAIN__"
+ return -1
+}
+
+set int [fortran_int4]
+set real [fortran_real4]
+
+gdb_breakpoint [gdb_get_line_number "BP1"]
+gdb_continue_to_breakpoint "BP1"
+
+# Check the indentation when using ptype on pointers in user-defined types.
+gdb_test "ptype tinsta" \
+ [multi_line "type = Type tuserdef" \
+ " $int :: i" \
+ " PTR TO -> \\( $real :: ptr\\)" \
+ "End Type tuserdef"]
diff --git a/gdb/testsuite/gdb.fortran/ptr-indentation.f90 b/gdb/testsuite/gdb.fortran/ptr-indentation.f90
new file mode 100644
index 0000000..045f5ef
--- /dev/null
+++ b/gdb/testsuite/gdb.fortran/ptr-indentation.f90
@@ -0,0 +1,30 @@
+! Copyright 2017 Free Software Foundation, Inc.
+!
+! This program is free software; you can redistribute it and/or modify
+! it under the terms of the GNU General Public License as published by
+! the Free Software Foundation; either version 3 of the License, or
+! (at your option) any later version.
+!
+! This program is distributed in the hope that it will be useful,
+! but WITHOUT ANY WARRANTY; without even the implied warranty of
+! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+! GNU General Public License for more details.
+!
+! You should have received a copy of the GNU General Public License
+! along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+program main
+ implicit none
+
+ type tuserdef
+ integer :: i
+ real, pointer :: ptr
+ end type tuserdef
+ real, target :: rval
+
+ type(tuserdef), target:: tinsta,tinstb,tinstc
+
+ tinsta%i = 4
+ tinsta%ptr => rval !BP1
+
+end program main
diff --git a/gdb/testsuite/gdb.fortran/vla-ptype.exp b/gdb/testsuite/gdb.fortran/vla-ptype.exp
index 2dd51e5..c8e72e9 100644
--- a/gdb/testsuite/gdb.fortran/vla-ptype.exp
+++ b/gdb/testsuite/gdb.fortran/vla-ptype.exp
@@ -39,7 +39,7 @@ gdb_test "ptype vla1(3, 6, 9)" "no such vector element \\\(vector not allocated\
"ptype vla1(3, 6, 9) not initialized"
gdb_test "ptype vla2(5, 45, 20)" \
"no such vector element \\\(vector not allocated\\\)" \
- "ptype vla1(5, 45, 20) not initialized"
+ "ptype vla2(5, 45, 20) not initialized"
gdb_breakpoint [gdb_get_line_number "vla1-allocated"]
gdb_continue_to_breakpoint "vla1-allocated"
@@ -63,7 +63,7 @@ gdb_continue_to_breakpoint "vla2-filled"
gdb_test "ptype vla2" "type = $real \\\(7,42:50,13:35\\\)" \
"ptype vla2 filled"
gdb_test "ptype vla2(5, 45, 20)" "type = $real" \
- "ptype vla1(5, 45, 20) filled"
+ "ptype vla2(5, 45, 20) filled"
gdb_breakpoint [gdb_get_line_number "pvla-associated"]
gdb_continue_to_breakpoint "pvla-associated"
@@ -77,7 +77,7 @@ gdb_continue_to_breakpoint "pvla-re-associated"
gdb_test "ptype pvla" "type = $real \\\(7,42:50,13:35\\\)" \
"ptype pvla re-associated"
gdb_test "ptype vla2(5, 45, 20)" "type = $real" \
- "ptype vla1(5, 45, 20) re-associated"
+ "ptype vla2(5, 45, 20) re-associated"
gdb_breakpoint [gdb_get_line_number "pvla-deassociated"]
gdb_continue_to_breakpoint "pvla-deassociated"
diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran/vla-value.exp
index 6ceceab..60022c5 100644
--- a/gdb/testsuite/gdb.fortran/vla-value.exp
+++ b/gdb/testsuite/gdb.fortran/vla-value.exp
@@ -14,6 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
standard_testfile "vla.f90"
+load_lib "fortran.exp"
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
{debug f90 quiet}] } {
@@ -25,12 +26,16 @@ if ![runto_main] {
return -1
}
+# Depending on the compiler being used,
+# the type names can be printed differently.
+set real [fortran_real4]
+
# Try to access values in non allocated VLA
gdb_breakpoint [gdb_get_line_number "vla1-init"]
gdb_continue_to_breakpoint "vla1-init"
gdb_test "print vla1" " = <not allocated>" "print non-allocated vla1"
gdb_test "print &vla1" \
- " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(<not allocated>\\\)\\\)\\\) $hex" \
+ " = \\\(PTR TO -> \\\( $real \\\(<not allocated>\\\)\\\)\\\) $hex" \
"print non-allocated &vla1"
gdb_test "print vla1(1,1,1)" "no such vector element \\\(vector not allocated\\\)" \
"print member in non-allocated vla1 (1)"
@@ -51,12 +56,12 @@ with_timeout_factor 15 {
"step over value assignment of vla1"
}
gdb_test "print &vla1" \
- " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(10,10,10\\\)\\\)\\\) $hex" \
+ " = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\)\\\)\\\) $hex" \
"print allocated &vla1"
gdb_test "print vla1(3, 6, 9)" " = 1311" "print allocated vla1(3,6,9)"
gdb_test "print vla1(1, 3, 8)" " = 1311" "print allocated vla1(1,3,8)"
gdb_test "print vla1(9, 9, 9) = 999" " = 999" \
- "print allocated vla1(9,9,9)=1"
+ "print allocated vla1(9,9,9)=999"
# Try to access values in allocated VLA after specific assignment
gdb_breakpoint [gdb_get_line_number "vla1-filled"]
@@ -71,7 +76,7 @@ gdb_test "print vla1(9, 9, 9)" " = 999" \
# Try to access values in undefined pointer to VLA (dangling)
gdb_test "print pvla" " = <not associated>" "print undefined pvla"
gdb_test "print &pvla" \
- " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(<not associated>\\\)\\\)\\\) $hex" \
+ " = \\\(PTR TO -> \\\( $real \\\(<not associated>\\\)\\\)\\\) $hex" \
"print non-associated &pvla"
gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated\\\)" \
"print undefined pvla(1,3,8)"
@@ -80,7 +85,7 @@ gdb_test "print pvla(1, 3, 8)" "no such vector element \\\(vector not associated
gdb_breakpoint [gdb_get_line_number "pvla-associated"]
gdb_continue_to_breakpoint "pvla-associated"
gdb_test "print &pvla" \
- " = \\\(PTR TO -> \\\( real\\\(kind=4\\\) \\\(10,10,10\\\)\\\)\\\) $hex" \
+ " = \\\(PTR TO -> \\\( $real \\\(10,10,10\\\)\\\)\\\) $hex" \
"print associated &pvla"
gdb_test "print pvla(3, 6, 9)" " = 42" "print associated pvla(3,6,9)"
gdb_test "print pvla(1, 3, 8)" " = 1001" "print associated pvla(1,3,8)"
diff --git a/gdb/testsuite/gdb.gdb/unittest.exp b/gdb/testsuite/gdb.gdb/unittest.exp
index d6fc3de..c3e36e6 100644
--- a/gdb/testsuite/gdb.gdb/unittest.exp
+++ b/gdb/testsuite/gdb.gdb/unittest.exp
@@ -15,3 +15,8 @@
gdb_start
gdb_test "maintenance selftest" "Ran $decimal unit tests, 0 failed"
+
+if { ![is_remote host] } {
+ gdb_test "maintenance check xml-descriptions ${srcdir}/../features" \
+ "Tested $decimal XML files, 0 failed"
+}
diff --git a/gdb/testsuite/gdb.gdb/xfullpath.exp b/gdb/testsuite/gdb.gdb/xfullpath.exp
deleted file mode 100644
index 8c90693..0000000
--- a/gdb/testsuite/gdb.gdb/xfullpath.exp
+++ /dev/null
@@ -1,60 +0,0 @@
-# Copyright 2002-2017 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-# This file was written by Joel Brobecker. (brobecker@gnat.com), derived
-# from selftest.exp, written by Rob Savoye.
-
-load_lib selftest-support.exp
-
-proc test_with_self {} {
- # A file which contains a directory prefix
- gdb_test "print gdb_realpath (\"./xfullpath.exp\")" \
- ".\[0-9\]+ =.*\".*/xfullpath.exp\"" \
- "A filename with ./ as the directory prefix"
-
- # A file which contains a directory prefix
- gdb_test "print gdb_realpath (\"../../defs.h\")" \
- ".\[0-9\]+ =.*\".*/defs.h\"" \
- "A filename with ../ in the directory prefix"
-
- # A one-character filename
- gdb_test "print gdb_realpath (\"./a\")" \
- ".\[0-9\]+ =.*\".*/a\"" \
- "A one-char filename in the current directory"
-
- # A file in the root directory
- gdb_test "print gdb_realpath (\"/root_file_which_should_exist\")" \
- ".\[0-9\]+ =.*\"/root_file_which_should_exist\"" \
- "A filename in the root directory"
-
- # A file which does not have a directory prefix
- gdb_test "print gdb_realpath (\"xfullpath.exp\")" \
- ".\[0-9\]+ =.*\"xfullpath.exp\"" \
- "A filename without any directory prefix"
-
- # A one-char filename without any directory prefix
- gdb_test "print gdb_realpath (\"a\")" \
- ".\[0-9\]+ =.*\"a\"" \
- "A one-char filename without any directory prefix"
-
- # An empty filename
- gdb_test "print gdb_realpath (\"\")" \
- ".\[0-9\]+ =.*\"\"" \
- "an empty filename"
-
- return 0
-}
-
-do_self_tests captured_main test_with_self
diff --git a/gdb/testsuite/gdb.linespec/base/one/thefile.cc b/gdb/testsuite/gdb.linespec/base/one/thefile.cc
index 0417b7a..34bc547 100644
--- a/gdb/testsuite/gdb.linespec/base/one/thefile.cc
+++ b/gdb/testsuite/gdb.linespec/base/one/thefile.cc
@@ -23,3 +23,8 @@ int NameSpace::overload(int x)
{
return x + 23;
}
+
+int z1 ()
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.linespec/base/two/thefile.cc b/gdb/testsuite/gdb.linespec/base/two/thefile.cc
index 88188a5..264ae97 100644
--- a/gdb/testsuite/gdb.linespec/base/two/thefile.cc
+++ b/gdb/testsuite/gdb.linespec/base/two/thefile.cc
@@ -24,3 +24,8 @@ int NameSpace::overload(double x)
{
return (int) x - 23;
}
+
+int z2 ()
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.linespec/linespec.exp b/gdb/testsuite/gdb.linespec/linespec.exp
index ccb73c8..b30ac10 100644
--- a/gdb/testsuite/gdb.linespec/linespec.exp
+++ b/gdb/testsuite/gdb.linespec/linespec.exp
@@ -43,6 +43,9 @@ if {$l1 != $l2} {
error "somebody incompatibly modified the source files needed by linespec.exp"
}
+gdb_test_no_output "set breakpoint pending off" \
+ "disable pending breakpoints for linespec tests"
+
# Copying files to a remote host loses the directory prefix during
# compilation.
if { [is_remote host] } {
@@ -55,6 +58,93 @@ if { [is_remote host] } {
gdb_test "clear one/thefile.cc:$l1" \
"Deleted breakpoint $decimal *" \
"clear breakpoint using dir/file:line"
+
+ if { [readline_is_used] } {
+ # There are functions named 'twodup' in both source files.
+ # Both should be found if we restrict the linespec to the
+ # ambiguous "thefile.cc" source filename. Check both
+ # completion and setting the breakpoint.
+ set tst "complete unique function name in two source files"
+ send_gdb "break thefile.cc:t\t"
+ gdb_test_multiple "" $tst {
+ -re "break thefile.cc:twodup\\(\\) " {
+ pass $tst
+
+ send_gdb "\n"
+ gdb_test "" \
+ "Breakpoint $decimal at $hex: thefile.cc:twodup\\(\\). \[(\]2 locations\[)\]" \
+ "set break at unique function name in two source files"
+ }
+ }
+
+ # Check both completing and setting a breakpoint on a linespec
+ # with a source component, where there's more than one source
+ # file with the same basename. We should find the functions
+ # in all matching sources -- one/thefile.cc and
+ # two/thefile.cc. The "one" file has "z1()", while the "two"
+ # file has "z2()".
+ set tst "complete non-unique function name in two source files"
+ send_gdb "break thefile.cc:z\t"
+ gdb_test_multiple "" $tst {
+ -re "break thefile.cc:z\\\x07" {
+ send_gdb "\t"
+ gdb_test_multiple "" $tst {
+ -re "\r\nz1\\(\\)\[ \t\]+z2\\(\\)\[ \t\]+\r\n$gdb_prompt " {
+ pass $tst
+
+ send_gdb "\n"
+ gdb_test "" \
+ "Function \"z\" not defined in \"thefile.cc\"." \
+ "set break at non-unique function name in two source files"
+ }
+ }
+ }
+ }
+
+ # Now check that disambiguating the source path makes GDB only
+ # match the symbols in that file. "z" should now have a
+ # unique completion to "z1()", and setting the breakpoint
+ # should find only one location.
+ set tst "complete unique function name in disambiguated source file"
+ send_gdb "break one/thefile.cc:z\t"
+ gdb_test_multiple "" $tst {
+ -re "break one/thefile.cc:z1\\(\\) " {
+ pass $tst
+
+ send_gdb "\n"
+ gdb_test "" \
+ "Breakpoint $decimal at $hex: file .*thefile.cc, line \[^\r\n\]*" \
+ "set break at unique function name in disambiguated source file"
+ }
+ }
+
+ # Check that using a non-existing source path does not confuse
+ # GDB. It should not match any symbol.
+ set dir_file "one/thefile.cc"
+ set non_existing "/some/non-existing/absolute/path/prefix/$dir_file"
+ set non_existing_re [string_to_regexp $non_existing]
+
+ set tst "complete functions in non-existing absolute path"
+ send_gdb "break $non_existing:\t"
+ gdb_test_multiple "" $tst {
+ -re "break $non_existing_re:\\\x07" {
+ send_gdb "\t\t"
+ gdb_test_multiple "" $tst {
+ -re "^\\\x07\\\x07" {
+ pass $tst
+
+ # There's a function called 'twodup' in each
+ # of the thefile.cc files. Make sure none is
+ # picked.
+ send_gdb "twodup\n"
+ gdb_test "" \
+ "No source file named $non_existing_re." \
+ "set break in function in non-existing absolute path"
+ }
+ }
+ }
+ }
+ }
}
gdb_test "break thefile.cc:$l1" \
@@ -73,9 +163,6 @@ gdb_test "break dupname:label" \
# not the locations.
gdb_test "complete condition " "condition $decimal\r\ncondition $decimal\r\ncondition $decimal"
-gdb_test_no_output "set breakpoint pending off" \
- "disable pending breakpoints for linespec tests"
-
# This is PR breakpoints/12856.
gdb_test "break lspec.cc:nosuchfunction" \
"Function \"nosuchfunction\" not defined in \"lspec.cc\"." \
diff --git a/gdb/testsuite/gdb.linespec/ls-errs.exp b/gdb/testsuite/gdb.linespec/ls-errs.exp
index 1f78ca6..f55cd0e 100644
--- a/gdb/testsuite/gdb.linespec/ls-errs.exp
+++ b/gdb/testsuite/gdb.linespec/ls-errs.exp
@@ -96,8 +96,13 @@ proc do_test {lang} {
}
# Some commonly used whitespace tests around ':'.
- set spaces [list ":" ": " " :" " : " "\t: " " :\t" "\t:\t" \
- " \t:\t " "\t \t:\t \t \t"]
+ set spaces [list \
+ ":" \
+ ": " \
+ " :" \
+ " : " \
+ " : " \
+ ]
# A list of invalid offsets.
set invalid_offsets [list -100 +500 1000]
@@ -167,11 +172,14 @@ proc do_test {lang} {
test_break "-source $x -line 3" invalid_file [string trim $x \"']
}
- # Test that option lexing stops at whitespace boundaries
+ # Test that option lexing stops at whitespace boundaries, except
+ # when lexing function names, where we want to handle setting
+ # breakpoints on e.g., "int template_function<int>()".
test_break "-source this file has spaces.c -line 3" invalid_file "this"
- test_break "-function function whitespace" invalid_function "function"
- test_break "-source $srcfile -function function whitespace" \
- invalid_function_f "function" $srcfile
+ test_break "-function ret_type tmpl_function" \
+ invalid_function "ret_type tmpl_function"
+ test_break "-source $srcfile -function ret_type tmpl_function" \
+ invalid_function_f "ret_type tmpl_function" $srcfile
test_break "-function main -label label whitespace" \
invalid_label "label" "main"
@@ -232,7 +240,12 @@ proc do_test {lang} {
foreach x {"3" "+100" "-100" "foo"} {
test_break "main 3" invalid_function "main 3"
test_break "-function \"main $x\"" invalid_function "main $x"
- test_break "main:here $x" invalid_label "here $x" "main"
+ if {$x == "foo"} {
+ test_break "main:here $x" unexpected_opt "string" $x
+ } else {
+ test_break "main:here $x" unexpected_opt "number" $x
+ }
+
test_break "-function main -label \"here $x\"" \
invalid_label "here $x" "main"
}
diff --git a/gdb/testsuite/gdb.mi/mi-var-child-f.exp b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
index dd56c35..a4a9a89 100644
--- a/gdb/testsuite/gdb.mi/mi-var-child-f.exp
+++ b/gdb/testsuite/gdb.mi/mi-var-child-f.exp
@@ -17,6 +17,7 @@
load_lib mi-support.exp
set MIFLAGS "-i=mi"
+load_lib "fortran.exp"
if { [skip_fortran_tests] } { return -1 }
@@ -40,10 +41,9 @@ mi_runto MAIN__
mi_create_varobj "array" "array" "create local variable array"
-# Depending on the compiler version being used, the name of the 4-byte integer
-# and real types can be printed differently. For instance, gfortran-4.1 uses
-# "int4" whereas gfortran-4.3 uses "integer(kind=4)".
-set int4 "(int4|integer\\(kind=4\\))"
+# Depending on the compiler being used,
+# the type names can be printed differently.
+set int4 [fortran_int4]
set children [list [list "array.-1" "-1" 2 "$int4 \\(2\\)"] \
[list "array.0" "0" 2 "$int4 \\(2\\)"] \
diff --git a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
index b81165e..bee6ebe 100644
--- a/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
+++ b/gdb/testsuite/gdb.mi/mi-vla-fortran.exp
@@ -17,6 +17,7 @@
# Array (VLA).
load_lib mi-support.exp
+load_lib fortran.exp
set MIFLAGS "-i=mi"
gdb_exit
@@ -32,19 +33,23 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
return -1
}
+# Depending on the compiler being used,
+# the type names can be printed differently.
+set real [fortran_real4]
+
mi_delete_breakpoints
mi_gdb_reinitialize_dir $srcdir/$subdir
mi_gdb_load ${binfile}
set bp_lineno [gdb_get_line_number "vla1-not-allocated"]
-mi_create_breakpoint "-t vla.f90:$bp_lineno" 1 "del" "vla" \
- ".*vla.f90" $bp_lineno $hex \
- "insert breakpoint at line $bp_lineno (vla not allocated)"
+mi_create_breakpoint "-t vla.f90:$bp_lineno" \
+ "insert breakpoint at line $bp_lineno (vla not allocated)" \
+ -number 1 -disp del -func vla ".*vla.f90" $bp_lineno $hex
mi_run_cmd
mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
{ "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
mi_gdb_test "500-data-evaluate-expression vla1" \
- "500\\^done,value=\"<not allocated>\"" "evaluate not allocated vla"
+ "500\\^done,value=\"<not allocated>\"" "evaluate not allocated vla, before allocation"
mi_create_varobj_checked vla1_not_allocated vla1 "<not allocated>" \
"create local variable vla1_not_allocated"
@@ -58,23 +63,24 @@ mi_gdb_test "503-var-evaluate-expression vla1_not_allocated" \
"503\\^done,value=\"\\\[0\\\]\"" \
"eval variable vla1_not_allocated"
mi_list_array_varobj_children_with_index "vla1_not_allocated" "0" "1" \
- "real\\\(kind=4\\\)" "get children of vla1_not_allocated"
+ "$real" "get children of vla1_not_allocated"
set bp_lineno [gdb_get_line_number "vla1-allocated"]
-mi_create_breakpoint "-t vla.f90:$bp_lineno" 2 "del" "vla" ".*vla.f90" \
- $bp_lineno $hex "insert breakpoint at line $bp_lineno (vla allocated)"
+mi_create_breakpoint "-t vla.f90:$bp_lineno" \
+ "insert breakpoint at line $bp_lineno (vla allocated)" \
+ -number 2 -disp del -func vla ".*vla.f90" $bp_lineno $hex
mi_run_cmd
mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
{ "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
mi_gdb_test "510-data-evaluate-expression vla1" \
"510\\^done,value=\"\\(.*\\)\"" "evaluate allocated vla"
-mi_create_varobj_checked vla1_allocated vla1 "real\\\(kind=4\\\) \\\(5\\\)" \
+mi_create_varobj_checked vla1_allocated vla1 "$real \\\(5\\\)" \
"create local variable vla1_allocated"
mi_gdb_test "511-var-info-type vla1_allocated" \
- "511\\^done,type=\"real\\\(kind=4\\\) \\\(5\\\)\"" \
+ "511\\^done,type=\"$real \\\(5\\\)\"" \
"info type variable vla1_allocated"
mi_gdb_test "512-var-show-format vla1_allocated" \
"512\\^done,format=\"natural\"" \
@@ -83,48 +89,52 @@ mi_gdb_test "513-var-evaluate-expression vla1_allocated" \
"513\\^done,value=\"\\\[5\\\]\"" \
"eval variable vla1_allocated"
mi_list_array_varobj_children_with_index "vla1_allocated" "5" "1" \
- "real\\\(kind=4\\\)" "get children of vla1_allocated"
+ "$real" "get children of vla1_allocated"
set bp_lineno [gdb_get_line_number "vla1-filled"]
-mi_create_breakpoint "-t vla.f90:$bp_lineno" 3 "del" "vla" ".*vla.f90" \
- $bp_lineno $hex "insert breakpoint at line $bp_lineno"
+mi_create_breakpoint "-t vla.f90:$bp_lineno" \
+ "insert breakpoint at line $bp_lineno" \
+ -number 3 -disp del -func vla ".*vla.f90" $bp_lineno $hex
mi_run_cmd
mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
{ "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
mi_gdb_test "520-data-evaluate-expression vla1" \
- "520\\^done,value=\"\\(1, 1, 1, 1, 1\\)\"" "evaluate filled vla"
+ "520\\^done,value=\"\\(1, 1, 1, 1, 1\\)\"" "evaluate filled vla, filled all 1s"
set bp_lineno [gdb_get_line_number "vla1-modified"]
-mi_create_breakpoint "-t vla.f90:$bp_lineno" 4 "del" "vla" ".*vla.f90" \
- $bp_lineno $hex "insert breakpoint at line $bp_lineno"
+mi_create_breakpoint "-t vla.f90:$bp_lineno" \
+ "insert breakpoint at line $bp_lineno" \
+ -number 4 -disp del -func vla ".*vla.f90" $bp_lineno $hex
mi_run_cmd
mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
{ "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
mi_gdb_test "530-data-evaluate-expression vla1" \
- "530\\^done,value=\"\\(1, 42, 1, 24, 1\\)\"" "evaluate filled vla"
+ "530\\^done,value=\"\\(1, 42, 1, 24, 1\\)\"" "evaluate filled vla, contents modified"
mi_gdb_test "540-data-evaluate-expression vla1(1)" \
- "540\\^done,value=\"1\"" "evaluate filled vla"
+ "540\\^done,value=\"1\"" "evaluate filled vla(1)"
mi_gdb_test "550-data-evaluate-expression vla1(2)" \
- "550\\^done,value=\"42\"" "evaluate filled vla"
+ "550\\^done,value=\"42\"" "evaluate filled vla(2)"
mi_gdb_test "560-data-evaluate-expression vla1(4)" \
- "560\\^done,value=\"24\"" "evaluate filled vla"
+ "560\\^done,value=\"24\"" "evaluate filled vla(4)"
set bp_lineno [gdb_get_line_number "vla1-deallocated"]
-mi_create_breakpoint "-t vla.f90:$bp_lineno" 5 "del" "vla" ".*vla.f90" \
- $bp_lineno $hex "insert breakpoint at line $bp_lineno"
+mi_create_breakpoint "-t vla.f90:$bp_lineno" \
+ "insert breakpoint at line $bp_lineno" \
+ -number 5 -disp del -func vla ".*vla.f90" $bp_lineno $hex
mi_run_cmd
mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
{ "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
mi_gdb_test "570-data-evaluate-expression vla1" \
- "570\\^done,value=\"<not allocated>\"" "evaluate not allocated vla"
+ "570\\^done,value=\"<not allocated>\"" "evaluate not allocated vla, after deallocation"
set bp_lineno [gdb_get_line_number "pvla2-not-associated"]
-mi_create_breakpoint "-t vla.f90:$bp_lineno" 6 "del" "vla" ".*vla.f90" \
- $bp_lineno $hex "insert breakpoint at line $bp_lineno"
+mi_create_breakpoint "-t vla.f90:$bp_lineno" \
+ "insert breakpoint at line $bp_lineno" \
+ -number 6 -disp "del" -func "vla" ".*vla.f90" $bp_lineno $hex
mi_run_cmd
mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
{ "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
@@ -148,7 +158,7 @@ gdb_expect {
"583\\^done,value=\"\\\[0\\\]\"" \
"eval variable pvla2_not_associated"
mi_list_array_varobj_children_with_index "pvla2_not_associated" "0" "1" \
- "real\\\(kind=4\\\)" "get children of pvla2_not_associated"
+ "$real" "get children of pvla2_not_associated"
}
-re "580\\^error,msg=\"value contents too large \\(\[0-9\]+ bytes\\).*${mi_gdb_prompt}$" {
# Undefined behaviour in gfortran.
@@ -163,8 +173,9 @@ gdb_expect {
}
set bp_lineno [gdb_get_line_number "pvla2-associated"]
-mi_create_breakpoint "-t vla.f90:$bp_lineno" 7 "del" "vla" ".*vla.f90" \
- $bp_lineno $hex "insert breakpoint at line $bp_lineno"
+mi_create_breakpoint "-t vla.f90:$bp_lineno" \
+ "insert breakpoint at line $bp_lineno" \
+ -number 7 -disp del -func vla ".*vla.f90" $bp_lineno $hex
mi_run_cmd
mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
{ "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
@@ -173,9 +184,9 @@ mi_gdb_test "590-data-evaluate-expression pvla2" \
"evaluate associated vla"
mi_create_varobj_checked pvla2_associated pvla2 \
- "real\\\(kind=4\\\) \\\(5,2\\\)" "create local variable pvla2_associated"
+ "$real \\\(5,2\\\)" "create local variable pvla2_associated"
mi_gdb_test "591-var-info-type pvla2_associated" \
- "591\\^done,type=\"real\\\(kind=4\\\) \\\(5,2\\\)\"" \
+ "591\\^done,type=\"$real \\\(5,2\\\)\"" \
"info type variable pvla2_associated"
mi_gdb_test "592-var-show-format pvla2_associated" \
"592\\^done,format=\"natural\"" \
@@ -186,8 +197,9 @@ mi_gdb_test "593-var-evaluate-expression pvla2_associated" \
set bp_lineno [gdb_get_line_number "pvla2-set-to-null"]
-mi_create_breakpoint "-t vla.f90:$bp_lineno" 8 "del" "vla" ".*vla.f90" \
- $bp_lineno $hex "insert breakpoint at line $bp_lineno"
+mi_create_breakpoint "-t vla.f90:$bp_lineno" \
+ "insert breakpoint at line $bp_lineno" \
+ -number 8 -disp del -func vla ".*vla.f90" $bp_lineno $hex
mi_run_cmd
mi_expect_stop "breakpoint-hit" "vla" "" ".*vla.f90" "$bp_lineno" \
{ "" "disp=\"del\"" } "run to breakpoint at line $bp_lineno"
diff --git a/gdb/testsuite/gdb.multi/multi-arch-exec.exp b/gdb/testsuite/gdb.multi/multi-arch-exec.exp
index ed98532..27a0d60 100644
--- a/gdb/testsuite/gdb.multi/multi-arch-exec.exp
+++ b/gdb/testsuite/gdb.multi/multi-arch-exec.exp
@@ -76,12 +76,22 @@ if { [prepare_for_testing "failed to prepare" ${exec2} "${srcfile2}" \
return -1
}
-clean_restart ${exec1}
-if ![runto_main] then {
- fail "couldn't run to main"
- return -1
+proc do_test { mode } {
+ global exec1
+
+ clean_restart ${exec1}
+ if ![runto_main] then {
+ fail "couldn't run to main"
+ return -1
+ }
+
+ gdb_test_no_output "set follow-exec-mode $mode"
+
+ # Test that GDB updates the target description / arch successfuly
+ # after the exec.
+ gdb_test "continue" "Breakpoint 1, main.*" "continue across exec that changes architecture"
}
-# Test that GDB updates the target description / arch successfuly
-# after the exec.
-gdb_test "continue" "Breakpoint 1, main.*" "continue across exec that changes architecture"
+foreach follow_exec_mode {"same" "new"} {
+ do_test $follow_exec_mode
+}
diff --git a/gdb/testsuite/gdb.python/py-inferior.exp b/gdb/testsuite/gdb.python/py-inferior.exp
index c2ea2c2..715c693 100644
--- a/gdb/testsuite/gdb.python/py-inferior.exp
+++ b/gdb/testsuite/gdb.python/py-inferior.exp
@@ -214,12 +214,33 @@ with_test_prefix "is_valid" {
gdb_test "python print (inf_list\[0\].is_valid())" "True" \
"check inferior validity 1"
+ gdb_py_test_multiple "install new inferior event handler" \
+ "python" "" \
+ "my_inferior_count = 1" "" \
+ "def new_inf_handler(evt):" "" \
+ " global my_inferior_count" "" \
+ " if evt.inferior is not None:" "" \
+ " my_inferior_count = my_inferior_count + 1" "" \
+ "gdb.events.new_inferior.connect(new_inf_handler)" "" \
+ "end" ""
+ gdb_py_test_multiple "install inferior deleted event handler" \
+ "python" "" \
+ "def del_inf_handler(evt):" "" \
+ " global my_inferior_count" "" \
+ " if evt.inferior is not None:" "" \
+ " my_inferior_count = my_inferior_count - 1" "" \
+ "gdb.events.inferior_deleted.connect(del_inf_handler)" "" \
+ "end" ""
+
gdb_test "add-inferior" "Added inferior 2.*" "add empty inferior 2"
gdb_py_test_silent_cmd "python inf_list = gdb.inferiors()" "get new list" 1
gdb_test "python print (len(inf_list))" "2" "get inferior list length 2"
gdb_test "python print (inf_list\[0\].is_valid())" "True" \
"check inferior validity 2"
+ gdb_test "python print (my_inferior_count)" "2" \
+ "test new-inferior event handler"
+
gdb_test "python print (inf_list\[1\].is_valid())" "True" \
"check inferior validity 3"
@@ -229,6 +250,9 @@ with_test_prefix "is_valid" {
gdb_test "python print (inf_list\[1\].is_valid())" "False" \
"check inferior validity 5"
+
+ gdb_test "python print (my_inferior_count)" "1" \
+ "test inferior-deleted event handler"
}
# Test gdb.selected_inferior()
diff --git a/gdb/testsuite/gdb.python/py-infthread.exp b/gdb/testsuite/gdb.python/py-infthread.exp
index a5fed8d..0711d69 100644
--- a/gdb/testsuite/gdb.python/py-infthread.exp
+++ b/gdb/testsuite/gdb.python/py-infthread.exp
@@ -30,6 +30,16 @@ clean_restart ${testfile}
# Skip all tests if Python scripting is not enabled.
if { [skip_python_tests] } { continue }
+gdb_py_test_multiple "install new_thread event handler" \
+ "python" "" \
+ "seen_a_thread = False" "" \
+ "def thread_handler(evt):" "" \
+ " if evt.inferior_thread is not None:" "" \
+ " global seen_a_thread" "" \
+ " seen_a_thread = True" "" \
+ "gdb.events.new_thread.connect(thread_handler)" "" \
+ "end" ""
+
# The following tests require execution.
if ![runto_main] then {
@@ -37,6 +47,8 @@ if ![runto_main] then {
return 0
}
+gdb_test "python print(seen_a_thread)" "True"
+
# Test basic gdb.Inferior attributes and methods.
gdb_py_test_silent_cmd "python t0 = gdb.selected_thread ()" "test gdb.selected_thread" 1
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.c b/gdb/testsuite/gdb.python/py-prettyprint.c
index fd58358..82f9fe7 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.c
+++ b/gdb/testsuite/gdb.python/py-prettyprint.c
@@ -257,6 +257,15 @@ bug_14741()
set_item(&c, 0, 5);
}
+/* Some typedefs/variables for checking that GDB doesn't lose typedefs
+ when looking for a printer. */
+typedef int int_type;
+typedef int_type int_type2;
+
+int an_int = -1;
+int_type an_int_type = 1;
+int_type2 an_int_type2 = 2;
+
int
main ()
{
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp
index b0a9e32..02300e9 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.exp
+++ b/gdb/testsuite/gdb.python/py-prettyprint.exp
@@ -110,6 +110,19 @@ proc run_lang_tests {exefile lang} {
gdb_test "print nstype" " = {.0. = 7, .1. = 42}" \
"print nstype on one line"
+ # Check that GDB doesn't lose typedefs when looking for a printer.
+ gdb_test "print an_int" " = -1"
+ gdb_test "print (int) an_int" " = -1"
+ gdb_test "print (int_type) an_int" " = type=int_type, val=-1"
+
+ gdb_test "print an_int_type" " = type=int_type, val=1"
+ gdb_test "print (int_type) an_int_type" " = type=int_type, val=1"
+
+ gdb_test "print an_int_type2" " = type=int_type2, val=2"
+ gdb_test "print (int) an_int_type2" " = 2"
+ gdb_test "print (int_type) an_int_type2" " = type=int_type, val=2"
+ gdb_test "print (int_type2) an_int_type2" " = type=int_type2, val=2"
+
gdb_continue_to_end
}
diff --git a/gdb/testsuite/gdb.python/py-prettyprint.py b/gdb/testsuite/gdb.python/py-prettyprint.py
index c56f564..ec845e4 100644
--- a/gdb/testsuite/gdb.python/py-prettyprint.py
+++ b/gdb/testsuite/gdb.python/py-prettyprint.py
@@ -227,6 +227,13 @@ class pp_eval_type (object):
gdb.execute("bt", to_string=True)
return "eval=<" + str(gdb.parse_and_eval("eval_func (123456789, 2, 3, 4, 5, 6, 7, 8)")) + ">"
+class pp_int_typedef (object):
+ def __init__(self, val):
+ self.val = val
+
+ def to_string(self):
+ return "type=%s, val=%s" % (self.val.type, int(self.val))
+
def lookup_function (val):
"Look-up and return a pretty-printer that can print val."
@@ -263,6 +270,26 @@ def disable_lookup_function ():
def enable_lookup_function ():
lookup_function.enabled = True
+# Lookup a printer for VAL in the typedefs dict.
+def lookup_typedefs_function (val):
+ "Look-up and return a pretty-printer that can print val (typedefs)."
+
+ # Get the type.
+ type = val.type
+
+ if type == None or type.name == None or type.code != gdb.TYPE_CODE_TYPEDEF:
+ return None
+
+ # Iterate over local dictionary of typedef types to determine if a
+ # printer is registered for that type. Return an instantiation of
+ # the printer if found.
+ for function in typedefs_pretty_printers_dict:
+ if function.match (type.name):
+ return typedefs_pretty_printers_dict[function] (val)
+
+ # Cannot find a pretty printer.
+ return None
+
def register_pretty_printers ():
pretty_printers_dict[re.compile ('^struct s$')] = pp_s
pretty_printers_dict[re.compile ('^s$')] = pp_s
@@ -309,7 +336,14 @@ def register_pretty_printers ():
pretty_printers_dict[re.compile ('^eval_type_s$')] = pp_eval_type
+ typedefs_pretty_printers_dict[re.compile ('^int_type$')] = pp_int_typedef
+ typedefs_pretty_printers_dict[re.compile ('^int_type2$')] = pp_int_typedef
+
+# Dict for struct types with typedefs fully stripped.
pretty_printers_dict = {}
+# Dict for typedef types.
+typedefs_pretty_printers_dict = {}
register_pretty_printers ()
gdb.pretty_printers.append (lookup_function)
+gdb.pretty_printers.append (lookup_typedefs_function)
diff --git a/gdb/testsuite/gdb.python/py-thrhandle.c b/gdb/testsuite/gdb.python/py-thrhandle.c
new file mode 100644
index 0000000..0dd974f
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-thrhandle.c
@@ -0,0 +1,94 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2017 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <pthread.h>
+#include <unistd.h>
+#include <memory.h>
+
+#define NTHR 3
+#define NBOGUSTHR 2
+
+int thr_data[NTHR];
+
+/* Thread handles for each thread plus some "bogus" threads. */
+pthread_t thrs[NTHR + NBOGUSTHR];
+
+/* The thread children will meet at this barrier. */
+pthread_barrier_t c_barrier;
+
+/* The main thread and child thread will meet at this barrier. */
+pthread_barrier_t mc_barrier;
+
+void
+do_something (int n)
+{
+}
+
+void *
+do_work (void *data)
+{
+ int num = * (int *) data;
+
+ /* As the child threads are created, they'll meet the main thread
+ at this barrier. We do this to ensure that threads end up in
+ GDB's thread list in the order in which they were created. Having
+ this ordering makes it easier to write the test. */
+ pthread_barrier_wait (&mc_barrier);
+
+ /* All of the child threads will meet at this barrier before proceeding.
+ This ensures that all threads will be active (not exited) and in
+ roughly the same state when the first one hits the breakpoint in
+ do_something(). */
+ pthread_barrier_wait (&c_barrier);
+
+ do_something (num);
+
+ pthread_exit (NULL);
+}
+
+void
+after_mc_barrier (void)
+{
+}
+
+int
+main (int argc, char **argv)
+{
+ int i;
+
+ pthread_barrier_init (&c_barrier, NULL, NTHR - 1);
+ pthread_barrier_init (&mc_barrier, NULL, 2);
+
+ thrs[0] = pthread_self ();
+ thr_data[0] = 1;
+
+ /* Create two bogus thread handles. */
+ memset (&thrs[NTHR], 0, sizeof (pthread_t));
+ memset (&thrs[NTHR + 1], 0xaa, sizeof (pthread_t));
+
+ for (i = 1; i < NTHR; i++)
+ {
+ thr_data[i] = i + 1;
+
+ pthread_create (&thrs[i], NULL, do_work, &thr_data[i]);
+ pthread_barrier_wait (&mc_barrier);
+ after_mc_barrier ();
+ }
+
+ for (i = 1; i < NTHR; i++)
+ pthread_join (thrs[i], NULL);
+}
diff --git a/gdb/testsuite/gdb.python/py-thrhandle.exp b/gdb/testsuite/gdb.python/py-thrhandle.exp
new file mode 100644
index 0000000..66b0472
--- /dev/null
+++ b/gdb/testsuite/gdb.python/py-thrhandle.exp
@@ -0,0 +1,102 @@
+# Copyright (C) 2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@gnu.org
+
+# This file verifies that gdb.Inferior.thread_from_thread_handle works
+# as expected.
+
+standard_testfile
+
+
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug] != "" } {
+ return -1
+}
+
+clean_restart ${binfile}
+runto_main
+
+gdb_test "break after_mc_barrier" \
+ "Breakpoint 2 at .*: file .*${srcfile}, line .*" \
+ "breakpoint on after_mc_barrier"
+
+gdb_test "break do_something" \
+ "Breakpoint 3 at .*: file .*${srcfile}, line .*" \
+ "breakpoint on do_something"
+
+gdb_test "continue" \
+ "Breakpoint 2, after_mc_barrier .*" \
+ "run to after_mc_barrier"
+
+gdb_test_no_output "del 2" "delete after_mc_barrier breakpoint"
+
+gdb_test "continue" \
+ "Breakpoint 3, do_something .*" \
+ "run to do_something"
+
+# The test case has been constructed so that the current thread,
+# indicated by '*' in the "info threads" output, should be stopped in
+# do_something() with a value of n which is the same as the number
+# reported in the "Id" column. If it's not, then something went wrong
+# with the start up sequence which should cause the main thread to be
+# thread 1, the first child thread to be thread 2, and the second
+# child thread to be thread 3.
+#
+# Note that \1 in the RE below is a backreference to the thread id
+# reported in the "Id" column.
+
+gdb_test "info threads" \
+ {.*[\r\n]+\* +([0-9]+) +Thread[^\r\n]* do_something \(n=\1\) at.*}
+
+# Check for expected results when passing a valid thread handle to
+# thread_from_thread_handle().
+
+gdb_test "python print(gdb.selected_inferior().thread_from_thread_handle(gdb.parse_and_eval('thrs\[0\]')).num)" \
+ "1" "print thread id for thrs\[0\]"
+
+gdb_test "python print(gdb.selected_inferior().thread_from_thread_handle(gdb.parse_and_eval('thrs\[1\]')).num)" \
+ "2" "print thread id for thrs\[1\]"
+
+gdb_test "python print(gdb.selected_inferior().thread_from_thread_handle(gdb.parse_and_eval('thrs\[2\]')).num)" \
+ "3" "print thread id for thrs\[2\]"
+
+# Objects which are of the correct size, but which are bogus thread
+# handles should return None. For the first test (using thrs[3]), we
+# use 0. For the second (thrs[4]), we use an unlikely bit pattern.
+
+gdb_test "python print(gdb.selected_inferior().thread_from_thread_handle(gdb.parse_and_eval('thrs\[3\]')))" \
+ "None" "print thread for bogus handle thrs\[3\]"
+
+gdb_test "python print(gdb.selected_inferior().thread_from_thread_handle(gdb.parse_and_eval('thrs\[4\]')))" \
+ "None" "print thread for bogus handle thrs\[4\]"
+
+# We should see an exception when passing an object of the wrong type.
+
+gdb_test "python print(gdb.selected_inferior().thread_from_thread_handle(gdb.lookup_symbol('main')))" \
+ ".*TypeError: Argument 'handle_obj' must be a thread handle object.*" \
+ "TypeError when passing a symbol object to thread_from_thread_handle"
+
+# We should see an exception when passing too large of an object.
+
+gdb_test "python print(gdb.selected_inferior().thread_from_thread_handle(gdb.parse_and_eval('thrs')))" \
+ ".*Thread handle size mismatch.*" \
+ "Pass overly large object to thread_from_thread_handle"
+
+# We should see an exception when passing too small of an object.
+
+gdb_test "python print(gdb.selected_inferior().thread_from_thread_handle(gdb.parse_and_eval('\"S\"')))" \
+ ".*Thread handle size mismatch.*" \
+ "Pass too small of an object to thread_from_thread_handle"
diff --git a/gdb/testsuite/gdb.python/py-unwind.exp b/gdb/testsuite/gdb.python/py-unwind.exp
index 0a4d34f..86e695c 100644
--- a/gdb/testsuite/gdb.python/py-unwind.exp
+++ b/gdb/testsuite/gdb.python/py-unwind.exp
@@ -20,7 +20,12 @@ load_lib gdb-python.exp
standard_testfile
-if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
+# Stack protection can make the stack look a bit different, breaking the
+# assumptions this test has about its layout.
+
+set flags "additional_flags=-fno-stack-protector"
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} "debug $flags"] } {
return -1
}
@@ -51,4 +56,5 @@ gdb_test_sequence "where" "Backtrace restored by unwinder" {
"\\r\\n#2 .* main \\(.*\\) at"
}
-
+# Check that the Python unwinder frames can be flushed / released.
+gdb_test "flushregs" "Register cache flushed\\." "flush frames"
diff --git a/gdb/testsuite/gdb.rust/simple.exp b/gdb/testsuite/gdb.rust/simple.exp
index 872b22c..403a11b 100644
--- a/gdb/testsuite/gdb.rust/simple.exp
+++ b/gdb/testsuite/gdb.rust/simple.exp
@@ -135,6 +135,9 @@ gdb_test "print simple::ByeBob\{field1: 0xff, field2:5\}" \
gdb_test "print simple::HiBob(0xff, 5)" \
"Type simple::HiBob is not a tuple struct"
+gdb_test "print sizeof(simple::HiBob)" " = \[0-9\]+"
+gdb_test "print simple::HiBob + 5" \
+ "Found type 'simple::HiBob', which can't be evaluated in this context"
gdb_test "print nosuchsymbol" \
"No symbol 'nosuchsymbol' in current context"
@@ -194,14 +197,14 @@ gdb_test "print 5.." " = .*::ops::RangeFrom.* \\{start: 5\\}"
gdb_test "print .." " = .*::ops::RangeFull"
gdb_test "print str_some" \
- " = core::option::Option<collections::string::String>::Some\\(collections::string::String .*"
-gdb_test "print str_none" " = core::option::Option<collections::string::String>::None"
+ " = core::option::Option<\[a-z\]+::string::String>::Some\\(\[a-z\]+::string::String .*"
+gdb_test "print str_none" " = core::option::Option<\[a-z\]+::string::String>::None"
gdb_test "print int_some" " = core::option::Option::Some\\(1\\)"
gdb_test "print int_none" " = core::option::Option::None"
gdb_test "print box_some" " = core::option::Option<\[a-z:\]*Box<u8>>::Some\\(.*\\)"
gdb_test "print box_none" " = core::option::Option<\[a-z:\]*Box<u8>>::None"
gdb_test "print custom_some" \
- " = simple::NonZeroOptimized::Value\\(collections::string::String .*"
+ " = simple::NonZeroOptimized::Value\\(\[a-z\]+::string::String .*"
gdb_test "print custom_none" " = simple::NonZeroOptimized::Empty"
proc test_one_slice {svar length base range} {
@@ -246,3 +249,11 @@ gdb_test "print parametrized.next.val" \
" = \\(simple::ParametrizedStruct<i32> \\*\\) $hex"
gdb_test "print parametrized" \
" = simple::ParametrizedStruct<i32> \\{next: simple::ParametrizedEnum<\[a-z:\]*Box<simple::ParametrizedStruct<i32>>>::Val\\{val: $hex\\}, value: 0\\}"
+
+
+load_lib gdb-python.exp
+if {[skip_python_tests]} {
+ continue
+}
+
+gdb_test "python print(gdb.lookup_type('simple::HiBob'))" "simple::HiBob"
diff --git a/gdb/testsuite/gdb.server/normal.c b/gdb/testsuite/gdb.server/normal.c
new file mode 100644
index 0000000..f0eb154
--- /dev/null
+++ b/gdb/testsuite/gdb.server/normal.c
@@ -0,0 +1,24 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2013-2017 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* This test is just a normal return 0. */
+
+int
+main (int argc, char *argv[])
+{
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.server/run-without-local-binary.exp b/gdb/testsuite/gdb.server/run-without-local-binary.exp
new file mode 100644
index 0000000..07bb828
--- /dev/null
+++ b/gdb/testsuite/gdb.server/run-without-local-binary.exp
@@ -0,0 +1,62 @@
+# Copyright 2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+load_lib gdbserver-support.exp
+
+if {[skip_gdbserver_tests]} {
+ return
+}
+
+standard_testfile normal.c
+
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile debug]} {
+ return -1
+}
+
+# Test running GDB without providing a local binary for it. In order
+# to do that, we unset GDBFLAGS before running GDB. We also start
+# gdbserver "by hand". For more details about this test, see PR
+# remote/21852.
+save_vars { GDBFLAGS } {
+ set GDBFLAGS ""
+ gdb_exit
+ gdb_start
+
+ gdb_test_no_output "set remote exec-file $binfile" \
+ "set remote exec-file"
+
+ # Make sure we're disconnected, in case we're testing with an
+ # extended-remote board, therefore already connected.
+ gdb_test "disconnect" ".*" "disconnect"
+
+ # Let's start gdbserver in extended-remote mode now. We cannot
+ # use gdbserver_start_extended here because it starts gdbserver,
+ # then GDB *with* a local binary, and the connect both.
+ set res [gdbserver_start "--multi" ""]
+ set gdbserver_protocol [lindex $res 0]
+ if { [string first "extended-" $gdbserver_protocol] != 0} {
+ set gdbserver_protocol "extended-$gdbserver_protocol"
+ }
+ set gdbserver_gdbport [lindex $res 1]
+ set use_gdb_stub 0
+
+ gdb_test "target ${gdbserver_protocol} ${gdbserver_gdbport}" \
+ "Remote debugging using $gdbserver_gdbport" \
+ "connect to gdbserver"
+
+ gdb_test "run" \
+ "\\\[Inferior $decimal \\\(process $decimal\\\) exited normally\\\]" \
+ "run test program until the end"
+}
diff --git a/gdb/testsuite/gdb.server/unittest.exp b/gdb/testsuite/gdb.server/unittest.exp
new file mode 100644
index 0000000..584a23d
--- /dev/null
+++ b/gdb/testsuite/gdb.server/unittest.exp
@@ -0,0 +1,41 @@
+# This testcase is part of GDB, the GNU debugger.
+
+# Copyright 2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+load_lib gdbserver-support.exp
+
+standard_testfile
+
+if { [skip_gdbserver_tests] } {
+ return 0
+}
+
+global server_spawn_id
+
+set gdbserver [find_gdbserver]
+set gdbserver_command "$gdbserver --selftest"
+
+set server_spawn_id [remote_spawn target $gdbserver_command]
+
+gdb_expect {
+ -i $server_spawn_id
+ -re "Ran $decimal unit tests, 0 failed" {
+ pass "unit tests"
+ }
+ default {
+ fail "unit tests"
+ }
+}
diff --git a/gdb/testsuite/gdb.threads/siginfo-threads.exp b/gdb/testsuite/gdb.threads/siginfo-threads.exp
index 328168c..8ee4c36 100644
--- a/gdb/testsuite/gdb.threads/siginfo-threads.exp
+++ b/gdb/testsuite/gdb.threads/siginfo-threads.exp
@@ -40,12 +40,17 @@ gdb_test "handle SIGUSR2 stop print pass" \
gdb_breakpoint [gdb_get_line_number "break-at-exit"]
set test "get pid"
-gdb_test_multiple "p getpid ()" $test {
+set pid ""
+gdb_test_multiple "p (int) getpid ()" $test {
-re " = (\[0-9\]+)\r\n$gdb_prompt $" {
set pid $expect_out(1,string)
pass $test
}
}
+if {$pid == ""} {
+ untested "failed to get pid"
+ return
+}
for {set sigcount 0} {$sigcount < 4} {incr sigcount} {
set test "catch signal $sigcount"
diff --git a/gdb/testsuite/gdb.threads/tls-nodebug-pie.c b/gdb/testsuite/gdb.threads/tls-nodebug-pie.c
new file mode 100644
index 0000000..c2f62f2
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/tls-nodebug-pie.c
@@ -0,0 +1,28 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2016-2017 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <pthread.h>
+
+__thread int thread_local = 42;
+
+int
+main (void)
+{
+ /* Ensure we link against pthreads even with --as-needed. */
+ pthread_testcancel ();
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.threads/tls-nodebug-pie.exp b/gdb/testsuite/gdb.threads/tls-nodebug-pie.exp
new file mode 100644
index 0000000..ca384a0
--- /dev/null
+++ b/gdb/testsuite/gdb.threads/tls-nodebug-pie.exp
@@ -0,0 +1,29 @@
+# Copyright 2016-2017 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+standard_testfile
+
+if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable \
+ [list "additional_flags=-fPIE -pie"]] != "" } {
+ return -1
+}
+
+clean_restart ${binfile}
+if ![runto_main] then {
+ return 0
+}
+
+# Formerly: Cannot access memory at address 0xffffef7c0698
+gdb_test "p (int) thread_local" " = 42" "thread local storage"
diff --git a/gdb/testsuite/gdb.threads/tls-nodebug.exp b/gdb/testsuite/gdb.threads/tls-nodebug.exp
index 8dc9444..e718736 100644
--- a/gdb/testsuite/gdb.threads/tls-nodebug.exp
+++ b/gdb/testsuite/gdb.threads/tls-nodebug.exp
@@ -33,7 +33,10 @@ if ![runto_main] then {
}
# Formerly: Cannot access memory at address 0x0
-gdb_test "p thread_local" "= 42" "thread local storage"
+gdb_test "p thread_local" "'thread_local' has unknown type; cast it to its declared type" \
+ "thread local storage, unknown type"
+gdb_test "p (int) thread_local" "= 42" \
+ "thread local storage, cast"
# Done!
#
diff --git a/gdb/testsuite/gdb.trace/entry-values.exp b/gdb/testsuite/gdb.trace/entry-values.exp
index b2650c6..baf9371 100644
--- a/gdb/testsuite/gdb.trace/entry-values.exp
+++ b/gdb/testsuite/gdb.trace/entry-values.exp
@@ -194,8 +194,8 @@ gdb_test_sequence "bt" "bt (1)" {
# Update global variables 'global1' and 'global2' and test that the
# entry values are updated too.
-gdb_test_no_output "set var global1=10"
-gdb_test_no_output "set var global2=11"
+gdb_test_no_output "set var *(int *) &global1=10"
+gdb_test_no_output "set var *(int *) &global2=11"
gdb_test_sequence "bt" "bt (2)" {
"\[\r\n\]#0 .* foo \\(i=[-]?[0-9]+, i@entry=10, j=[-]?[0-9]+, j@entry=11\\)"
@@ -226,7 +226,7 @@ gdb_test "trace foo" "Tracepoint $decimal at .*"
# argument j.
gdb_trace_setactions "set action for tracepoint 1" "" \
- "collect i, j, global1, \(\*\(void \*\*\) \(\$$spreg\)\) @ 128" "^$"
+ "collect i, j, (int) global1, \(\*\(void \*\*\) \(\$$spreg\)\) @ 128" "^$"
gdb_test_no_output "tstart"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 3d3eaab..48fec2f 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -370,6 +370,43 @@ proc gdb_start_cmd {args} {
return -1
}
+# Generic starti command. Return 0 if we could start the program, -1
+# if we could not.
+#
+# N.B. This function does not wait for gdb to return to the prompt,
+# that is the caller's responsibility.
+
+proc gdb_starti_cmd {args} {
+ global gdb_prompt use_gdb_stub
+
+ foreach command [gdb_init_commands] {
+ send_gdb "$command\n"
+ gdb_expect 30 {
+ -re "$gdb_prompt $" { }
+ default {
+ perror "gdb_init_command for target failed"
+ return -1
+ }
+ }
+ }
+
+ if $use_gdb_stub {
+ return -1
+ }
+
+ send_gdb "starti $args\n"
+ gdb_expect 60 {
+ -re "The program .* has been started already.*y or n. $" {
+ send_gdb "y\n"
+ exp_continue
+ }
+ -re "Starting program: \[^\r\n\]*" {
+ return 0
+ }
+ }
+ return -1
+}
+
# Set a breakpoint at FUNCTION. If there is an additional argument it is
# a list of options; the supported options are allow-pending, temporary,
# message, no-message, and passfail.
@@ -3368,6 +3405,34 @@ proc gdb_wrapper_init { args } {
set gdb_wrapper_target [current_target_name]
}
+# Determine options that we always want to pass to the compiler.
+gdb_caching_proc universal_compile_options {
+ set me "universal_compile_options"
+ set options {}
+
+ set src [standard_temp_file ccopts[pid].c]
+ set obj [standard_temp_file ccopts[pid].o]
+
+ gdb_produce_source $src {
+ int foo(void) { return 0; }
+ }
+
+ # Try an option for disabling colored diagnostics. Some compilers
+ # yield colored diagnostics by default (when run from a tty) unless
+ # such an option is specified.
+ set opt "additional_flags=-fdiagnostics-color=never"
+ set lines [target_compile $src $obj object [list "quiet" $opt]]
+ if [string match "" $lines] then {
+ # Seems to have worked; use the option.
+ lappend options $opt
+ }
+ file delete $src
+ file delete $obj
+
+ verbose "$me: returning $options" 2
+ return $options
+}
+
# Some targets need to always link a special object in. Save its path here.
global gdb_saved_set_unbuffered_mode_obj
set gdb_saved_set_unbuffered_mode_obj ""
@@ -3419,7 +3484,12 @@ proc gdb_compile {source dest type options} {
# Add platform-specific options if a shared library was specified using
# "shlib=librarypath" in OPTIONS.
- set new_options ""
+ if {[lsearch -exact $options rust] != -1} {
+ # -fdiagnostics-color is not a rustcc option.
+ } else {
+ set new_options [universal_compile_options]
+ }
+ set new_options {}
set shlib_found 0
set shlib_load 0
foreach opt $options {
@@ -5537,7 +5607,7 @@ proc get_valueof { fmt exp default {test ""} } {
set val ${default}
gdb_test_multiple "print${fmt} ${exp}" "$test" {
- -re "\\$\[0-9\]* = (.*)\[\r\n\]*$gdb_prompt $" {
+ -re "\\$\[0-9\]* = (\[^\r\n\]*)\[\r\n\]*$gdb_prompt $" {
set val $expect_out(1,string)
pass "$test ($val)"
}