void gdb_disassembly (struct gdbarch *gdbarch, struct ui_out *uiout, char *file_string, int flags, int how_many, CORE_ADDR low, CORE_ADDR high) { struct ui_file *stb = mem_fileopen (); struct cleanup *cleanups = make_cleanup_ui_file_delete (stb); struct disassemble_info di = gdb_disassemble_info (gdbarch, stb); struct symtab *symtab; struct linetable_entry *le = NULL; int nlines = -1; /* Assume symtab is valid for whole PC range. */ symtab = find_pc_line_symtab (low); if (symtab != NULL && SYMTAB_LINETABLE (symtab) != NULL) { /* Convert the linetable to a bunch of my_line_entry's. */ le = SYMTAB_LINETABLE (symtab)->item; nlines = SYMTAB_LINETABLE (symtab)->nitems; } if (!(flags & DISASSEMBLY_SOURCE) || nlines <= 0 || symtab == NULL || SYMTAB_LINETABLE (symtab) == NULL) do_assembly_only (gdbarch, uiout, &di, low, high, how_many, flags, stb); else if (flags & DISASSEMBLY_SOURCE) do_mixed_source_and_assembly (gdbarch, uiout, &di, nlines, le, low, high, symtab, how_many, flags, stb); do_cleanups (cleanups); gdb_flush (gdb_stdout); }
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 (SYMTAB_OBJFILE (s)); cleanup_stack = make_cleanup_ui_out_list_begin_end (uiout, "lines"); if (SYMTAB_LINETABLE (s) != NULL && SYMTAB_LINETABLE (s)->nitems > 0) for (i = 0; i < SYMTAB_LINETABLE (s)->nitems; i++) { cleanup_tuple = make_cleanup_ui_out_tuple_begin_end (uiout, NULL); uiout->field_core_addr ("pc", gdbarch, SYMTAB_LINETABLE (s)->item[i].pc); uiout->field_int ("line", SYMTAB_LINETABLE (s)->item[i].line); do_cleanups (cleanup_tuple); } do_cleanups (cleanup_stack); }