42 #include "timeval-utils.h"
89 "the name of a maintenance command.\n"));
97 if (
query (
_(
"Should GDB dump core? ")))
101 signal (SIGABRT, SIG_DFL);
102 kill (getpid (), SIGABRT);
104 signal (SIGQUIT, SIG_DFL);
105 kill (getpid (), SIGQUIT);
119 internal_error (__FILE__, __LINE__,
"%s", (args == NULL ?
"" : args));
155 if (args == NULL || *args ==
'\0')
164 if (args == NULL || *args ==
'\0')
178 "by the name of an info command.\n"));
188 int substr_len = strlen(substr);
191 while ((tok = strstr (
string, substr)) != NULL)
199 if (tok[substr_len] ==
' '
200 || tok[substr_len] ==
'\t'
201 || tok[substr_len] ==
'\0')
216 if (flags & SEC_ALLOC)
219 if (flags & SEC_LOAD)
222 if (flags & SEC_RELOC)
225 if (flags & SEC_READONLY)
228 if (flags & SEC_CODE)
231 if (flags & SEC_DATA)
237 if (flags & SEC_CONSTRUCTOR)
240 if (flags & SEC_HAS_CONTENTS)
243 if (flags & SEC_NEVER_LOAD)
246 if (flags & SEC_COFF_SHARED_LIBRARY)
249 if (flags & SEC_IS_COMMON)
259 if (flags & SEC_ALLOC)
261 if (flags & SEC_LOAD)
263 if (flags & SEC_RELOC)
265 if (flags & SEC_READONLY)
267 if (flags & SEC_CODE)
269 if (flags & SEC_DATA)
273 if (flags & SEC_CONSTRUCTOR)
275 if (flags & SEC_HAS_CONTENTS)
277 if (flags & SEC_NEVER_LOAD)
279 if (flags & SEC_COFF_SHARED_LIBRARY)
281 if (flags & SEC_IS_COMMON)
288 unsigned long filepos,
int addr_size)
304 flagword
flags = bfd_get_section_flags (abfd, asect);
305 const char *
name = bfd_section_name (abfd, asect);
306 const char *arg = datum;
308 if (arg == NULL || *arg ==
'\0'
316 addr = bfd_section_vma (abfd, asect);
317 endaddr = addr + bfd_section_size (abfd, asect);
320 asect->filepos, addr_size);
332 if (
string == NULL || *
string ==
'\0'
365 if (strcmp (arg,
"ALLOBJ") == 0)
371 bfd_get_filename (ofile->
obfd));
427 "by the name of a print command.\n"));
446 if (arg == NULL || *arg == 0)
447 error (
_(
"requires argument (address or section + address)"));
454 while (*p && !isspace (*p))
457 error (
_(
"Need to specify <section-name> and <address>"));
468 error (
_(
"Unknown section %s."), arg);
481 const char *symbol_offset
487 const char *section_name;
488 const char *obj_name;
498 symbol_name, symbol_offset,
499 section_name, obj_name);
502 symbol_name, symbol_offset, section_name);
524 if (args == NULL || *args ==
'\0')
527 the command you want to deprecate, and optionally the replacement command\n\
528 enclosed in quotes.\n"));
539 if (args == NULL || *args ==
'\0')
542 the command you want to undeprecate.\n"));
563 char *start_ptr = NULL;
564 char *end_ptr = NULL;
580 start_ptr = strchr (text,
'\"');
581 if (start_ptr != NULL)
584 end_ptr = strrchr (start_ptr,
'\"');
587 len = end_ptr - start_ptr;
588 start_ptr[
len] =
'\0';
589 replacement = xstrdup (start_ptr);
594 if (!start_ptr || !end_ptr)
653 "by the name of a set command.\n"));
676 #define TEXTEND &_etext
677 #elif defined (HAVE_ETEXT)
679 #define TEXTEND &etext
682 #if defined (HAVE_MONSTARTUP) && defined (HAVE__MCLEANUP) && defined (TEXTEND)
702 if (maintenance_profile_p == profiling_state)
707 if (maintenance_profile_p)
709 static int profiling_initialized;
711 if (!profiling_initialized)
714 profiling_initialized = 1;
733 error (
_(
"Profiling support is not available on this system."));
785 per_command_time = new_value;
794 per_command_space = new_value;
807 int nr_compunit_symtabs = 0;
817 ++nr_compunit_symtabs;
824 *nr_symtabs_ptr = nr_symtabs;
825 *nr_compunit_symtabs_ptr = nr_compunit_symtabs;
826 *nr_blocks_ptr = nr_blocks;
843 struct timeval now_wall_time, delta_wall_time, wait_time;
845 gettimeofday (&now_wall_time, NULL);
846 timeval_sub (&delta_wall_time,
851 timeval_sub (&delta_wall_time, &delta_wall_time, &wait_time);
854 ?
_(
"Startup time: %ld.%06ld (cpu), %ld.%06ld (wall)\n")
855 :
_(
"Command execution time: %ld.%06ld (cpu), %ld.%06ld (wall)\n"),
856 cmd_time / 1000000, cmd_time % 1000000,
857 (
long) delta_wall_time.tv_sec,
858 (
long) delta_wall_time.tv_usec);
864 char *lim = (
char *) sbrk (0);
867 long space_diff = space_now - start_stats->
start_space;
870 ?
_(
"Space used: %ld (%s%ld during startup)\n")
871 :
_(
"Space used: %ld (%s%ld for this command)\n"),
873 (space_diff >= 0 ?
"+" :
""),
880 int nr_symtabs, nr_compunit_symtabs, nr_blocks;
884 " #compunits: %d (+%d),"
885 " #blocks: %d (+%d)\n"),
913 && !per_command_space
914 && !per_command_symtab)
921 if (msg_type == 0 || per_command_space)
924 char *lim = (
char *) sbrk (0);
930 if (msg_type == 0 || per_command_time)
937 if (msg_type == 0 || per_command_symtab)
939 int nr_symtabs, nr_compunit_symtabs, nr_blocks;
966 error (
_(
"Bad value for 'mt set per-command no'."));
968 for (list = per_command_setlist; list != NULL; list = list->
next)
991 Commands for use by GDB maintainers.\n\
992 Includes commands to dump specific internal GDB structures in\n\
993 a human readable form, to cause GDB to deliberately dump core, etc."),
1000 Commands for showing internal info about the program being debugged."),
1006 List the BFD sections of the exec and core files. \n\
1007 Arguments may be any combination of:\n\
1008 [one or more section names]\n\
1009 ALLOC LOAD RELOC READONLY CODE DATA ROM CONSTRUCTOR\n\
1010 HAS_CONTENTS NEVER_LOAD COFF_SHARED_LIBRARY IS_COMMON\n\
1011 Sections matching any argument will be listed (no argument\n\
1012 implies all sections). In addition, the special argument\n\
1014 lists all sections from all object files, including shared libraries."),
1018 _(
"Maintenance command for printing GDB internal state."),
1023 Set GDB internal variables used by the GDB maintainer.\n\
1024 Configure variables internal to GDB that aid in GDB's maintenance"),
1025 &maintenance_set_cmdlist,
"maintenance set ",
1030 Show GDB internal variables used by the GDB maintainer.\n\
1031 Configure variables internal to GDB that aid in GDB's maintenance"),
1032 &maintenance_show_cmdlist,
"maintenance show ",
1038 Get fatal error; make debugger dump its core.\n\
1039 GDB sets its handling of SIGQUIT back to SIG_DFL and then sends\n\
1040 itself a SIGQUIT signal."),
1046 Give GDB an internal error.\n\
1047 Cause GDB to behave as if an internal error was detected."),
1052 Give GDB an internal warning.\n\
1053 Cause GDB to behave as if an internal warning was reported."),
1058 Give GDB a demangler warning.\n\
1059 Cause GDB to behave as if a demangler warning was reported."),
1063 This command has been moved to \"demangle\"."),
1068 Per-command statistics settings."),
1069 &per_command_setlist,
"set per-command ",
1070 1, &maintenance_set_cmdlist);
1073 Show per-command statistics settings."),
1074 &per_command_showlist,
"show per-command ",
1075 0, &maintenance_show_cmdlist);
1078 &per_command_time,
_(
"\
1079 Set whether to display per-command execution time."),
_(
"\
1080 Show whether to display per-command execution time."),
1082 If enabled, the execution time for each command will be\n\
1083 displayed following the command's output."),
1085 &per_command_setlist, &per_command_showlist);
1088 &per_command_space,
_(
"\
1089 Set whether to display per-command space usage."),
_(
"\
1090 Show whether to display per-command space usage."),
1092 If enabled, the space usage for each command will be\n\
1093 displayed following the command's output."),
1095 &per_command_setlist, &per_command_showlist);
1098 &per_command_symtab,
_(
"\
1099 Set whether to display per-command symtab statistics."),
_(
"\
1100 Show whether to display per-command symtab statistics."),
1102 If enabled, the basic symtab statistics for each command will be\n\
1103 displayed following the command's output."),
1105 &per_command_setlist, &per_command_showlist);
1110 Set the display of time usage.\n\
1111 If nonzero, will cause the execution time for each command to be\n\
1112 displayed, following the command's output."),
1118 Set the display of space usage.\n\
1119 If nonzero, will cause the execution space for each command to be\n\
1120 displayed, following the command's output."),
1124 Print a type chain for a given symbol.\n\
1125 For each node in a type chain, print the raw data for each member of\n\
1126 the type structure, and the interpretation of the data."),
1130 _(
"Print statistics about internal gdb state."),
1135 Print the internal architecture configuration.\n\
1136 Takes an optional file parameter."),
1141 _(
"Translate a section name and address to a symbol."),
1145 Deprecate a command. Note that this is just in here so the \n\
1146 testsuite can check the command deprecator. You probably shouldn't use this,\n\
1147 rather you should use the C function deprecate_cmd(). If you decide you \n\
1148 want to use it: maintenance deprecate 'commandname' \"replacement\". The \n\
1152 Undeprecate a command. Note that this is just in here so the \n\
1153 testsuite can check the command deprecator. You probably shouldn't use this,\n\
1154 If you decide you want to use it: maintenance undeprecate 'commandname'"),
1158 Set watchdog timer."),
_(
"\
1159 Show watchdog timer."),
_(
"\
1160 When non-zero, this timeout is used instead of waiting forever for a target\n\
1161 to finish a low-level step or continue operation. If the specified amount\n\
1162 of time passes without a response from the target, an error occurs."),
1168 &maintenance_profile_p,
_(
"\
1169 Set internal profiling."),
_(
"\
1170 Show internal profiling."),
_(
"\
1171 When enabled GDB is profiled."),
1174 &maintenance_set_cmdlist,
1175 &maintenance_show_cmdlist);
struct timeval start_wall_time
unsigned int deprecated_warn_user
char * hex_string(LONGEST num)
static void maintenance_space_display(char *, int)
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc, struct cmd_list_element **prefixlist, const char *prefixname, int allow_unknown, struct cmd_list_element **list)
struct cmd_list_element * next
struct bound_minimal_symbol lookup_minimal_symbol_by_pc_section(CORE_ADDR pc, struct obj_section *section)
static int per_command_symtab
int parse_cli_boolean_value(const char *arg)
static void maintenance_internal_warning(char *args, int from_tty)
void add_setshow_zinteger_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
void maintenance_print_type(char *, int)
unsigned int cmd_deprecated
int gdb_bfd_section_index(bfd *abfd, asection *section)
static int per_command_space
static void maintenance_set_profile_cmd(char *args, int from_tty, struct cmd_list_element *c)
__extension__ enum cmd_types type
int start_nr_compunit_symtabs
struct bfd_section * the_bfd_section
#define BMSYMBOL_VALUE_ADDRESS(symbol)
struct cmd_list_element * deprecate_cmd(struct cmd_list_element *cmd, const char *replacement)
int query(const char *ctlstr,...)
EXTERN_C void monstartup(unsigned long, unsigned long)
static void maintenance_print_statistics(char *args, int from_tty)
static struct cmd_list_element * per_command_setlist
struct cmd_list_element * maintenanceinfolist
struct ui_file * gdb_stdout
static void maintenance_print_architecture(char *args, int from_tty)
struct ui_file * gdb_fopen(const char *name, const char *mode)
void internal_error(const char *file, int line, const char *fmt,...)
#define obj_section_endaddr(s)
static void maintenance_info_sections(char *, int)
#define ALL_OBJSECTIONS(objfile, osect)
#define ALL_OBJFILE_OSECTIONS(objfile, osect)
void set_per_command_time(int new_value)
static struct cmd_list_element * per_command_showlist
struct cmd_list_element * cmdlist
static void show_watchdog(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void maintenance_translate_address(char *arg, int from_tty)
char * skip_spaces(char *chp)
void demangler_warning(const char *file, int line, const char *string,...)
static void print_objfile_section_info(bfd *abfd, struct obj_section *asect, const char *string)
static void maintenance_deprecate(char *args, int from_tty)
int lookup_cmd_composition(const char *text, struct cmd_list_element **alias, struct cmd_list_element **prefix_cmd, struct cmd_list_element **cmd)
static void show_maintenance_profile_p(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
void printf_filtered(const char *format,...)
#define obj_section_addr(s)
#define MSYMBOL_OBJ_SECTION(objfile, symbol)
mach_port_t kern_return_t mach_port_t msgports mach_port_t kern_return_t pid_t pid mach_port_t kern_return_t mach_port_t task mach_port_t kern_return_t int flags
void null_cleanup(void *arg)
EXTERN_C void _mcleanup(void)
static void maintenance_print_command(char *, int)
#define MSYMBOL_PRINT_NAME(symbol)
static void maintenance_info_command(char *, int)
struct cmd_list_element * setlist
#define ALL_OBJFILES(obj)
void _initialize_maint_cmds(void)
struct cleanup * make_cleanup_dtor(make_cleanup_ftype *function, void *arg, make_cleanup_dtor_ftype *dtor)
static void maintenance_set_cmd(char *args, int from_tty)
void reset_prompt_for_continue_wait_time(void)
void fprintf_filtered(struct ui_file *stream, const char *format,...)
static void maintenance_internal_error(char *args, int from_tty)
static void mcleanup_wrapper(void)
struct cmd_list_element * showlist
struct cmd_list_element * add_com_alias(const char *name, const char *oldname, enum command_class theclass, int abbrev_flag)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, cmd_cfunc_ftype *fun, const char *doc, struct cmd_list_element **list)
__extension__ enum var_types var_type
struct cleanup * make_cleanup(make_cleanup_ftype *function, void *arg)
char * pulongest(ULONGEST u)
#define ALL_COMPUNITS(objfile, cu)
static void print_bfd_section_info(bfd *abfd, asection *asect, void *datum)
struct gdbarch * get_current_arch(void)
static void print_bfd_flags(flagword flags)
static void report_command_stats(void *arg)
struct cmd_list_element * maintenance_set_cmdlist
struct cmd_list_element * add_alias_cmd(const char *name, const char *oldname, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
int gdbarch_addr_bit(struct gdbarch *gdbarch)
static void maintenance_dump_me(char *args, int from_tty)
static void maintenance_demangler_warning(char *args, int from_tty)
void wrap_here(char *indent)
void printf_unfiltered(const char *format,...)
static int match_substring(const char *string, const char *substr)
const char * objfile_name(const struct objfile *objfile)
struct cmd_list_element * maintenanceprintlist
void cmd_show_list(struct cmd_list_element *list, int from_tty, const char *prefix)
static void maintenance_time_display(char *, int)
static void show_per_command_cmd(char *args, int from_tty)
#define COMPUNIT_BLOCKVECTOR(cust)
static int per_command_time
struct gdbarch * gdbarch_from_bfd(bfd *abfd)
void help_list(struct cmd_list_element *list, const char *cmdtype, enum command_class theclass, struct ui_file *stream)
char * hex_string_custom(LONGEST num, int width)
static void maintenance_command(char *, int)
void void void void void void void void void perror_with_name(const char *string) ATTRIBUTE_NORETURN
struct bound_minimal_symbol lookup_minimal_symbol_by_pc(CORE_ADDR pc)
static int maintenance_profile_p
struct cleanup * make_command_stats_cleanup(int msg_type)
struct cmd_list_element * maintenance_show_cmdlist
struct cleanup * make_cleanup_ui_file_delete(struct ui_file *arg)
CORE_ADDR parse_and_eval_address(const char *exp)
struct minimal_symbol * minsym
void print_objfile_statistics(void)
#define BLOCKVECTOR_NBLOCKS(blocklist)
static void set_per_command_cmd(char *args, int from_tty)
struct program_space * current_program_space
static void maintenance_show_cmd(char *args, int from_tty)
void do_set_command(const char *arg, int from_tty, struct cmd_list_element *c)
void set_per_command_space(int new_value)
struct cmd_list_element * maintenancelist
static int profiling_state
void gdbarch_dump(struct gdbarch *gdbarch, struct ui_file *file)
#define ALL_COMPUNIT_FILETABS(cu, s)
static void maint_print_section_info(const char *name, flagword flags, CORE_ADDR addr, CORE_ADDR endaddr, unsigned long filepos, int addr_size)
static void count_symtabs_and_blocks(int *nr_symtabs_ptr, int *nr_compunit_symtabs_ptr, int *nr_blocks_ptr)
static void maintenance_demangle(char *, int)
struct timeval get_prompt_for_continue_wait_time(void)
unsigned int malloced_replacement
static void maintenance_do_deprecate(char *, int)
#define MULTI_OBJFILE_P()
void internal_warning(const char *file, int line, const char *fmt,...)
static int match_bfd_flags(const char *string, flagword flags)
static void maintenance_undeprecate(char *args, int from_tty)
void error(const char *fmt,...)
void do_cleanups(struct cleanup *old_chain)
void add_setshow_boolean_cmd(const char *name, enum command_class theclass, int *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_sfunc_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
const ULONGEST const LONGEST len
void print_symbol_bcache_statistics(void)