📄 symmisc.c
字号:
: (TYPE_CODE (SYMBOL_TYPE (symbol)) == TYPE_CODE_STRUCT ? "struct" : "union")), SYMBOL_NAME (symbol)); type_print_1 (SYMBOL_TYPE (symbol), "", outfile, 1, depth); } fprintf (outfile, ";\n"); } else { if (SYMBOL_CLASS (symbol) == LOC_TYPEDEF) fprintf (outfile, "typedef "); if (SYMBOL_TYPE (symbol)) { /* Print details of types, except for enums where it's clutter. */ type_print_1 (SYMBOL_TYPE (symbol), SYMBOL_NAME (symbol), outfile, TYPE_CODE (SYMBOL_TYPE (symbol)) != TYPE_CODE_ENUM, depth); fprintf (outfile, "; "); } else fprintf (outfile, "%s ", SYMBOL_NAME (symbol)); switch (SYMBOL_CLASS (symbol)) { case LOC_CONST: fprintf (outfile, "const %ld (0x%lx),", SYMBOL_VALUE (symbol), SYMBOL_VALUE (symbol)); break; case LOC_CONST_BYTES: fprintf (outfile, "const %u hex bytes:", TYPE_LENGTH (SYMBOL_TYPE (symbol))); { unsigned i; for (i = 0; i < TYPE_LENGTH (SYMBOL_TYPE (symbol)); i++) fprintf (outfile, " %2x", (unsigned)SYMBOL_VALUE_BYTES (symbol) [i]); fprintf (outfile, ","); } break; case LOC_STATIC: fprintf (outfile, "static at 0x%x,", SYMBOL_VALUE_ADDRESS (symbol)); break; case LOC_REGISTER: fprintf (outfile, "register %ld,", SYMBOL_VALUE (symbol)); break; case LOC_ARG: if (SYMBOL_BASEREG_VALID (symbol)) { fprintf (outfile, "arg at 0x%lx from register %d,", SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol)); } else { fprintf (outfile, "arg at 0x%lx,", SYMBOL_VALUE (symbol)); } break; case LOC_LOCAL_ARG: if (SYMBOL_BASEREG_VALID (symbol)) { fprintf (outfile, "arg at offset 0x%lx from register %d,", SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol)); } else { fprintf (outfile, "arg at offset 0x%lx from fp,", SYMBOL_VALUE (symbol)); } case LOC_REF_ARG: fprintf (outfile, "reference arg at 0x%lx,", SYMBOL_VALUE (symbol)); break; case LOC_REGPARM: fprintf (outfile, "parameter register %ld,", SYMBOL_VALUE (symbol)); break; case LOC_LOCAL: if (SYMBOL_BASEREG_VALID (symbol)) { fprintf (outfile, "local at 0x%lx from register %d", SYMBOL_VALUE (symbol), SYMBOL_BASEREG (symbol)); } else { fprintf (outfile, "local at 0x%lx,", SYMBOL_VALUE (symbol)); } break; case LOC_TYPEDEF: break; case LOC_LABEL: fprintf (outfile, "label at 0x%lx", SYMBOL_VALUE_ADDRESS (symbol)); break; case LOC_BLOCK: fprintf (outfile, "block (object 0x%x) starting at 0x%x,", (unsigned int) SYMBOL_BLOCK_VALUE (symbol), BLOCK_START (SYMBOL_BLOCK_VALUE (symbol))); break; default: fprintf (outfile, "botched symbol class %x", SYMBOL_CLASS (symbol)); break; } } fprintf (outfile, "\n");}voidmaintenance_print_psymbols (args, from_tty) char *args; int from_tty;{ char **argv; FILE *outfile; struct cleanup *cleanups; char *symname = NULL; char *filename = DEV_TTY; struct objfile *objfile; struct partial_symtab *ps; dont_repeat (); if (args == NULL) { error ("print-psymbols takes an output file name and optional symbol file name"); } else if ((argv = buildargv (args)) == NULL) { nomem (0); } cleanups = make_cleanup (freeargv, (char *) argv); if (argv[0] != NULL) { filename = argv[0]; /* If a second arg is supplied, it is a source file name to match on */ if (argv[1] != NULL) { symname = argv[1]; } } filename = tilde_expand (filename); make_cleanup (free, filename); outfile = fopen (filename, "w"); if (outfile == 0) perror_with_name (filename); make_cleanup (fclose, outfile); immediate_quit++; ALL_PSYMTABS (objfile, ps) if (symname == NULL || (strcmp (symname, ps -> filename) == 0)) dump_psymtab (objfile, ps, outfile); immediate_quit--; do_cleanups (cleanups);}static voidprint_partial_symbol (p, count, what, outfile) struct partial_symbol *p; int count; char *what; FILE *outfile;{ fprintf_filtered (outfile, " %s partial symbols:\n", what); while (count-- > 0) { fprintf_filtered (outfile, " `%s', ", SYMBOL_NAME(p)); switch (SYMBOL_NAMESPACE (p)) { case UNDEF_NAMESPACE: fputs_filtered ("undefined namespace, ", outfile); break; case VAR_NAMESPACE: /* This is the usual thing -- don't print it */ break; case STRUCT_NAMESPACE: fputs_filtered ("struct namespace, ", outfile); break; case LABEL_NAMESPACE: fputs_filtered ("label namespace, ", outfile); break; default: fputs_filtered ("<invalid namespace>, ", outfile); break; } switch (SYMBOL_CLASS (p)) { case LOC_UNDEF: fputs_filtered ("undefined", outfile); break; case LOC_CONST: fputs_filtered ("constant int", outfile); break; case LOC_STATIC: fputs_filtered ("static", outfile); break; case LOC_REGISTER: fputs_filtered ("register", outfile); break; case LOC_ARG: fputs_filtered ("pass by value", outfile); break; case LOC_REF_ARG: fputs_filtered ("pass by reference", outfile); break; case LOC_REGPARM: fputs_filtered ("register parameter", outfile); break; case LOC_LOCAL: fputs_filtered ("stack parameter", outfile); break; case LOC_TYPEDEF: fputs_filtered ("type", outfile); break; case LOC_LABEL: fputs_filtered ("label", outfile); break; case LOC_BLOCK: fputs_filtered ("function", outfile); break; case LOC_CONST_BYTES: fputs_filtered ("constant bytes", outfile); break; case LOC_LOCAL_ARG: fputs_filtered ("shuffled arg", outfile); break; default: fputs_filtered ("<invalid location>", outfile); break; } fputs_filtered (", ", outfile); fprintf_filtered (outfile, "0x%x\n", SYMBOL_VALUE (p)); p++; }}voidmaintenance_print_msymbols (args, from_tty) char *args; int from_tty;{ char **argv; FILE *outfile; struct cleanup *cleanups; char *filename = DEV_TTY; char *symname = NULL; struct objfile *objfile; dont_repeat (); if (args == NULL) { error ("print-msymbols takes an output file name and optional symbol file name"); } else if ((argv = buildargv (args)) == NULL) { nomem (0); } cleanups = make_cleanup (freeargv, argv); if (argv[0] != NULL) { filename = argv[0]; /* If a second arg is supplied, it is a source file name to match on */ if (argv[1] != NULL) { symname = argv[1]; } } filename = tilde_expand (filename); make_cleanup (free, filename); outfile = fopen (filename, "w"); if (outfile == 0) perror_with_name (filename); make_cleanup (fclose, outfile); immediate_quit++; ALL_OBJFILES (objfile) if (symname == NULL || (strcmp (symname, objfile -> name) == 0)) dump_msymbols (objfile, outfile); immediate_quit--; fprintf_filtered (outfile, "\n\n"); do_cleanups (cleanups);}voidmaintenance_print_objfiles (ignore, from_tty) char *ignore; int from_tty;{ struct objfile *objfile; dont_repeat (); immediate_quit++; ALL_OBJFILES (objfile) dump_objfile (objfile); immediate_quit--;}/* Return the nexting depth of a block within other blocks in its symtab. */static intblock_depth (block) struct block *block;{ register int i = 0; while (block = BLOCK_SUPERBLOCK (block)) i++; return i;}#endif /* MAINTENANCE_CMDS *//* Increase the space allocated for LISTP, which is probably global_psymbol_list or static_psymbol_list. This space will eventually be freed in free_objfile(). */voidextend_psymbol_list (listp, objfile) register struct psymbol_allocation_list *listp; struct objfile *objfile;{ int new_size; if (listp->size == 0) { new_size = 255; listp->list = (struct partial_symbol *) xmmalloc (objfile -> md, new_size * sizeof (struct partial_symbol)); } else { new_size = listp->size * 2; listp->list = (struct partial_symbol *) xmrealloc (objfile -> md, (char *) listp->list, new_size * sizeof (struct partial_symbol)); } /* Next assumes we only went one over. Should be good if program works correctly */ listp->next = listp->list + listp->size; listp->size = new_size;}#ifdef DEBUG/* The work performed by this function is normally done by the macro ADD_PSYMBOL_TO_LIST defined in symfile.h. When debugging gdb, this function makes things easier. */voidadd_psymbol_to_list (name, namelength, namespace, class, listp, psymval) char *name; int namelength; enum namespace namespace; enum address_class class; struct psymbol_allocation_list *listp; unsigned long psymval;{ register struct partial_symbol *psym; if (listp -> next >= listp -> list + listp -> size) extend_psymbol_list (listp, objfile); psym = listp -> next++; SYMBOL_NAME (psym) = (char *) obstack_alloc (&objfile->psymbol_obstack, namelength + 1); memcpy (SYMBOL_NAME (psym), name, namelength); SYMBOL_NAME (psym)[namelength] = '\0'; SYMBOL_NAMESPACE (psym) = namespace; SYMBOL_CLASS (psym) = class; SYMBOL_VALUE (psym) = psymval;}/* The work performed by this function is normally done by the macro ADD_PSYMBOL_ADDR_TO_LIST defined in symfile.h. When debugging gdb, this function makes things easier. */voidadd_psymbol_addr_to_list (name, namelength, namespace, class, listp, psymval) char *name; int namelength; enum namespace namespace; enum address_class class; struct psymbol_allocation_list *listp; CORE_ADDR psymval;{ register struct partial_symbol *psym; if (listp -> next >= listp -> list + listp -> size) extend_psymbol_list (listp, objfile); psym = listp -> next++; SYMBOL_NAME (psym) = (char *) obstack_alloc (&objfile->psymbol_obstack, namelength + 1); memcpy (SYMBOL_NAME (psym), name, namelength); SYMBOL_NAME (psym)[namelength] = '\0'; SYMBOL_NAMESPACE (psym) = namespace; SYMBOL_CLASS (psym) = class; SYMBOL_VALUE_ADDRESS (psym) = psymval;}#endif /* DEBUG */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -