From 61ff14c69a7cb2870f9dd2792690a1fbc8967f29 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Sun, 15 Mar 2009 09:19:40 +0000 Subject: gdb/ * stack.c (return_command ): New variables retval_expr and old_chain. Inline parse_and_eval to initialize retval_expr. Check RETVAL_EXPR for UNOP_CAST and set RETURN_TYPE to the RETURN_VALUE type if RETURN_TYPE is NULL. gdb/doc/ * gdb.texinfo (Returning): New description for missing debug info. gdb/testsuite/ * gdb.base/return-nodebug.exp, gdb.base/return-nodebug.c: New. --- gdb/stack.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'gdb/stack.c') diff --git a/gdb/stack.c b/gdb/stack.c index d0c872e..d0ea3bf 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1796,18 +1796,27 @@ return_command (char *retval_exp, int from_tty) message. */ if (retval_exp) { + struct expression *retval_expr = parse_expression (retval_exp); + struct cleanup *old_chain = make_cleanup (xfree, retval_expr); struct type *return_type = NULL; /* Compute the return value. Should the computation fail, this call throws an error. */ - return_value = parse_and_eval (retval_exp); + return_value = evaluate_expression (retval_expr); /* Cast return value to the return type of the function. Should the cast fail, this call throws an error. */ if (thisfun != NULL) return_type = TYPE_TARGET_TYPE (SYMBOL_TYPE (thisfun)); if (return_type == NULL) - return_type = builtin_type (get_frame_arch (thisframe))->builtin_int; + { + if (retval_expr->elts[0].opcode != UNOP_CAST) + error (_("Return value type not available for selected " + "stack frame.\n" + "Please use an explicit cast of the value to return.")); + return_type = value_type (return_value); + } + do_cleanups (old_chain); CHECK_TYPEDEF (return_type); return_value = value_cast (return_type, return_value); -- cgit v1.1