Re: [RFC] -thread-info new command

Daniel Jacobowitz
2007-03-27T19:54:24Z

On Thu, Mar 22, 2007 at 09:09:15AM +1200, Nick Roberts wrote:
> I've gone through the archives to try to understand the changes. The above
> message says:
>
> Well we need to propagate the error message back to
> captured_mi_execute_command.
>
> Actually there are currently two ways to catch an error in MI:
>
> 1) Using error () and catch_exception.
>
> 2) Using MI_CMD_ERROR and mi_error_message.
>
> The first gets caught in mi_execute_command and the error message is stored
> in result.message. The second goes back to captured_mi_execute_command and
> the error message is manually stored in mi_error_message.
>
> I think that only one method should be used and this should be the first one.

Once upon a time there were supposed to be more things using "libgdb"
- these gdb_* wrapper functions. It didn't come to pass.

For now can we do the minimal fix for this problem? I apologize I was
never clear enough about what I meant when I said that, so here's a
patch. Before:

-break-insert *
&"Argument required (expression to compute).\n"
^done

After:

-break-insert *
&"Argument required (expression to compute).\n"
^error,msg="Argument required (expression to compute)."

I'm running the testsuite on this now.

--
Daniel Jacobowitz
CodeSourcery

2007-03-27 Daniel Jacobowitz <dan@codesourcery.com>

* breakpoint.c (gdb_breakpoint_query): Really return an
enum gdb_rc.
(gdb_breakpoint): Likewise.
* thread.c (do_captured_list_thread_ids): Likewise.
(do_captured_thread_select): Likewise.
* mi/mi-main.c (mi_cmd_thread_select): Expect an enum gdb_rc.
(mi_cmd_thread_list_ids): Remove bogus initialization.

Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.242
diff -u -p -r1.242 breakpoint.c
--- breakpoint.c 9 Mar 2007 16:20:42 -0000 1.242
+++ breakpoint.c 27 Mar 2007 19:51:50 -0000
@@ -3755,8 +3755,11 @@ gdb_breakpoint_query (struct ui_out *uio
args.bnum = bnum;
/* For the moment we don't trust print_one_breakpoint() to not throw
an error. */
- return catch_exceptions_with_msg (uiout, do_captured_breakpoint_query, &args,
- error_message, RETURN_MASK_ALL);
+ if (catch_exceptions_with_msg (uiout, do_captured_breakpoint_query, &args,
+ error_message, RETURN_MASK_ALL) < 0)
+ return GDB_RC_FAIL;
+ else
+ return GDB_RC_OK;
}

/* Return non-zero if B is user settable (breakpoints, watchpoints,
@@ -5598,8 +5601,11 @@ gdb_breakpoint (char *address, char *con
args.tempflag = tempflag;
args.thread = thread;
args.ignore_count = ignore_count;
- return catch_exceptions_with_msg (uiout, do_captured_breakpoint, &args,
- error_message, RETURN_MASK_ALL);
+ if (catch_exceptions_with_msg (uiout, do_captured_breakpoint, &args,
+ error_message, RETURN_MASK_ALL) < 0)
+ return GDB_RC_FAIL;
+ else
+ return GDB_RC_OK;
}

Index: thread.c
===================================================================
RCS file: /cvs/src/src/gdb/thread.c,v
retrieving revision 1.51
diff -u -p -r1.51 thread.c
--- thread.c 28 Feb 2007 17:35:01 -0000 1.51
+++ thread.c 27 Mar 2007 19:51:50 -0000
@@ -286,8 +286,10 @@ do_captured_list_thread_ids (struct ui_o
enum gdb_rc
gdb_list_thread_ids (struct ui_out *uiout, char **error_message)
{
- return catch_exceptions_with_msg (uiout, do_captured_list_thread_ids, NULL,
- error_message, RETURN_MASK_ALL);
+ if (catch_exceptions_with_msg (uiout, do_captured_list_thread_ids, NULL,
+ error_message, RETURN_MASK_ALL) < 0)
+ return GDB_RC_FAIL;
+ return GDB_RC_OK;
}

/* Load infrun state for the thread PID. */
@@ -707,8 +709,10 @@ do_captured_thread_select (struct ui_out
enum gdb_rc
gdb_thread_select (struct ui_out *uiout, char *tidstr, char **error_message)
{
- return catch_exceptions_with_msg (uiout, do_captured_thread_select, tidstr,
- error_message, RETURN_MASK_ALL);
+ if (catch_exceptions_with_msg (uiout, do_captured_thread_select, tidstr,
+ error_message, RETURN_MASK_ALL) < 0)
+ return GDB_RC_FAIL;
+ return GDB_RC_OK;
}

/* Commands with a prefix of `thread'. */
Index: mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.94
diff -u -p -r1.94 mi-main.c
--- mi/mi-main.c 3 Feb 2007 05:41:15 -0000 1.94
+++ mi/mi-main.c 27 Mar 2007 19:51:50 -0000
@@ -253,11 +253,7 @@ mi_cmd_thread_select (char *command, cha
else
rc = gdb_thread_select (uiout, argv[0], &mi_error_message);

- /* RC is enum gdb_rc if it is successful (>=0)
- enum return_reason if not (<0). */
- if ((int) rc < 0 && (enum return_reason) rc == RETURN_ERROR)
- return MI_CMD_ERROR;
- else if ((int) rc >= 0 && rc == GDB_RC_FAIL)
+ if (rc == GDB_RC_FAIL)
return MI_CMD_ERROR;
else
return MI_CMD_DONE;
@@ -266,7 +262,7 @@ mi_cmd_thread_select (char *command, cha
enum mi_cmd_result
mi_cmd_thread_list_ids (char *command, char **argv, int argc)
{
- enum gdb_rc rc = MI_CMD_DONE;
+ enum gdb_rc rc;

if (argc != 0)
{