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: RFA: fix PR python/13351


On 02/01/2012 04:04 PM, Tom Tromey wrote:

> I don't understand why get_selected_frame is the preferred API.  To me
> it seems clearly worse: passing in an error message is ugly, and it
> isn't really possible to distinguish "no frames" from "an exception was
> thrown for some other reason".  Neither of these problems would affect
> get_selected_frame_if_set.
> 
> Perhaps I can do the detection by checking has_stack_frames?  Is that safe?

Yes.  Though you could just call get_selected_block instead (which does the
has_stack_frames check).

       TRY_CATCH (except, RETURN_MASK_ALL)
 	{
-	  selected_frame = get_selected_frame (_("No frame selected."));
-	  block = get_frame_block (selected_frame, NULL);
+	  block = get_selected_block (NULL);
 	}
       GDB_PY_HANDLE_EXCEPTION (except);

-- 
Pedro Alves


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