void annotate_error (void) { if (annotation_level > 1) printf_filtered (("\n\032\032error\n")); }
static void darwin_debug_regions (task_t task, mach_vm_address_t address, int max) { kern_return_t kret; vm_region_basic_info_data_64_t info, prev_info; mach_vm_address_t prev_address; mach_vm_size_t size, prev_size; mach_port_t object_name; mach_msg_type_number_t count; int nsubregions = 0; int num_printed = 0; count = VM_REGION_BASIC_INFO_COUNT_64; kret = mach_vm_region (task, &address, &size, VM_REGION_BASIC_INFO_64, (vm_region_info_t) &info, &count, &object_name); if (kret != KERN_SUCCESS) { printf_filtered (_("No memory regions.")); return; } memcpy (&prev_info, &info, sizeof (vm_region_basic_info_data_64_t)); prev_address = address; prev_size = size; nsubregions = 1; for (;;) { int print = 0; int done = 0; address = prev_address + prev_size; /* Check to see if address space has wrapped around. */ if (address == 0) print = done = 1; if (!done) { count = VM_REGION_BASIC_INFO_COUNT_64; kret = mach_vm_region (task, &address, &size, VM_REGION_BASIC_INFO_64, (vm_region_info_t) &info, &count, &object_name); if (kret != KERN_SUCCESS) { size = 0; print = done = 1; } } if (address != prev_address + prev_size) print = 1; if ((info.protection != prev_info.protection) || (info.max_protection != prev_info.max_protection) || (info.inheritance != prev_info.inheritance) || (info.shared != prev_info.reserved) || (info.reserved != prev_info.reserved)) print = 1; if (print) { printf_filtered (_("%s-%s %s/%s %s %s %s"), paddress (target_gdbarch (), prev_address), paddress (target_gdbarch (), prev_address + prev_size), unparse_protection (prev_info.protection), unparse_protection (prev_info.max_protection), unparse_inheritance (prev_info.inheritance), prev_info.shared ? _("shrd") : _("priv"), prev_info.reserved ? _("reserved") : _("not-rsvd")); if (nsubregions > 1) printf_filtered (_(" (%d sub-rgn)"), nsubregions); printf_filtered (_("\n")); prev_address = address; prev_size = size; memcpy (&prev_info, &info, sizeof (vm_region_basic_info_data_64_t)); nsubregions = 1; num_printed++; } else { prev_size += size; nsubregions++; } if ((max > 0) && (num_printed >= max)) done = 1; if (done) break; } }
static void find_command (char *args, int from_tty) { /* Command line parameters. These are initialized to avoid uninitialized warnings from -Wall. */ ULONGEST max_count = 0; char *pattern_buf = 0; ULONGEST pattern_len = 0; CORE_ADDR start_addr = 0; ULONGEST search_space_len = 0; /* End of command line parameters. */ unsigned int found_count; CORE_ADDR last_found_addr; struct cleanup *old_cleanups; parse_find_args (args, &max_count, &pattern_buf, &pattern_len, &start_addr, &search_space_len); old_cleanups = make_cleanup (free_current_contents, &pattern_buf); /* Perform the search. */ found_count = 0; last_found_addr = 0; while (search_space_len >= pattern_len && found_count < max_count) { /* Offset from start of this iteration to the next iteration. */ ULONGEST next_iter_incr; CORE_ADDR found_addr; int found = target_search_memory (start_addr, search_space_len, pattern_buf, pattern_len, &found_addr); if (found <= 0) break; print_address (found_addr, gdb_stdout); printf_filtered ("\n"); ++found_count; last_found_addr = found_addr; /* Begin next iteration at one byte past this match. */ next_iter_incr = (found_addr - start_addr) + 1; /* For robustness, we don't let search_space_len go -ve here. */ if (search_space_len >= next_iter_incr) search_space_len -= next_iter_incr; else search_space_len = 0; start_addr += next_iter_incr; } /* Record and print the results. */ set_internalvar_integer (lookup_internalvar ("numfound"), found_count); if (found_count > 0) { struct gdbarch *gdbarch = current_gdbarch; struct type *ptr_type = builtin_type (gdbarch)->builtin_data_ptr; set_internalvar (lookup_internalvar ("_"), value_from_pointer (ptr_type, last_found_addr)); } if (found_count == 0) printf_filtered ("Pattern not found.\n"); else printf_filtered ("%d pattern%s found.\n", found_count, found_count > 1 ? "s" : ""); do_cleanups (old_cleanups); }
void annotate_array_section_end (void) { if (annotation_level == 2) printf_filtered (("\n\032\032array-section-end\n")); }
void annotate_starting (void) { if (annotation_level > 1) printf_filtered (("\n\032\032starting\n")); }
void annotate_frame_end (void) { if (annotation_level == 2) printf_filtered (("\n\032\032frame-end\n")); }
void annotate_elt_rep_end (void) { if (annotation_level == 2) printf_filtered (("\n\032\032elt-rep-end\n")); }
void annotate_display_end (void) { if (annotation_level == 2) printf_filtered (("\n\032\032display-end\n")); }
void annotate_arg_begin (void) { if (annotation_level == 2) printf_filtered (("\n\032\032arg-begin\n")); }
void annotate_display_expression (void) { if (annotation_level == 2) printf_filtered (("\n\032\032display-expression\n")); }
void annotate_display_value (void) { if (annotation_level == 2) printf_filtered (("\n\032\032display-value\n")); }
void annotate_display_format (void) { if (annotation_level == 2) printf_filtered (("\n\032\032display-format\n")); }
void annotate_display_begin (void) { if (annotation_level == 2) printf_filtered (("\n\032\032display-begin\n")); }
void annotate_value_history_end (void) { if (annotation_level == 2) printf_filtered (("\n\032\032value-history-end\n")); }
void annotate_frame_source_line (void) { if (annotation_level == 2) printf_filtered (("\n\032\032frame-source-line\n")); }
void annotate_arg_end (void) { if (annotation_level == 2) printf_filtered (("\n\032\032arg-end\n")); }
void annotate_frame_where (void) { if (annotation_level == 2) printf_filtered (("\n\032\032frame-where\n")); }
void annotate_frame_begin (int level, CORE_ADDR pc) { if (annotation_level > 1) printf_filtered (("\n\032\032frame-begin %d %s\n"), level, paddress (pc)); }
void annotate_elt_rep (unsigned int repcount) { if (annotation_level == 2) printf_filtered (("\n\032\032elt-rep %u\n"), repcount); }
void annotate_function_call (void) { if (annotation_level == 2) printf_filtered (("\n\032\032function-call\n")); }
void annotate_elt (void) { if (annotation_level == 2) printf_filtered (("\n\032\032elt\n")); }
void annotate_signal_handler_caller (void) { if (annotation_level == 2) printf_filtered (("\n\032\032signal-handler-caller\n")); }
void annotate_watchpoint (int num) { if (annotation_level > 1) printf_filtered (("\n\032\032watchpoint %d\n"), num); }
void annotate_frame_function_name (void) { if (annotation_level == 2) printf_filtered (("\n\032\032frame-function-name\n")); }
static void print_bfd_flags (flagword flags) { if (flags & SEC_ALLOC) printf_filtered (" ALLOC"); if (flags & SEC_LOAD) printf_filtered (" LOAD"); if (flags & SEC_RELOC) printf_filtered (" RELOC"); if (flags & SEC_READONLY) printf_filtered (" READONLY"); if (flags & SEC_CODE) printf_filtered (" CODE"); if (flags & SEC_DATA) printf_filtered (" DATA"); if (flags & SEC_ROM) printf_filtered (" ROM"); if (flags & SEC_CONSTRUCTOR) printf_filtered (" CONSTRUCTOR"); if (flags & SEC_HAS_CONTENTS) printf_filtered (" HAS_CONTENTS"); if (flags & SEC_NEVER_LOAD) printf_filtered (" NEVER_LOAD"); if (flags & SEC_COFF_SHARED_LIBRARY) printf_filtered (" COFF_SHARED_LIBRARY"); if (flags & SEC_IS_COMMON) printf_filtered (" IS_COMMON"); }
void annotate_frame_args (void) { if (annotation_level == 2) printf_filtered (("\n\032\032frame-args\n")); }
void child_terminal_info (char *args, int from_tty) { if (!gdb_has_a_terminal ()) { printf_filtered ("This GDB does not control a terminal.\n"); return; } printf_filtered ("Inferior's terminal status (currently saved by GDB):\n"); /* First the fcntl flags. */ { int flags; flags = tflags_inferior; printf_filtered ("File descriptor flags = "); #ifndef O_ACCMODE #define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) #endif /* (O_ACCMODE) parens are to avoid Ultrix header file bug */ switch (flags & (O_ACCMODE)) { case O_RDONLY: printf_filtered ("O_RDONLY"); break; case O_WRONLY: printf_filtered ("O_WRONLY"); break; case O_RDWR: printf_filtered ("O_RDWR"); break; } flags &= ~(O_ACCMODE); #ifdef O_NONBLOCK if (flags & O_NONBLOCK) printf_filtered (" | O_NONBLOCK"); flags &= ~O_NONBLOCK; #endif #if defined (O_NDELAY) /* If O_NDELAY and O_NONBLOCK are defined to the same thing, we will print it as O_NONBLOCK, which is good cause that is what POSIX has, and the flag will already be cleared by the time we get here. */ if (flags & O_NDELAY) printf_filtered (" | O_NDELAY"); flags &= ~O_NDELAY; #endif if (flags & O_APPEND) printf_filtered (" | O_APPEND"); flags &= ~O_APPEND; #if defined (O_BINARY) if (flags & O_BINARY) printf_filtered (" | O_BINARY"); flags &= ~O_BINARY; #endif if (flags) printf_filtered (" | 0x%x", flags); printf_filtered ("\n"); } #ifdef PROCESS_GROUP_TYPE printf_filtered ("Process group = %d\n", (int) inferior_process_group); #endif serial_print_tty_state (stdin_serial, inferior_ttystate, gdb_stdout); }
void annotate_frame_source_begin (void) { if (annotation_level == 2) printf_filtered (("\n\032\032frame-source-begin\n")); }
static void parse_find_args (char *args, ULONGEST *max_countp, char **pattern_bufp, ULONGEST *pattern_lenp, CORE_ADDR *start_addrp, ULONGEST *search_space_lenp) { /* Default to using the specified type. */ char size = '\0'; ULONGEST max_count = ~(ULONGEST) 0; /* Buffer to hold the search pattern. */ char *pattern_buf; /* Current size of search pattern buffer. We realloc space as needed. */ #define INITIAL_PATTERN_BUF_SIZE 100 ULONGEST pattern_buf_size = INITIAL_PATTERN_BUF_SIZE; /* Pointer to one past the last in-use part of pattern_buf. */ char *pattern_buf_end; ULONGEST pattern_len; CORE_ADDR start_addr; ULONGEST search_space_len; char *s = args; bfd_boolean big_p = gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG; struct cleanup *old_cleanups; struct value *v; if (args == NULL) error (_("Missing search parameters.")); pattern_buf = xmalloc (pattern_buf_size); pattern_buf_end = pattern_buf; old_cleanups = make_cleanup (free_current_contents, &pattern_buf); /* Get search granularity and/or max count if specified. They may be specified in either order, together or separately. */ while (*s == '/') { ++s; while (*s != '\0' && *s != '/' && !isspace (*s)) { if (isdigit (*s)) { max_count = atoi (s); while (isdigit (*s)) ++s; continue; } switch (*s) { case 'b': case 'h': case 'w': case 'g': size = *s++; break; default: error (_("Invalid size granularity.")); } } while (isspace (*s)) ++s; } /* Get the search range. */ v = parse_to_comma_and_eval (&s); start_addr = value_as_address (v); if (*s == ',') ++s; while (isspace (*s)) ++s; if (*s == '+') { LONGEST len; ++s; v = parse_to_comma_and_eval (&s); len = value_as_long (v); if (len == 0) { printf_filtered (_("Empty search range.\n")); return; } if (len < 0) error (_("Invalid length.")); /* Watch for overflows. */ if (len > CORE_ADDR_MAX || (start_addr + len - 1) < start_addr) error (_("Search space too large.")); search_space_len = len; } else { CORE_ADDR end_addr; v = parse_to_comma_and_eval (&s); end_addr = value_as_address (v); if (start_addr > end_addr) error (_("Invalid search space, end preceeds start.")); search_space_len = end_addr - start_addr + 1; /* We don't support searching all of memory (i.e. start=0, end = 0xff..ff). Bail to avoid overflows later on. */ if (search_space_len == 0) error (_("Overflow in address range computation, choose smaller range.")); } if (*s == ',') ++s; /* Fetch the search string. */ while (*s != '\0') { LONGEST x; int val_bytes; while (isspace (*s)) ++s; v = parse_to_comma_and_eval (&s); val_bytes = TYPE_LENGTH (value_type (v)); /* Keep it simple and assume size == 'g' when watching for when we need to grow the pattern buf. */ if ((pattern_buf_end - pattern_buf + max (val_bytes, sizeof (int64_t))) > pattern_buf_size) { size_t current_offset = pattern_buf_end - pattern_buf; pattern_buf_size *= 2; pattern_buf = xrealloc (pattern_buf, pattern_buf_size); pattern_buf_end = pattern_buf + current_offset; } if (size != '\0') { x = value_as_long (v); switch (size) { case 'b': *pattern_buf_end++ = x; break; case 'h': put_bits (x, pattern_buf_end, 16, big_p); pattern_buf_end += sizeof (int16_t); break; case 'w': put_bits (x, pattern_buf_end, 32, big_p); pattern_buf_end += sizeof (int32_t); break; case 'g': put_bits (x, pattern_buf_end, 64, big_p); pattern_buf_end += sizeof (int64_t); break; } } else { memcpy (pattern_buf_end, value_contents_raw (v), val_bytes); pattern_buf_end += val_bytes; } if (*s == ',') ++s; while (isspace (*s)) ++s; } if (pattern_buf_end == pattern_buf) error (_("Missing search pattern.")); pattern_len = pattern_buf_end - pattern_buf; if (search_space_len < pattern_len) error (_("Search space too small to contain pattern.")); *max_countp = max_count; *pattern_bufp = pattern_buf; *pattern_lenp = pattern_len; *start_addrp = start_addr; *search_space_lenp = search_space_len; /* We successfully parsed the arguments, leave the freeing of PATTERN_BUF to the caller now. */ discard_cleanups (old_cleanups); }
void annotate_quit (void) { if (annotation_level > 1) printf_filtered (("\n\032\032quit\n")); }