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]

[PATCH] Fix MI -symbol-list-lines


Please consider this patch, which fixes -symbol-list-lines in situations
where a symbol table is only partially loaded and situations where more
than one symbol table corresponds to a given file.

Regards,
Jason



diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c
index 2fdea91..dd1a786 100644
--- a/gdb/mi/mi-symbol-cmds.c
+++ b/gdb/mi/mi-symbol-cmds.c
@@ -29,37 +29,54 @@
 void
 mi_cmd_symbol_list_lines (char *command, char **argv, int argc)
 {
-  struct gdbarch *gdbarch;
-  char *filename;
-  struct symtab *s;
-  int i;
-  struct cleanup *cleanup_stack, *cleanup_tuple;
-  struct ui_out *uiout = current_uiout;
-
-  if (argc != 1)
-    error (_("-symbol-list-lines: Usage: SOURCE_FILENAME"));
-
-  filename = argv[0];
-  s = lookup_symtab (filename);
-
-  if (s == NULL)
-    error (_("-symbol-list-lines: Unknown source file name."));
-
-  /* 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.  */
-
-  gdbarch = get_objfile_arch (s->objfile);
-  cleanup_stack = make_cleanup_ui_out_list_begin_end (uiout, "lines");
-
-  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", gdbarch, LINETABLE
(s)->item[i].pc);
-      ui_out_field_int (uiout, "line", LINETABLE (s)->item[i].line);
-      do_cleanups (cleanup_tuple);
+    struct gdbarch *gdbarch;
+    char *filename;
+    struct symtab *s;
+    int i;
+    struct cleanup *cleanup_stack, *cleanup_tuple;
+    struct ui_out *uiout = current_uiout;
+    struct program_space   *pspace      = 0;
+    struct objfile         *objfile     = 0;
+
+
+    if (argc != 1)
+        error (_("-symbol-list-lines: Usage: SOURCE_FILENAME"));
+
+    filename = argv[0];
+    s = lookup_symtab (filename);
+
+    if (s == NULL)
+        error (_("-symbol-list-lines: Unknown source file name."));
+
+    /*  This creates the "demand" for a symbol table associated with
+     *  "filename".  Although we do not use 's', this is an important
+     *  step because it forces and partial symbol tables associated
+     *  with "filename" to be expanded into full symbol tables.
+     */
+    find_line_symtab(s, 1, NULL, NULL);
+
+    /* 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.  */
+
+    gdbarch = get_objfile_arch (s->objfile);
+    cleanup_stack = make_cleanup_ui_out_list_begin_end (uiout, "lines");
+
+    pspace = current_program_space;
+
+    ALL_PSPACE_SYMTABS (pspace, objfile, s) {
+        if (strlen(filename) && strlen(s->filename) &&
+                !strcmp(lbasename(filename), lbasename(s->filename))) {
+            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", gdbarch,
LINETABLE (s)->item[i].pc);
+                    ui_out_field_int (uiout, "line", LINETABLE
(s)->item[i].line);
+                    do_cleanups (cleanup_tuple);
+                }
+            }
     }

-  do_cleanups (cleanup_stack);
+    do_cleanups (cleanup_stack);
 }




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