void mi_cmd_file_list_exec_source_file (char *command, char **argv, int argc) { struct symtab_and_line st; struct ui_out *uiout = current_uiout; if (!mi_valid_noargs ("-file-list-exec-source-file", argc, argv)) error (_("-file-list-exec-source-file: Usage: No args")); /* Set the default file and line, also get them. */ set_default_source_symtab_and_line (); st = get_current_source_symtab_and_line (); /* We should always get a symtab. Apparently, filename does not need to be tested for NULL. The documentation in symtab.h suggests it will always be correct. */ if (!st.symtab) error (_("-file-list-exec-source-file: No symtab")); /* Print to the user the line, filename and fullname. */ ui_out_field_int (uiout, "line", st.line); ui_out_field_string (uiout, "file", symtab_to_filename_for_display (st.symtab)); ui_out_field_string (uiout, "fullname", symtab_to_fullname (st.symtab)); ui_out_field_int (uiout, "macro-info", COMPUNIT_MACRO_TABLE (SYMTAB_COMPUNIT (st.symtab)) != NULL); }
struct macro_scope * sal_macro_scope (struct symtab_and_line sal) { struct macro_source_file *main_file, *inclusion; struct macro_scope *ms; struct compunit_symtab *cust; if (sal.symtab == NULL) return NULL; cust = SYMTAB_COMPUNIT (sal.symtab); if (COMPUNIT_MACRO_TABLE (cust) == NULL) return NULL; ms = XNEW (struct macro_scope); main_file = macro_main (COMPUNIT_MACRO_TABLE (cust)); inclusion = macro_lookup_inclusion (main_file, sal.symtab->filename); if (inclusion) { ms->file = inclusion; ms->line = sal.line; } else { /* There are, unfortunately, cases where a compilation unit can have a symtab for a source file that doesn't appear in the macro table. For example, at the moment, Dwarf doesn't have any way in the .debug_macinfo section to describe the effect of #line directives, so if you debug a YACC parser you'll get a macro table which only mentions the .c files generated by YACC, but symtabs that mention the .y files consumed by YACC. In the long run, we should extend the Dwarf macro info representation to handle #line directives, and get GCC to emit it. For the time being, though, we'll just treat these as occurring at the end of the main source file. */ ms->file = main_file; ms->line = -1; complaint (&symfile_complaints, _("symtab found for `%s', but that file\n" "is not covered in the compilation unit's macro information"), symtab_to_filename_for_display (sal.symtab)); } return ms; }
static PyObject * stpy_get_producer (PyObject *self, void *closure) { struct symtab *symtab = NULL; struct compunit_symtab *cust; STPY_REQUIRE_VALID (self, symtab); cust = SYMTAB_COMPUNIT (symtab); if (COMPUNIT_PRODUCER (cust) != NULL) { const char *producer = COMPUNIT_PRODUCER (cust); return host_string_to_python_string (producer); } Py_RETURN_NONE; }
static PyObject * stpy_get_producer (PyObject *self, void *closure) { struct symtab *symtab = NULL; struct compunit_symtab *cust; STPY_REQUIRE_VALID (self, symtab); cust = SYMTAB_COMPUNIT (symtab); if (COMPUNIT_PRODUCER (cust) != NULL) { const char *producer = COMPUNIT_PRODUCER (cust); return PyString_Decode (producer, strlen (producer), host_charset (), NULL); } Py_RETURN_NONE; }