GDB (xrefs)

Macros | Functions
common-utils.c File Reference
`#include "common-defs.h"`
`#include "common-utils.h"`
`#include "host-defs.h"`
`#include <ctype.h>`

Go to the source code of this file.

## Macros
#define | HIGH_BYTE_POSN ((sizeof (ULONGEST) - 1) * HOST_CHAR_BIT)

## Functions
PTR | xmalloc (size_t size)
PTR | xrealloc (PTR ptr, size_t size)
PTR | xcalloc (size_t number, size_t size)
void * | xzalloc (size_t size)
void | xmalloc_failed (size_t size)
char * | xstrprintf (const char *format,...)
char * | xstrvprintf (const char *format, va_list ap)
int | xsnprintf (char *str, size_t size, const char *format,...)
std::string | string_printf (const char *fmt,...)
std::string | string_vprintf (const char *fmt, va_list args)
void | string_appendf (std::string &str, const char *fmt,...)
void | string_vappendf (std::string &str, const char *fmt, va_list args)
char * | savestring (const char *ptr, size_t len)
static int | is_digit_in_base (unsigned char digit, int base)
static int | digit_to_int (unsigned char c)
ULONGEST | strtoulst (const char *num, const char **trailer, int base)
char * | skip_spaces (char *chp)
const char * | skip_spaces (const char *chp)
const char * | skip_to_space (const char *chp)
char * | skip_to_space (char *chp)
void | free_vector_argv (std::vector< char *> &v)
std::string | stringify_argv (const std::vector< char *> &args)

## Macro Definition Documentation

## ◆ HIGH_BYTE_POSN

#define HIGH_BYTE_POSN ((sizeof (ULONGEST) - 1) * HOST_CHAR_BIT)

Definition at line 238 of file common-utils.c.

Referenced by strtoulst().

## Function Documentation

## ◆ digit_to_int()

static int digit_to_int | ( | unsigned char | c | ) |
| static

Definition at line 255 of file common-utils.c.

Referenced by strtoulst().

## ◆ free_vector_argv()

void free_vector_argv | ( | std::vector< char *> & | v | ) |

Definition at line 381 of file common-utils.c.

References xfree().

## ◆ is_digit_in_base()

static int is_digit_in_base | ( | unsigned char | digit,
|  | int | base
| ) |  |
| static

Definition at line 244 of file common-utils.c.

Referenced by strtoulst().

## ◆ savestring()

char* savestring | ( | const char * | ptr,
|  | size_t | len
| ) |  |

Definition at line 226 of file common-utils.c.

References xmalloc().

Referenced by add_path(), cd_command(), copy_token_string(), explicit_location_lex_one(), explicit_location_lex_one_function(), find_condition_and_thread(), init_breakpoint_sal(), linespec_parse_basic(), maintenance_do_deprecate(), new_linespec_location(), parse_macro_definition(), process_next_line(), read_member_functions(), read_one_struct_field(), record_full_goto_bookmark(), scan_expression(), scan_filename(), solib_find_1(), strip_bg_char(), and watch_command_1().

## ◆ skip_spaces() [1/2]

char* skip_spaces | ( | char * | chp | ) |

Definition at line 337 of file common-utils.c.

