This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR mi/2086 -break-insert missing error diagnostic


 > > OK, how about just using the hack in mi_cmd_thread_select for
 > > mi_cmd_break_insert for the moment.
 > 
 > This is just nasty.  I believe I pointed you at Ulrich's analysis of
 > this problem upthread:
 > 
 >   http://sources.redhat.com/ml/gdb/2006-10/msg00021.html
 > 
 > It seems pretty clear to me that the patch which switched things to
 > return the result of catch_exceptions_with_msg was wrong.  The
 > functions are defined to return an enum gdb_rc.  Can't we make
 > them do that again?  Simple, obviously correct.

Well we need to propagate the error message back to
captured_mi_execute_command.  The best I can do is create a new function
catch_errors_with_msg (gdb_breakpoint used catch_errors previously).  We can
also change mi_cmd_thread_list_ids accordingly.  Also do_captured_breakpoint,
do_captured_breakpoint_query, do_captured_thread_select and
do_captured_list_thread_ids should really be type enum gdb_rc.

-- 
Nick                                           http://www.inet.net.nz/~nickrob**


*** exceptions.h	22 Sep 2006 10:00:57 +1200	1.19
--- exceptions.h	19 Nov 2006 17:09:58 +1300	
***************
*** 227,236 ****
     indication of the exact exception that it caught - quit_flag might
     help.
  
!    This function is superseeded by catch_exceptions().  */
  
  typedef int (catch_errors_ftype) (void *);
  extern int catch_errors (catch_errors_ftype *, void *, char *, return_mask);
  
  /* Template to catch_errors() that wraps calls to command
     functions. */
--- 227,238 ----
     indication of the exact exception that it caught - quit_flag might
     help.
  
!    This function is superseded by catch_exceptions().  */
  
  typedef int (catch_errors_ftype) (void *);
  extern int catch_errors (catch_errors_ftype *, void *, char *, return_mask);
+ extern int catch_errors_with_msg (catch_errors_ftype *, void *, char *,
+ 				  char **, return_mask);
  
  /* Template to catch_errors() that wraps calls to command
     functions. */


*** exceptions.c	04 Feb 2006 10:50:25 +1300	1.24
--- exceptions.c	19 Nov 2006 17:00:36 +1300	
***************
*** 508,513 ****
--- 508,520 ----
  catch_errors (catch_errors_ftype *func, void *func_args, char *errstring,
  	      return_mask mask)
  {
+   return catch_errors_with_msg (func, func_args, errstring, NULL, mask);
+ }
+ 
+ int
+ catch_errors_with_msg (catch_errors_ftype *func, void *func_args, char *errstring,
+ 		       char **gdberrmsg, return_mask mask)
+ {
    volatile int val = 0;
    volatile struct gdb_exception exception;
    TRY_CATCH (exception, mask)
***************
*** 516,522 ****
      }
    print_any_exception (gdb_stderr, errstring, exception);
    if (exception.reason != 0)
!     return 0;
    return val;
  }
  
--- 523,541 ----
      }
    print_any_exception (gdb_stderr, errstring, exception);
    if (exception.reason != 0)
!     {
!       /* If caller wants a copy of the low-level error message, make
! 	 one.  This is used in the case of a silent error whereby the
! 	 caller may optionally want to issue the message.  */
!       if (gdberrmsg != NULL)
! 	{
! 	  if (exception.message != NULL)
! 	    *gdberrmsg = xstrdup (exception.message);
! 	  else
! 	    *gdberrmsg = NULL;
! 	}
!       return 0;
!     }
    return val;
  }
  

*** breakpoint.c	23 Oct 2006 08:48:48 +1300	1.231
--- breakpoint.c	19 Nov 2006 17:19:52 +1300	
***************
*** 3615,3621 ****
    };
  
  static int
! do_captured_breakpoint_query (struct ui_out *uiout, void *data)
  {
    struct captured_breakpoint_query_args *args = data;
    struct breakpoint *b;
--- 3615,3621 ----
    };
  
  static int
! do_captured_breakpoint_query (void *data)
  {
    struct captured_breakpoint_query_args *args = data;
    struct breakpoint *b;
***************
*** 3632,3645 ****
  }
  
  enum gdb_rc
! gdb_breakpoint_query (struct ui_out *uiout, int bnum, char **error_message)
  {
    struct captured_breakpoint_query_args args;
    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);
  }
  
  /* Return non-zero if B is user settable (breakpoints, watchpoints,
--- 3632,3645 ----
  }
  
  enum gdb_rc
! gdb_breakpoint_query (int bnum, char **error_message)
  {
    struct captured_breakpoint_query_args args;
    args.bnum = bnum;
    /* For the moment we don't trust print_one_breakpoint() to not throw
       an error. */
!   return catch_errors_with_msg (do_captured_breakpoint_query, &args, NULL,
! 				error_message, RETURN_MASK_ALL);
  }
  
  /* Return non-zero if B is user settable (breakpoints, watchpoints,
***************
*** 5373,5379 ****
    };
  
  static int
! do_captured_breakpoint (struct ui_out *uiout, void *data)
  {
    struct captured_breakpoint_args *args = data;
    struct symtabs_and_lines sals;
--- 5373,5379 ----
    };
  
  static int
! do_captured_breakpoint (void *data)
  {
    struct captured_breakpoint_args *args = data;
    struct symtabs_and_lines sals;
***************
*** 5481,5488 ****
    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);
  }
  
  
--- 5481,5488 ----
    args.tempflag = tempflag;
    args.thread = thread;
    args.ignore_count = ignore_count;
!   return catch_errors_with_msg (do_captured_breakpoint, &args,
! 				NULL, error_message, RETURN_MASK_ALL);
  }


*** mi-cmd-break.c	24 Dec 2005 07:57:46 +1300	1.13
--- mi-cmd-break.c	19 Nov 2006 17:31:58 +1300	
***************
*** 39,45 ****
  static void
  breakpoint_notify (int b)
  {
!   gdb_breakpoint_query (uiout, b, NULL);
  }
  
  
--- 39,45 ----
  static void
  breakpoint_notify (int b)
  {
!   gdb_breakpoint_query (b, NULL);
  }


*** mi-main.c	18 Nov 2006 19:13:33 +1300	1.86
--- mi-main.c	19 Nov 2006 14:17:16 +1300	
***************
*** 234,244 ****
    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)
      return MI_CMD_ERROR;
    else
      return MI_CMD_DONE;
--- 234,240 ----
    else
      rc = gdb_thread_select (uiout, argv[0], &mi_error_message);
  
!   if (rc == GDB_RC_FAIL)
      return MI_CMD_ERROR;
    else
      return MI_CMD_DONE;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]