35#include "gdbsupport/gdb_obstack.h"
47 switch (str_type & ~
C_CHAR)
66 internal_error (_(
"unhandled c_string_type"));
77 const char **encoding)
96 if (!strcmp (
name,
"wchar_t"))
102 if (!strcmp (
name,
"char16_t"))
108 if (!strcmp (
name,
"char32_t"))
114 if (elttype->
code () != TYPE_CODE_TYPEDEF)
147 struct ui_file *stream,
int quoter)
const
149 const char *encoding;
161 c_string_type str_type;
193 const gdb_byte *
string,
unsigned int length,
194 const char *user_encoding,
int force_ellipses,
197 c_string_type str_type;
198 const char *type_encoding;
199 const char *encoding;
218 encoding = (user_encoding && *user_encoding) ? user_encoding : type_encoding;
243 int *length,
struct type **char_type,
244 const char **charset)
247 unsigned int fetchlimit;
251 enum bfd_endian byte_order
254 if (element_type == NULL)
257 if (
type->
code () == TYPE_CODE_ARRAY)
264 LONGEST low_bound, high_bound;
267 &low_bound, &high_bound);
268 fetchlimit = high_bound - low_bound + 1;
271 fetchlimit = UINT_MAX;
273 else if (
type->
code () == TYPE_CODE_PTR)
274 fetchlimit = UINT_MAX;
282 width = element_type->
length ();
299 ||
type->
code () == TYPE_CODE_ARRAY)
300 && fetchlimit != UINT_MAX
311 for (i = 0; i < fetchlimit; i++)
313 width, byte_order) == 0)
320 memcpy (buffer->get (), contents, *
length);
329 if (
type->
code () == TYPE_CODE_ARRAY)
332 error (_(
"Attempt to take address of value "
333 "not located in memory."));
352 fetchlimit = UINT_MAX;
364 if (req_length == -1)
368 width, byte_order) == 0)
377 *char_type = element_type;
384 if (!type_str.empty ())
386 error (_(
"Trying to read string with inappropriate type `%s'."),
390 error (_(
"Trying to read string with inappropriate type."));
404convert_ucn (
const char *p,
const char *limit,
const char *dest_charset,
405 struct obstack *output,
int length)
407 unsigned long result = 0;
411 for (i = 0; i <
length && p < limit && ISXDIGIT (*p); ++i, ++p)
412 result = (result << 4) + fromhex (*p);
414 for (i = 3; i >= 0; --i)
416 data[i] = result & 0xff;
431 struct obstack *output)
435 buffer = (gdb_byte *) alloca (
type->
length ());
437 obstack_grow (output, buffer,
type->
length ());
447 const char *limit,
struct obstack *output)
450 unsigned long value = 0;
453 i < 3 && p < limit && ISDIGIT (*p) && *p !=
'8' && *p !=
'9';
472 const char *limit,
struct obstack *output)
474 unsigned long value = 0;
476 while (p < limit && ISXDIGIT (*p))
491 error (_("Malformed escape sequence")); \
503 const char *p,
const char *limit,
struct obstack *output)
511 obstack_1grow (output,
'\\');
518 error (_(
"\\x used with no following hex digits."));
536 int length = *p ==
'u' ? 4 : 8;
540 error (_(
"\\u used with no following hex digits"));
556 const char *dest_charset,
struct type *
type)
564 const char *p = data;
567 while (p < limit && *p !=
'\\')
572 (
const gdb_byte *) data, p - data, 1,
590 struct value *result;
591 c_string_type dest_type;
592 const char *dest_charset;
593 int satisfy_expected = 0;
599 switch (dest_type & ~
C_CHAR)
615 internal_error (_(
"unhandled c_string_type"));
621 if (expect_type && expect_type->
code () == TYPE_CODE_ARRAY)
623 struct type *element_type
626 if (element_type->
code () == TYPE_CODE_INT
627 || element_type->
code () == TYPE_CODE_CHAR)
630 satisfy_expected = 1;
636 for (
const std::string &item : std::get<1> (
m_storage))
640 if ((dest_type &
C_CHAR) != 0)
644 if (obstack_object_size (&output) !=
type->
length ())
645 error (_(
"Could not convert character "
646 "constant to target character set"));
654 if (satisfy_expected)
656 LONGEST low_bound, high_bound;
659 &low_bound, &high_bound))
662 high_bound = (expect_type->
length () / element_size) - 1;
664 if (obstack_object_size (&output) / element_size
665 > (high_bound - low_bound + 1))
666 error (_(
"Too many array elements"));
669 memcpy (result->
contents_raw ().data (), obstack_base (&output),
670 obstack_object_size (&output));
672 memset (result->
contents_raw ().data () + obstack_object_size (&output),
676 result =
value_cstring ((
const gdb_byte *) obstack_base (&output),
677 obstack_object_size (&output) / element_size,
692 while (
type->
code () == TYPE_CODE_REF)
700 case TYPE_CODE_ARRAY:
705 && array_target_type->
length () > 0
708 case TYPE_CODE_STRING:
726gdb::unique_xmalloc_ptr<char>
729 if (strchr (
name,
' ') !=
nullptr
730 || streq (
name,
"signed")
731 || streq (
name,
"unsigned"))
745 auto add = [&] (
struct type * t)
786 const char *
name ()
const override
798 static const std::vector<const char *> extensions = {
".c" };
819 const struct block *expr_block,
820 CORE_ADDR expr_pc)
const override
835 struct ui_file *stream,
int show,
int level,
867 const char *
name ()
const override
883 static const std::vector<const char *> extensions
884 = {
".C",
".cc",
".cp",
".cpp",
".cxx",
".c++" };
903 auto add = [&] (
struct type * t)
953 const struct block *expr_block,
954 CORE_ADDR expr_pc)
const override
967 (
const char *mangled,
968 gdb::unique_xmalloc_ptr<char> *demangled)
const override
970 *demangled =
gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
971 return *demangled != NULL;
977 int options)
const override
992 struct ui_file *stream,
int show,
int level,
1001 CORE_ADDR pc)
const override
1069 {
return "Assembly"; }
1075 static const std::vector<const char *> extensions
1076 = {
".s",
".sx",
".S" };
1099 struct ui_file *stream,
int show,
int level,
1134 {
return "minimal"; }
1139 {
return "Minimal"; }
1158 struct ui_file *stream,
int show,
int level,
static const char * convert_octal(struct type *type, const char *p, const char *limit, struct obstack *output)
bool c_is_string_type_p(struct type *type)
void c_language_arch_info(struct gdbarch *gdbarch, struct language_arch_info *lai)
static void emit_numeric_character(struct type *type, unsigned long value, struct obstack *output)
static const char * convert_ucn(const char *p, const char *limit, const char *dest_charset, struct obstack *output, int length)
static const char * convert_hex(struct type *type, const char *p, const char *limit, struct obstack *output)
void c_get_string(struct value *value, gdb::unique_xmalloc_ptr< gdb_byte > *buffer, int *length, struct type **char_type, const char **charset)
static asm_language asm_language_defn
static void parse_one_string(struct obstack *output, const char *data, int len, const char *dest_charset, struct type *type)
static cplus_language cplus_language_defn
static c_language c_language_defn
static const char * charset_for_string_type(c_string_type str_type, struct gdbarch *gdbarch)
gdb::unique_xmalloc_ptr< char > c_canonicalize_name(const char *name)
static minimal_language minimal_language_defn
static c_string_type classify_type(struct type *elttype, struct gdbarch *gdbarch, const char **encoding)
static const char * convert_escape(struct type *type, const char *dest_charset, const char *p, const char *limit, struct obstack *output)
std::string cplus_compute_program(compile_instance *inst, const char *input, struct gdbarch *gdbarch, const struct block *expr_block, CORE_ADDR expr_pc)
std::unique_ptr< compile_instance > cplus_get_compile_context()
std::string c_compute_program(compile_instance *inst, const char *input, struct gdbarch *gdbarch, const struct block *expr_block, CORE_ADDR expr_pc)
void c_print_type(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, enum language language, const struct type_print_options *flags)
int c_textual_element_type(struct type *, char)
std::unique_ptr< compile_instance > c_get_compile_context()
const struct lang_varobj_ops cplus_varobj_ops
const char * target_wide_charset(struct gdbarch *gdbarch)
const char * host_charset(void)
void convert_between_encodings(const char *from, const char *to, const gdb_byte *bytes, unsigned int num_bytes, int width, struct obstack *output, enum transliterations translit)
const char * target_charset(struct gdbarch *gdbarch)
const char * natural_name() const override
const std::vector< const char * > & filename_extensions() const override
bool store_sym_names_in_linkage_form_p() const override
enum macro_expansion macro_expansion() const override
void language_arch_info(struct gdbarch *gdbarch, struct language_arch_info *lai) const override
const char * name() const override
void print_type(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, const struct type_print_options *flags) const override
bool can_print_type_offsets() const override
bool can_print_type_offsets() const override
const char * name() const override
const char * natural_name() const override
std::string compute_program(compile_instance *inst, const char *input, struct gdbarch *gdbarch, const struct block *expr_block, CORE_ADDR expr_pc) const override
void language_arch_info(struct gdbarch *gdbarch, struct language_arch_info *lai) const override
enum macro_expansion macro_expansion() const override
void print_type(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, const struct type_print_options *flags) const override
const std::vector< const char * > & filename_extensions() const override
std::unique_ptr< compile_instance > get_compile_instance() const override
bool store_sym_names_in_linkage_form_p() const override
const struct lang_varobj_ops * varobj_ops() const override
bool sniff_from_mangled_name(const char *mangled, gdb::unique_xmalloc_ptr< char > *demangled) const override
CORE_ADDR skip_trampoline(const frame_info_ptr &fi, CORE_ADDR pc) const override
char * class_name_from_physname(const char *physname) const override
struct block_symbol lookup_symbol_nonlocal(const char *name, const struct block *block, const domain_enum domain) const override
void language_arch_info(struct gdbarch *gdbarch, struct language_arch_info *lai) const override
std::unique_ptr< compile_instance > get_compile_instance() const override
enum macro_expansion macro_expansion() const override
symbol_name_matcher_ftype * get_symbol_name_matcher_inner(const lookup_name_info &lookup_name) const override
std::string compute_program(compile_instance *inst, const char *input, struct gdbarch *gdbarch, const struct block *expr_block, CORE_ADDR expr_pc) const override
const char * name_of_this() const override
unsigned int search_name_hash(const char *name) const override
const char * name() const override
bool can_print_type_offsets() const override
struct language_pass_by_ref_info pass_by_reference_info(struct type *type) const override
struct type * lookup_transparent_type(const char *name) const override
const char * natural_name() const override
const char * get_digit_separator() const override
gdb::unique_xmalloc_ptr< char > demangle_symbol(const char *mangled, int options) const override
void print_type(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, const struct type_print_options *flags) const override
const std::vector< const char * > & filename_extensions() const override
value * evaluate(struct type *expect_type, struct expression *exp, enum noside noside) override
std::tuple< Arg... > m_storage
enum macro_expansion macro_expansion() const override
bool store_sym_names_in_linkage_form_p() const override
void print_type(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, const struct type_print_options *flags) const override
const char * name() const override
const char * natural_name() const override
bool can_print_type_offsets() const override
void language_arch_info(struct gdbarch *gdbarch, struct language_arch_info *lai) const override
void memory_error(enum target_xfer_status err, CORE_ADDR memaddr)
struct language_pass_by_ref_info cp_pass_by_reference(struct type *type)
CORE_ADDR cplus_skip_trampoline(frame_info_ptr frame, CORE_ADDR stop_pc)
struct type * cp_lookup_transparent_type(const char *name)
struct block_symbol cp_lookup_symbol_nonlocal(const struct language_defn *langdef, const char *name, const struct block *block, const domain_enum domain)
gdb::unique_xmalloc_ptr< char > gdb_demangle(const char *name, int options)
symbol_name_matcher_ftype * cp_get_symbol_name_matcher(const lookup_name_info &lookup_name)
gdb::unique_xmalloc_ptr< char > cp_canonicalize_string(const char *string)
char * cp_class_name_from_physname(const char *physname)
unsigned int cp_search_name_hash(const char *search_name)
static ULONGEST extract_unsigned_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
enum bfd_endian type_byte_order(const struct type *type)
struct type * lookup_typename(const struct language_defn *language, const char *name, const struct block *block, int noerr)
bool get_discrete_bounds(struct type *type, LONGEST *lowp, LONGEST *highp)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
struct type * check_typedef(struct type *type)
mach_port_t mach_port_t name mach_port_t mach_port_t name kern_return_t err
mach_port_t kern_return_t mach_port_t mach_msg_type_name_t msgportsPoly 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
struct type * language_string_char_type(const struct language_defn *la, struct gdbarch *gdbarch)
struct type * builtin_signed_char
struct type * builtin_declong
struct type * builtin_long_long
struct type * builtin_double
struct type * builtin_long
struct type * builtin_bool
struct type * builtin_unsigned_char
struct type * builtin_complex
struct type * builtin_long_double
struct type * builtin_unsigned_long_long
struct type * builtin_char16
struct type * builtin_short
struct type * builtin_double_complex
struct type * builtin_char
struct type * builtin_int
struct type * builtin_decfloat
struct type * builtin_unsigned_short
struct type * builtin_wchar
struct type * builtin_unsigned_int
struct type * builtin_decdouble
struct type * builtin_char32
struct type * builtin_unsigned_long
struct type * builtin_void
struct type * builtin_float
const struct language_defn * language_defn
struct type * type() const
void set_string_char_type(struct type *type)
void add_primitive_type(struct type *type)
void set_bool_type(struct type *type, const char *name=nullptr)
virtual void emitchar(int ch, struct type *chtype, struct ui_file *stream, int quoter) const
enum language la_language
virtual void printstr(struct ui_file *stream, struct type *elttype, const gdb_byte *string, unsigned int length, const char *encoding, int force_ellipses, const struct value_print_options *options) const
virtual void printchar(int ch, struct type *chtype, struct ui_file *stream) const
struct type * target_type() const
struct field & field(int idx) const
unsigned int num_fields() const
const char * name() const
type * index_type() const
static struct value * allocate(struct type *type)
gdb::array_view< const gdb_byte > contents()
gdb::array_view< gdb_byte > contents_raw()
struct type * type() const
enum lval_type lval() const
bool symbol_name_matcher_ftype(const char *symbol_search_name, const lookup_name_info &lookup_name, completion_match_result *comp_match_res)
int target_read_string(CORE_ADDR addr, int len, int width, unsigned int fetchlimit, gdb::unique_xmalloc_ptr< gdb_byte > *buffer, int *bytes_read)
std::string type_to_string(struct type *type)
void gdb_puts(const char *linebuffer, struct ui_file *stream)
struct value * value_cstring(const gdb_byte *ptr, ssize_t count, struct type *char_type)
void generic_emit_char(int c, struct type *type, struct ui_file *stream, int quoter, const char *encoding)
void generic_printstr(struct ui_file *stream, struct type *type, const gdb_byte *string, unsigned int length, const char *encoding, int force_ellipses, int quote_char, int c_style_terminator, const struct value_print_options *options)
CORE_ADDR value_as_address(struct value *val)
struct value * value_from_longest(struct type *type, LONGEST num)
void pack_long(gdb_byte *buf, struct type *type, LONGEST num)
LONGEST unpack_long(struct type *type, const gdb_byte *valaddr)