Referenced by aarch64_stap_parse_special_token(), ada_get_next_arg(), add_solib_catchpoint(), agent_command_1(), arm_stap_parse_special_token(), bppy_init(), break_range_command(), catch_ada_assert_command_split(), catch_ada_exception_command_split(), catch_exception_command_1(), catch_exec_command_1(), catch_fork_command_1(), catch_signal_command(), catch_signal_split_args(), catch_syscall_command_1(), catch_syscall_split_args(), check_raw_argument(), cmd_record_call_history(), cmd_record_insn_history(), collect_explicit_location_matches(), compile_code_command(), compile_file_command(), complete_line_internal_1(), condition_completer(), cp_search_name_hash(), decode_agent_options(), decode_static_tracepoint_spec(), decode_vmflags(), demangle_command(), disassemble_command(), disassembler_options_completer(), encode_actions_1(), ep_parse_optional_if_clause(), expand_preserving_ws(), extract_arg(), extract_exception_regexp(), find_condition_and_thread(), gdbscm_register_breakpoint_x(), get_call_history_modifiers(), get_context_size(), get_insn_history_modifiers(), get_insn_number(), number_or_range_parser::get_number(), get_number_trailer(), get_selected_pc_producer_options(), get_selections(), tid_range_parser::get_tid_or_range(), get_uint(), go32_pde(), go32_pte(), go32_pte_for_address(), go32_sgdt(), go32_sidt(), go32_sldt(), guile_command(), guile_repl_command(), info_auto_load_libthread_db(), info_macro_command(), info_threads_command(), init_breakpoint_sal(), init_history(), is_closing_quote_enclosed(), is_unlimited_literal(), lex_number(), line_first_arg(), linespec_lexer_lex_keyword(), linespec_lexer_lex_one(), linespec_lexer_lex_string(), linespec_parse_basic(), linux_fill_prpsinfo(), linux_info_proc(), maint_agent_printf_command(), maint_btrace_packet_history_cmd(), maintenance_translate_address(), mi_parse(), mi_parse_argv(), msymbol_hash_iw(), stap_probe::parse_arguments(), parse_cmd_to_aexpr(), parse_find_args(), parse_frame_specification(), parse_linespec(), parse_method(), parse_probes(), parse_proc_status_state(), parse_selector(), process_next_line(), python_command(), python_interactive_command(), rbreak_command(), read_mapping(), registers_info(), restore_command(), save_gdb_index_command(), scan_expression(), scan_filename(), serial_open(), set_completion_after_number(), set_ext_lang_command(), source_command(), stap_parse_argument(), stap_parse_argument_1(), stap_parse_argument_conditionally(), stap_parse_single_operand(), string_to_explicit_location(), strncmp_iw_with_mode(), tfind_outside_command(), tfind_range_command(), thread_apply_all_command(), thread_name_command(), trace_dump_actions(), trace_pass_command(), trace_variable_command(), ui_printf(), update_dprintf_command_list(), validate_actionline(), watch_command_1(), watch_maybe_just_location(), and whatis_exp().

## ◆ skip_spaces() [2/2]

const char* skip_spaces | ( | const char * | chp | ) |

Definition at line 349 of file common-utils.c.

## ◆ skip_to_space() [1/2]

const char* skip_to_space | ( | const char * | chp | ) |

Definition at line 361 of file common-utils.c.

Referenced by ada_get_next_arg(), condition_completer(), decode_static_tracepoint_spec(), decode_vmflags(), demangle_command(), extract_arg(), extract_exception_regexp(), find_condition_and_thread(), get_selected_pc_producer_options(), tid_range_parser::get_tid_or_range(), info_macro_command(), init_breakpoint_sal(), parse_linespec(), parse_probes(), producer_is_icc(), skip_keyword(), skip_to_space(), and watch_command_1().

## ◆ skip_to_space() [2/2]

char* skip_to_space | ( | char * | chp | ) |

Definition at line 373 of file common-utils.c.

References skip_to_space().

## ◆ string_appendf()

void string_appendf | ( | std::string & | str,
|  | const char * | fmt,
|  |  | ...
| ) |  |

Definition at line 195 of file common-utils.c.

References string_vappendf().

Referenced by remote_set_syscall_catchpoint(), and selftests::string_appendf_tests().

## ◆ string_printf()

std::string string_printf | ( | const char * | fmt,
|  |  | ...
| ) |  |

Definition at line 150 of file common-utils.c.

References size, and string.

Referenced by _initialize_arm_tdep(), actions_command(), ada_varobj_describe_ptr_child(), ada_varobj_describe_simple_array_child(), ada_varobj_describe_struct_child(), ada_varobj_get_value_of_array_variable(), ATTRIBUTE_PRINTF(), c_describe_child(), c_get_range_decl_name(), c_value_of_variable(), catch_syscall_completer(), commands_command_1(), compile_file_command(), compile_register_name_mangled(), cplus_describe_child(), create_child_with_value(), create_dwo_unit_in_dwp_v1(), create_dwo_unit_in_dwp_v2(), create_tsv_from_upload(), ctf_start(), decode_objc(), regcache::dump(), exec_reverse_once(), fbsd_find_memory_regions(), file_is_auto_load_safe(), floatformat_printf_format(), gdb_demangle(), gdb_safe_append_history(), get_new_file_names(), info_symbol_command(), local_setattro(), lookup_dwo_cutu(), memory_error_message(), print_mention_exception(), print_thread_info_1(), py_varobj_iter_next(), rbreak_command(), solib_aix_bfd_open(), solib_aix_current_sos(), selftests::string_printf_tests(), target_float_to_string(), target_waitstatus_to_string(), thread_section_name::thread_section_name(), host_float_ops< T >::to_string(), mpfr_float_ops::to_string(), decimal_float_ops::to_string(), varobj_gen_name(), vfprintf_unfiltered(), and yyparse().

