-# Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc.
+# Copyright (C) 2009-2019 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
# This file is part of the GDB testsuite. It tests the mechanism
# exposing convenience functions to Python.
-if $tracelevel then {
- strace $tracelevel
-}
-
load_lib gdb-python.exp
# Start with a fresh gdb.
"NormalError ()" "" \
"end" ""
+gdb_test_no_output "set python print-stack full"
gdb_test "print \$normalerror()" "Traceback.*File.*line 5.*in invoke.*RuntimeError.*This is a Normal Error.*" \
"Test a Runtime error. There should be a stack trace."
+
+gdb_py_test_multiple "input command-calling function" \
+ "python" "" \
+ "class CallCommand(gdb.Function):" "" \
+ " def __init__(self):" "" \
+ " gdb.Function.__init__(self, 'call_command')" "" \
+ " def invoke(self):" "" \
+ " return gdb.execute('print 1', to_string=True)" "" \
+ "CallCommand ()" "" \
+ "end" ""
+
+gdb_test_no_output "set var \$foo = \$call_command()" "setting a value from a function which executes a command."
+# There was a bug where GDB would segfault in the second call, so try calling again.
+gdb_test_no_output "set var \$foo = \$call_command()" "setting a value from a function which executes a command, again."