35#include "gdbsupport/gdb_obstack.h"
48 switch (str_type & ~
C_CHAR)
67 internal_error (_(
"unhandled c_string_type"));
78 const char **encoding)
97 if (!strcmp (
name,
"wchar_t"))
103 if (!strcmp (
name,
"char16_t"))
109 if (!strcmp (
name,
"char32_t"))
115 if (elttype->
code () != TYPE_CODE_TYPEDEF)
148 struct ui_file *stream,
int quoter)
const
150 const char *encoding;
162 c_string_type str_type;
194 const gdb_byte *
string,
unsigned int length,
195 const char *user_encoding,
int force_ellipses,
198 c_string_type str_type;
199 const char *type_encoding;
200 const char *encoding;
219 encoding = (user_encoding && *user_encoding) ? user_encoding : type_encoding;
244 int *length,
struct type **char_type,
245 const char **charset)
248 unsigned int fetchlimit;
252 enum bfd_endian byte_order
255 if (element_type == NULL)
258 if (
type->
code () == TYPE_CODE_ARRAY)
265 LONGEST low_bound, high_bound;
268 &low_bound, &high_bound);
269 fetchlimit = high_bound - low_bound + 1;
274 else if (
type->
code () == TYPE_CODE_PTR)
283 width = element_type->
length ();
300 ||
type->
code () == TYPE_CODE_ARRAY)
312 for (i = 0; i < fetchlimit; i++)
314 width, byte_order) == 0)
321 memcpy (buffer->get (), contents, *
length);
330 if (
type->
code () == TYPE_CODE_ARRAY)
333 error (_(
"Attempt to take address of value "
334 "not located in memory."));
365 if (req_length == -1)
369 width, byte_order) == 0)
378 *char_type = element_type;
385 if (!type_str.empty ())
387 error (_(
"Trying to read string with inappropriate type `%s'."),
391 error (_(
"Trying to read string with inappropriate type."));
405convert_ucn (
const char *p,
const char *limit,
const char *dest_charset,
406 struct obstack *output,
int length)
408 unsigned long result = 0;
412 for (i = 0; i <
length && p < limit && ISXDIGIT (*p); ++i, ++p)
413 result = (result << 4) + fromhex (*p);
415 for (i = 3; i >= 0; --i)
417 data[i] = result & 0xff;
432 struct obstack *output)
436 buffer = (gdb_byte *) alloca (
type->
length ());
438 obstack_grow (output, buffer,
type->
length ());
448 const char *limit,
struct obstack *output)
451 unsigned long value = 0;
454 i < 3 && p < limit && ISDIGIT (*p) && *p !=
'8' && *p !=
'9';
473 const char *limit,
struct obstack *output)
475 unsigned long value = 0;
477 while (p < limit && ISXDIGIT (*p))
492 error (_("Malformed escape sequence")); \
504 const char *p,
const char *limit,
struct obstack *output)
512 obstack_1grow (output,
'\\');
519 error (_(
"\\x used with no following hex digits."));
537 int length = *p ==
'u' ? 4 : 8;
541 error (_(
"\\u used with no following hex digits"));
557 const char *dest_charset,
struct type *
type)
565 const char *p = data;
568 while (p < limit && *p !=
'\\')
573 (
const gdb_byte *) data, p - data, 1,
591 struct value *result;
592 c_string_type dest_type;
593 const char *dest_charset;
594 int satisfy_expected = 0;
600 switch (dest_type & ~
C_CHAR)
616 internal_error (_(
"unhandled c_string_type"));
625 if (expect_type && expect_type->
code () == TYPE_CODE_ARRAY)
627 struct type *element_type
630 if (element_type->
code () == TYPE_CODE_INT
631 || element_type->
code () == TYPE_CODE_CHAR)
634 satisfy_expected = 1;
640 for (
const std::string &item : std::get<1> (
m_storage))
644 if ((dest_type &
C_CHAR) != 0)
648 if (obstack_object_size (&output) !=
type->
length ())
649 error (_(
"Could not convert character "
650 "constant to target character set"));
660 obstack_1grow (&output, 0);
662 if (satisfy_expected)
664 LONGEST low_bound, high_bound;
668 &low_bound, &high_bound))
671 high_bound = (expect_type->
length () / element_size) - 1;
673 if (obstack_object_size (&output) / element_size
674 > (high_bound - low_bound + 1))
675 error (_(
"Too many array elements"));
679 obstack_object_size (&output));
682 result =
value_cstring ((
const char *) obstack_base (&output),
683 obstack_object_size (&output),
698 while (
type->
code () == TYPE_CODE_REF)
706 case TYPE_CODE_ARRAY:
711 && array_target_type->
length () > 0
714 case TYPE_CODE_STRING:
732gdb::unique_xmalloc_ptr<char>
735 if (strchr (
name,
' ') !=
nullptr
736 || streq (
name,
"signed")
737 || streq (
name,
"unsigned"))
751 auto add = [&] (
struct type * t)
792 const char *
name ()
const override
804 static const std::vector<const char *> extensions = {
".c" };
825 const struct block *expr_block,
826 CORE_ADDR expr_pc)
const override
841 struct ui_file *stream,
int show,
int level,
873 const char *
name ()
const override
889 static const std::vector<const char *> extensions
890 = {
".C",
".cc",
".cp",
".cpp",
".cxx",
".c++" };
909 auto add = [&] (
struct type * t)
959 const struct block *expr_block,
960 CORE_ADDR expr_pc)
const override
973 (
const char *mangled,
974 gdb::unique_xmalloc_ptr<char> *demangled)
const override
976 *demangled =
gdb_demangle (mangled, DMGL_PARAMS | DMGL_ANSI);
977 return *demangled != NULL;
983 int options)
const override
998 struct ui_file *stream,
int show,
int level,
1007 CORE_ADDR pc)
const override
1075 {
return "Assembly"; }
1081 static const std::vector<const char *> extensions
1082 = {
".s",
".sx",
".S" };
1105 struct ui_file *stream,
int show,
int level,
1140 {
return "minimal"; }
1145 {
return "Minimal"; }
1164 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
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
CORE_ADDR skip_trampoline(frame_info_ptr fi, CORE_ADDR pc) 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)
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
const char * name() const
type * index_type() 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 char *ptr, ssize_t len, 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)
struct type * value_type(const struct value *value)
struct value * allocate_value(struct type *type)
CORE_ADDR value_as_address(struct value *val)
CORE_ADDR value_address(const struct value *value)
struct value * value_from_longest(struct type *type, LONGEST num)
gdb::array_view< gdb_byte > value_contents_raw(struct value *value)
gdb::array_view< const gdb_byte > value_contents(struct value *value)
void pack_long(gdb_byte *buf, struct type *type, LONGEST num)
LONGEST unpack_long(struct type *type, const gdb_byte *valaddr)