## ◆ string_vappendf()

void string_vappendf | ( | std::string & | str,
|  | const char * | fmt,
|  | va_list | args
| ) |  |

Definition at line 208 of file common-utils.c.

Referenced by selftests::ATTRIBUTE_PRINTF(), and string_appendf().

## ◆ string_vprintf()

std::string string_vprintf | ( | const char * | fmt,
|  | va_list | args
| ) |  |

Definition at line 173 of file common-utils.c.

References size, and string.

Referenced by selftests::ATTRIBUTE_PRINTF(), ATTRIBUTE_PRINTF(), link_callbacks_einfo(), vfprintf_maybe_filtered(), and vfprintf_unfiltered().

## ◆ stringify_argv()

std::string stringify_argv | ( | const std::vector< char *> & | args | ) |

Definition at line 392 of file common-utils.c.

References string.

## ◆ strtoulst()

ULONGEST strtoulst | ( | const char * | num,
|  | const char ** | trailer,
|  | int | base
| ) |  |

Definition at line 266 of file common-utils.c.

References digit_to_int(), HIGH_BYTE_POSN, and is_digit_in_base().

Referenced by generic_load(), get_insn_number(), info_spu_event_command(), info_spu_signal_command(), linux_info_proc(), linux_vsyscall_range_raw(), read_mapping(), read_maps_entry(), spu_pseudo_register_read_spu(), spu_symbol_file_add_from_memory(), spu_xfer_partial(), trace_pass_command(), and xml_parse_unsigned_integer().

## ◆ xcalloc()

PTR xcalloc | ( | size_t | number,
|  | size_t | size
| ) |  |

Definition at line 72 of file common-utils.c.

References malloc_failure(), and size.

Referenced by _initialize_ada_language(), _initialize_gdb_bfd(), _initialize_record_btrace(), _initialize_tailcall_frame(), allocate_dis_line_table(), ambiguous_names_p(), completion_tracker::completion_tracker(), compute_compunit_symtab_includes(), create_demangled_names_hash(), create_quick_file_names_table(), create_typedef_hash(), completion_tracker::discard_completions(), dw2_map_symbol_filenames(), dw_expand_symtabs_matching_file_matcher(), dwarf_decode_macros(), filename_seen_cache::filename_seen_cache(), gdb_bfd_open(), gdbscm_create_eqable_gsmob_ptr_map(), gdbscm_initialize_smobs(), generate_c_for_for_one_variable(), generate_c_for_variable_locations(), gnuv3_print_vtable(), linespec_state_constructor(), linux_xfer_osdata_processes(), new_compile_instance(), objfile_register_static_link(), register_solib_event_probe(), resize_symbol_cache(), and xzalloc().

## ◆ xmalloc()

PTR xmalloc | ( | size_t | size | ) |

Definition at line 35 of file common-utils.c.

References malloc_failure(), and size.

Referenced by savestring().

## ◆ xmalloc_failed()

void xmalloc_failed | ( | size_t | size | ) |

Definition at line 98 of file common-utils.c.

References malloc_failure(), and size.

## ◆ xrealloc()

PTR xrealloc | ( | PTR | ptr,
|  | size_t | size
| ) |  |

Definition at line 52 of file common-utils.c.

References malloc_failure(), and size.

Referenced by add_bincl_to_list(), add_block(), add_new_header_file(), add_this_object_header_file(), add_undefined_type_1(), add_undefined_type_noname(), dwarf2_frame_state_reg_info::alloc_regs(), arrange_linetable(), buffer_grow(), coff_lookup_type(), commandline_from_pid(), completion_list_objc_symbol(), copy_name(), create_file_handler(), dbx_lookup_type(), decoded_type_name(), do_set_command(), dwarf2_add_member_fn(), find_methods(), find_source_lines(), forward_search_command(), get_memory_packet_size(), grow_expr(), grow_vect(), growbuf_by_size(), init_remote_state(), linux_common_core_of_thread(), macro_define_command(), my_write_child(), overload_list_add_symbol(), parse_partial_symbols(), pdc_realloc(), process_enumeration_scope(), process_linenos(), push_context(), read_frame(), read_string(), record_line(), ref_add(), remote_fileio_resize_fd_map(), remote_hostio_pread(), remote_query_supported(), resize_buffer(), rs6000_ptrace_ldinfo(), set_value_enclosing_type(), set_width(), shrink_linetable(), specify_exec_file_hook(), substitute_path_component(), sync_threadlists(), target_fileio_read_alloc_1(), target_read_alloc_1(), target_read_string(), trace_dump_actions(), vec_o_reserve(), yylex(), and yyparse().

## ◆ xsnprintf()

int xsnprintf | ( | char * | str,
|  | size_t | size,
|  | const char * | format,
|  |  | ...
| ) |  |

Definition at line 134 of file common-utils.c.

References gdb_assert, and size.

Referenced by _initialize_check_for_gdb_ini(), ada_decode(), ada_enum_name(), ada_to_fixed_type_1(), add_pe_forwarded_sym(), append_ocl_sos(), append_resumption(), arm_dwarf_reg_to_regnum(), arm_neon_quad_read(), arm_neon_quad_write(), arm_pseudo_read(), arm_pseudo_write(), arm_push_dummy_call(), arm_return_value(), bsd_kvm_pid_to_str(), bsd_uthread_pid_to_str(), btrace_sync_conf(), cmd_record_save(), condition_completer(), convert_ast_to_expression(), convert_between_encodings(), convert_char_literal(), core_pid_to_str(), core_xfer_partial(), cp_lookup_nested_symbol(), create_tracepoint_from_upload(), d_lookup_nested_symbol(), decimal2str(), define_command(), do_compile_dwarf_expr_to_c(), cli_ui_out::do_field_int(), mi_ui_out::do_field_int(), do_set_command(), document_command(), execute_control_command_1(), extended_remote_attach(), extended_remote_create_inferior(), extended_remote_disable_randomization(), extended_remote_restart(), extended_remote_set_inferior_cwd(), fbsd_core_pid_to_str(), fbsd_pid_to_exec_file(), fetch_ppc_register(), fetch_register(), file_file_name(), find_old_style_renaming_symbol(), floatformat_mantissa(), gdb_connect_sync_socket(), gdb_display_match_list(), gdb_mangle_name(), gnu_pid_to_str(), hex_string(), host_address_to_string_1(), info_auto_load_libthread_db(), info_spu_dma_command(), info_spu_event_command(), info_spu_mailbox_command(), info_spu_proxydma_command(), info_spu_signal_command(), init_source_path(), linux_fill_prpsinfo(), linux_find_memory_regions_full(), linux_info_proc(), linux_ns_filename(), linux_proc_attach_tgid_threads(), linux_proc_pending_signals(), linux_proc_pid_get_state(), linux_proc_pid_to_exec_file(), linux_proc_task_list_dir_exists(), linux_proc_tid_get_name(), linux_proc_xfer_partial(), linux_proc_xfer_spu(), linux_spu_make_corefile_notes(), linux_vsyscall_range_raw(), linux_xfer_osdata_fds(), linux_xfer_osdata_threads(), m68hc11_initialize_register_info(), make_hex_string(), make_types(), mi_argv_to_format(), nbsd_pid_to_exec_file(), normal_pid_to_str(), nto_find_and_open_solib(), nto_init_solib_absolute_prefix(), octal2str(), op_name_standard(), output_thread_groups(), phex(), phex_nz(), ppu2spu_sniffer(), print_source_lines_base(), print_thread_id(), print_wchar(), proc_string(), pstring_list(), remote_add_target_side_condition(), remote_check_symbols(), remote_detach_pid(), remote_disable_btrace(), remote_disable_tracepoint(), remote_download_trace_state_variable(), remote_download_tracepoint(), remote_enable_btrace(), remote_enable_tracepoint(), remote_get_min_fast_tracepoint_insn_len(), remote_get_noisy_reply(), remote_get_trace_state_variable_value(), remote_get_tracepoint_status(), remote_hostio_set_filesystem(), remote_insert_breakpoint(), remote_insert_hw_breakpoint(), remote_insert_watchpoint(), remote_interrupt_ns(), remote_pid_to_exec_file(), remote_pid_to_str(), remote_query_attached(), remote_remove_breakpoint(), remote_remove_hw_breakpoint(), remote_remove_watchpoint(), remote_resume_with_vcont(), remote_set_circular_trace_buffer(), remote_set_disconnected_tracing(), remote_set_permissions(), remote_set_trace_buffer_size(), remote_set_trace_notes(), remote_static_tracepoint_marker_at(), remote_stop_ns(), remote_thread_events(), remote_threads_extra_info(), remote_trace_find(), remote_trace_set_readonly_regions(), remote_use_agent(), remote_verify_memory(), remote_vkill(), rust_underscore_fields(), safe_strerror(), send_environment_packet(), send_g_packet(), set_thread(), set_variant_num_fprs(), set_variant_num_gprs(), sol2_core_pid_to_str(), solaris_pid_to_str(), solist_update_incremental(), spu_current_sos(), spu_enumerate_spu_ids(), spu_fetch_inferior_registers(), spu_fetch_registers(), spu_proc_xfer_spu(), spu_pseudo_register_read(), spu_pseudo_register_read_spu(), spu_pseudo_register_write(), spu_pseudo_register_write_spu(), spu_store_inferior_registers(), spu_store_registers(), spu_symbol_file_add_from_memory(), spu_xfer_partial(), store_register(), store_register_using_P(), svr4_create_solib_event_breakpoints(), td_err_string(), td_state_string(), trace_status_mi(), tui_make_status_line(), vcont_builder_restart(), windows_create_inferior(), windows_pid_to_exec_file(), and write_ptid().

## ◆ xstrprintf()

char* xstrprintf | ( | const char * | format,
|  |  | ...
| ) |  |

Definition at line 107 of file common-utils.c.

References xstrvprintf().

Referenced by _initialize_auto_load(), ada_exception_catchpoint_cond_string(), add_angle_brackets(), add_auto_load_dir(), add_auto_load_safe_path(), add_deprecated_target_alias(), add_internal_problem_command(), add_packet_config_cmd(), add_pe_exported_sym(), add_pe_forwarded_sym(), add_sal_to_sals(), add_setshow_cmd_full(), add_vsyscall_page(), aix_thread_pid_to_str(), all_tracepoint_actions_and_cleanup(), bppy_init(), build_error_marker_type(), c_watch_location_expression(), canonical_to_fullform(), captured_main_1(), command_from_pid(), commandline_from_pid(), create_type_unit_group(), decode_line_2(), default_gcc_target_options(), edit_command(), env_execute_cli_command(), event_location_to_string(), fixup_definition(), gcore_command(), gdbscm_gsmob_kind(), gdbscm_initialize_ports(), gdbscm_make_arg_error(), gdbscm_make_type_error(), gdbscm_parse_command_name(), gdbscm_set_breakpoint_stop_x(), get_function_name(), get_init_files(), i386_fast_tracepoint_valid_at(), init_cli_cmds(), is_package_name(), jit_reader_load_command(), linux_ptrace_attach_fail_reason_string(), linux_xfer_osdata_fds(), linux_xfer_osdata_threads(), new_variant(), ppscm_make_pp_type_error_exception(), print_converted_chars_to_obstack(), print_mention_exception(), print_one_breakpoint_location(), print_one_catch_solib(), print_one_catch_syscall(), print_one_exception(), procfs_xfer_auxv(), rust_watch_location_expression(), salpy_str(), set_cp_abi_as_auto_default(), solib_aix_bfd_open(), update_dprintf_command_list(), watch_command_1(), xtensa_init_reggroups(), and xtensa_register_type().

## ◆ xstrvprintf()

char* xstrvprintf | ( | const char * | format,
|  | va_list | ap
| ) |  |

Definition at line 119 of file common-utils.c.

References _, internal_error(), and status.

Referenced by ATTRIBUTE_PRINTF(), gdbscm_printf(), gdbscm_scm_from_printf(), serial_printf(), gdb_xml_parser::vdebug(), and xstrprintf().

## ◆ xzalloc()

void* xzalloc | ( | size_t | size | ) |

Definition at line 92 of file common-utils.c.

References size, and xcalloc().

Referenced by allocate_value_contents(), new_bvect(), replace_operator_with_call(), and solib_target_relocate_section_addresses().