Index: mi-cmds.h =================================================================== RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v retrieving revision 1.7 diff -c -3 -p -r1.7 mi-cmds.h *** mi-cmds.h 6 Feb 2003 01:19:12 -0000 1.7 --- mi-cmds.h 10 Mar 2003 00:21:50 -0000 *************** extern mi_cmd_argv_ftype mi_cmd_stack_li *** 87,92 **** --- 87,93 ---- extern mi_cmd_argv_ftype mi_cmd_stack_list_frames; extern mi_cmd_argv_ftype mi_cmd_stack_list_locals; extern mi_cmd_argv_ftype mi_cmd_stack_select_frame; + extern mi_cmd_argv_ftype mi_cmd_symbol_info_linetable; extern mi_cmd_args_ftype mi_cmd_target_download; extern mi_cmd_args_ftype mi_cmd_target_select; extern mi_cmd_argv_ftype mi_cmd_thread_list_ids; Index: mi-cmds.c =================================================================== RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v retrieving revision 1.10 diff -c -3 -p -r1.10 mi-cmds.c *** mi-cmds.c 6 Feb 2003 01:19:12 -0000 1.10 --- mi-cmds.c 10 Mar 2003 00:21:50 -0000 *************** struct mi_cmd mi_cmds[] = *** 116,121 **** --- 116,122 ---- {"symbol-info-file", 0, 0}, {"symbol-info-function", 0, 0}, {"symbol-info-line", 0, 0}, + {"symbol-info-linetable", 0, 0, mi_cmd_symbol_info_linetable}, {"symbol-info-symbol", 0, 0}, {"symbol-list-functions", 0, 0}, {"symbol-list-types", 0, 0}, Index: mi-main.c =================================================================== RCS file: /cvs/src/src/gdb/mi/mi-main.c,v retrieving revision 1.41 diff -c -3 -p -r1.41 mi-main.c *** mi-main.c 1 Mar 2003 17:03:19 -0000 1.41 --- mi-main.c 10 Mar 2003 00:21:50 -0000 *************** mi_cmd_data_write_memory (char *command, *** 1070,1075 **** --- 1070,1127 ---- return MI_CMD_DONE; } + /* SYMBOL-INFO-LINETABLE: + + Print the table of all pc addresses and lines of code for + the provided (full or base) source file name. The entries + are sorted in ascending PC order. */ + + enum mi_cmd_result + mi_cmd_symbol_info_linetable (char *command, char **argv, int argc) + { + char *filename; + struct symtab *s; + int i; + struct cleanup *cleanup_stack, *cleanup_tuple; + + if (argc != 1) + { + xasprintf (&mi_error_message, + "Usage: %s filename.", command); + return MI_CMD_ERROR; + } + + filename = argv[0]; + + s = lookup_symtab (filename); + + if (s == NULL) + { + xasprintf (&mi_error_message, + "Unknown source file: '%s'", filename); + return MI_CMD_ERROR; + } + + /* Now, dump the associated line table. The pc addresses are already + sorted by increasing values in the symbol table, so no need to + perform any other sorting. */ + + cleanup_stack = make_cleanup_ui_out_list_begin_end (uiout, "linetable"); + + if (LINETABLE (s) != NULL && LINETABLE (s)->nitems > 0) + for (i = 0; i < LINETABLE (s)->nitems; i++) + { + cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); + ui_out_field_core_addr (uiout, "pc", LINETABLE (s)->item[i].pc); + ui_out_field_int (uiout, "line", LINETABLE (s)->item[i].line); + do_cleanups (cleanup_tuple); + } + + do_cleanups (cleanup_stack); + + return MI_CMD_DONE; + } + /* Execute a command within a safe environment. Return <0 for error; >=0 for ok.