On Tuesday 19 February 2008 00:44:33 Nick Roberts wrote: > > > mi_info_threads is nearly the same function as thread_command. > > > > You probably meant info_threads_command? > > Yes. > > > > Can this be > > > used in a dual way just as -break-list uses breakpoint_1? > > > > I don't know -- I actually have no idea what magic makes breakpoint_1 to > > work both for MI and CLI. Do you happen to know? > > It just seems to be a kind of overloading where the output format of > functions like ui_out_field_string depends on the interpreter used (value > of uiout). Okay, I've tried to do that. Now, I'm using ui_out_text to ensure empty spaces between fields. breakpoint.c uses ui_out_table_begin_end, but I don't think the formatting that one produces is good here. > In cases where only one interpreter outputs anything > ui_out_is_mi_like_p is used. > > > > Also Denis Pilat has already proposed a patch for -thread-info: > > > http://sourceware.org/ml/gdb-patches/2007-03/msg00167.html > > > > I did not notice that. > > > > > > > > How does your patch compare? (assuming the problem of return type is solved > > > as has been done for thread_select). > > > > It appears that my patch: > > > > 1. Does not bother with making non-throwing function, as MI top-level can > > handle exceptions. > > > > 2. Allows to print information about all threads. > > I see. Denis also proposed something for -thread-list-all-threads > (http://sourceware.org/ml/gdb-patches/2007-03/msg00144.html) I think having one command is a bit better. > Do you not want to print the frame level? Probably not; this command is useful right after stop, when the level is always 0. > Also do you want to > catch errors in print_stack_frame? Yes, why not? A typical error is when we have a char* parameter pointing to something not very accessible, in which case I'd prefer print_stack_frame to catch this error, as opposed to -thread-info outright dying. > Rather than: > > + print_stack_frame (get_selected_frame (NULL), 0, LOCATION); > > Would it be better to use: > > + print_frame_info (get_selected_frame (NULL), 1, LOC_AND_ADDRESS, 0); > > ? > > Note that with MI (following the thread with Denis) that the address gets > printed anyway when print_stack_frame is used: > > args.print_what = ui_out_is_mi_like_p (uiout) ? LOC_AND_ADDRESS : print_what; Then, using LOC_AND_ADDRESS in print_stack_frame invocation will only be more clear, without affecting behaviour? But I guess it's better, indeed. > > > I don't know what problem of return type you refer to -- can you clarify? > > That, in Denis' patch, gdb_thread_info returns type enum gdb_rc but > catch_exceptions_with_msg returns type int. (just like gdb_breakpoint and > break_command_really did for a while). This problem does not exist in my patch, as catch_exceptions_with_msg is just not used. I attach the revised version of the patch, including docs. Eli, is the doc part OK? I intend to commit the code part in a week unless there are objections. - Volodya [gdb] Implement -thread-info. * gdb.h (mi_info_threads): Declare. * thread.c (mi_info_threads): New, extracted from info_threads_command and adjusted to work for CLI and MI. (info_threads_command): Use mi_info_threads. * mi/mi-cmds.c (mi_cmds): Specify a handler for -thread-info. * mi/mi-cmds.h (mi_cmd_thread_info): Declare. * mi/mi-main.c (mi_cmd_thread_info): New. (mi_cmd_list_features): Include 'thread-info'. [gdb/doc] * gdb.texinfo (Thread Commands): Document -thread-info. Remove -thread-list-all-threads.