52#include "gdbsupport/format.h"
54#include "gdbsupport/byte-vector.h"
55#include "gdbsupport/gdb_optional.h"
56#include "gdbsupport/gdb-safe-ctype.h"
57#include "gdbsupport/rsp-low.h"
106 _(
"The largest offset that will be "
107 "printed in <symbol+1234> form is %s.\n"),
118 gdb_printf (file, _(
"Printing of source filename and "
119 "line number with <symbol> is %s.\n"),
137 const struct block *block_)
194 const char *p = *string_ptr;
207 if (*p >=
'0' && *p <=
'9')
208 val.
count *= atoi (p);
209 while (*p >=
'0' && *p <=
'9')
216 if (*p ==
'b' || *p ==
'h' || *p ==
'w' || *p ==
'g')
228 else if (*p >=
'a' && *p <=
'z')
234 *string_ptr = skip_spaces (p);
248 val.
format = oformat ==
'i' ?
'x' : oformat;
250 else if (val.
size ==
'?')
257 val.
size = osize ?
'a' : osize;
261 if (osize ==
'w' || osize ==
'g')
266 val.
size = osize ?
'g' : osize;
270 val.
size = osize ?
'b' : osize;
309 struct type *elttype = val->
type ();
314 stream, options) * len);
333 ||
type->
code () == TYPE_CODE_STRING
334 ||
type->
code () == TYPE_CODE_STRUCT
336 ||
type->
code () == TYPE_CODE_NAMESPACE)
378 gdb_assert (options->
format !=
's');
389 if (options->
format !=
'c'
392 if (len < type->length () && byte_order == BFD_ENDIAN_BIG)
398 const gdb_byte zero = 0;
424 error (_(
"Undefined output size \"%c\"."),
size);
426 if (newlen < len && byte_order == BFD_ENDIAN_BIG)
427 valaddr += len - newlen;
433 gdb::byte_vector converted_bytes;
437 gdb::optional<LONGEST> val_long;
439 && (options->
format ==
'o'
444 || options->
format ==
'u'))
451 byte_order, *val_long);
452 valaddr = converted_bytes.data ();
458 char format = options->
format;
459 if (format ==
'f' &&
type->
code () != TYPE_CODE_FLT)
502 if (!val_long.has_value ())
517 if (!val_long.has_value ())
524 error (_(
"Undefined output format \"%c\"."),
format);
556 int do_demangle,
const char *leadin)
558 std::string
name, filename;
564 &offset, &filename, &line, &unmapped))
580 gdb_puts (line == -1 ?
" in " :
" at ", stream);
599 bool prefer_sym_over_minsym,
602 std::string *filename,
608 CORE_ADDR name_location = 0;
610 const char *name_temp =
"";
657 if (msymbol.
minsym != NULL
665 if (msymbol.
minsym != NULL)
677 (!prefer_sym_over_minsym
679 && name_location !=
addr))
740 CORE_ADDR addr,
struct ui_file *stream)
771 struct ui_file *stream,
int do_demangle)
773 if (opts->addressprint)
797 int inst_count,
int *inst_read)
801 CORE_ADDR loop_start, loop_end, p;
802 std::vector<CORE_ADDR> pcs;
806 loop_start = loop_end = addr;
824 gdb_printf (_(
"No line number information available "
832 loop_end = loop_start;
837 for (p = loop_start; p < loop_end;)
843 inst_count -= pcs.size ();
844 *inst_read += pcs.size ();
846 while (inst_count > 0);
870 p = pcs.size () > 0 ? pcs[-inst_count] : loop_start;
876 *inst_read += inst_count;
887 CORE_ADDR memaddr, gdb_byte *myaddr,
int len)
904 for (nread = 0; nread < len; ++nread)
910 gdb_printf (_(
"Cannot access memory at address %s\n"),
926 while (i < len && x[i] == 0)
939 CORE_ADDR addr,
int count,
int char_size,
941 int *strings_counted)
943 const int chunk_size = 0x20;
946 int chars_to_read = chunk_size;
947 int chars_counted = 0;
948 int count_original = count;
949 CORE_ADDR string_start_addr = addr;
951 gdb_assert (char_size == 1 || char_size == 2 || char_size == 4);
952 gdb::byte_vector buffer (chars_to_read * char_size);
953 while (count > 0 && read_error == 0)
957 addr -= chars_to_read * char_size;
959 chars_to_read * char_size);
960 chars_read /= char_size;
961 read_error = (chars_read == chars_to_read) ? 0 : 1;
964 for (i = 0; i < chars_read && count > 0 ; ++i, ++chars_counted)
966 int offset = (chars_to_read - i - 1) * char_size;
969 || chars_counted == print_max_chars)
975 string_start_addr = addr + offset + char_size;
982 *strings_counted = count_original - count;
988 string_start_addr -= chars_counted * char_size;
991 return string_start_addr;
1003 struct type *val_type = NULL;
1007 int need_to_update_next_address = 0;
1008 CORE_ADDR addr_rewound = 0;
1034 internal_error (_(
"failed internal consistency check"));
1039 else if (
size ==
'h')
1041 else if (
size ==
'w')
1043 else if (
size ==
'g')
1048 struct type *char_type = NULL;
1054 else if (
size ==
'w')
1057 val_type = char_type;
1061 warning (_(
"Unable to display strings with "
1062 "size '%c', using 'b' instead."),
size);
1073 if (format ==
's' || format ==
'i')
1090 else if (format ==
's')
1104 addr_rewound = (format ==
's'
1107 need_to_update_next_address = 1;
1112 bool print_range_tag =
true;
1122 CORE_ADDR tag_laddr = 0, tag_haddr = 0;
1131 struct value *v_addr
1145 gdb_printf (_(
"<Allocation Tag %s for range [%s,%s)>\n"),
1151 print_range_tag =
false;
1182 if (format ==
'i' && count == 1)
1188 print_range_tag =
true;
1193 if (need_to_update_next_address)
1201 error (_(
"Size letters are meaningless in \"%s\" command."), cmdname);
1203 error (_(
"Item count other than 1 is meaningless in \"%s\" command."),
1206 error (_(
"Format letter \"%c\" is meaningless in \"%s\" command."),
1217 const char *exp = *expp;
1222 if (exp && *exp ==
'/')
1231 opts->format = fmt.
format;
1232 opts->raw = opts->raw || fmt.
raw;
1279 if (
code != TYPE_CODE_PTR
1295static struct value *
1307 const char *exp = args;
1309 if (exp !=
nullptr && *exp)
1318 parser_flags
flags = 0;
1322 return expr->evaluate ();
1337 if (voidprint || (val && val->
type () &&
1338 val->
type ()->
code () != TYPE_CODE_VOID))
1361 gdb_printf (_(
"Logical tag (%s) does not match the "
1362 "allocation tag (%s).\n"),
1363 ltag.c_str (), atag.c_str ());
1366 catch (gdb_exception_error &ex)
1368 if (ex.error == TARGET_CLOSE_ERROR)
1372 _(
"Could not validate memory tag: %s\n"),
1373 ex.message->c_str ());
1398 const char *text = *args;
1405 if (text[1] ==
'\0')
1417 text = skip_to_space (text);
1434 text = skip_spaces (text);
1451 const char *text,
const char * )
1491 if (exp && *exp ==
'/')
1501 val =
expr->evaluate ();
1525 switch (
expr->first_opcode ())
1527 case UNOP_PREINCREMENT:
1528 case UNOP_POSTINCREMENT:
1529 case UNOP_PREDECREMENT:
1530 case UNOP_POSTDECREMENT:
1532 case BINOP_ASSIGN_MODIFY:
1537 (_(
"Expression is not an assignment (and might have no effect)"));
1547 CORE_ADDR addr, sect_addr;
1549 unsigned int offset;
1565 if (osect->addr () <= sect_addr && sect_addr < osect->endaddr ()
1570 const char *obj_name, *mapped, *sec_name, *msym_name;
1571 const char *loc_string;
1576 sec_name = osect->the_bfd_section->name;
1581 std::string string_holder;
1584 string_holder = string_printf (
"%s + %u", msym_name, offset);
1585 loc_string = string_holder.c_str ();
1588 loc_string = msym_name;
1590 gdb_assert (osect->objfile &&
objfile_name (osect->objfile));
1597 "%s overlay section %s of %s\n"),
1598 loc_string, mapped, sec_name, obj_name);
1601 "section %s of %s\n"),
1602 loc_string, sec_name, obj_name);
1605 gdb_printf (_(
"%s in %s overlay section %s of %s\n"),
1606 loc_string, mapped, sec_name, obj_name);
1609 loc_string, sec_name, obj_name);
1613 gdb_printf (_(
"%s in load address range of %s overlay "
1615 loc_string, mapped, sec_name);
1618 (_(
"%s in load address range of section %s\n"),
1619 loc_string, sec_name);
1622 gdb_printf (_(
"%s in %s overlay section %s\n"),
1623 loc_string, mapped, sec_name);
1626 loc_string, sec_name);
1630 gdb_printf (_(
"No symbol matches %s.\n"), arg);
1642 CORE_ADDR load_addr, context_pc = 0;
1646 error (_(
"Argument required."));
1649 &is_a_field_of_this).
symbol;
1652 if (is_a_field_of_this.
type != NULL)
1657 gdb_printf (
"\" is a field of the local class variable ");
1667 if (msymbol.
minsym != NULL)
1680 gdb_printf (
" in a file compiled without debugging");
1695 error (_(
"No symbol \"%s\" in current context."), exp);
1741 gdb_assert_not_reached (
"LOC_COMPUTED variable missing a method");
1761 gdb_printf (_(
"static storage at address "));
1779 gdb_printf (_(
"address of an argument in register %s"),
1784 gdb_printf (_(
"an argument at offset %ld"), val);
1788 gdb_printf (_(
"a local variable at frame offset %ld"), val);
1792 gdb_printf (_(
"a reference argument at offset %ld"), val);
1830 gdb_printf (_(
"a thread-local variable at offset %s "
1831 "in the thread-local storage for `%s'"),
1838 gdb_printf (_(
"static storage at address "));
1885 if (exp && *exp ==
'/')
1887 const char *tmp = exp + 1;
1897 if (exp != 0 && *exp != 0)
1905 val =
expr->evaluate ();
1910 if (val->
type ()->
code () == TYPE_CODE_FUNC
1962 const char *text,
const char * )
1981 const char *
exp = arg;
2037 [=] (
const std::unique_ptr<struct display> &item)
2039 return item.get () == display;
2050 gdb::function_view<
void (
struct display *)> function)
2061 const char *p = parser.
cur_tok ();
2065 warning (_(
"bad display number at or near '%s'"), p);
2070 [=] (
const std::unique_ptr<display> &item)
2072 return item->number == num;
2075 gdb_printf (_(
"No display number %d.\n"), num);
2077 function (iter->get ());
2089 if (
query (_(
"Delete all auto-display expressions? ")))
2106 int within_current_scope;
2133 catch (
const gdb_exception_error &ex)
2137 warning (_(
"Unable to display \"%s\": %s"),
2149 within_current_scope = 0;
2152 within_current_scope = 1;
2153 if (!within_current_scope)
2156 scoped_restore save_display_number
2193 val = d->
exp->evaluate ();
2199 catch (
const gdb_exception_error &ex)
2231 val = d->
exp->evaluate ();
2234 catch (
const gdb_exception_error &ex)
2237 _(
"<error: %s>"), ex.what ());
2265 if (d->number == num)
2267 d->enabled_p =
false;
2270 gdb_printf (_(
"No display number %d.\n"), num);
2280 _(
"Disabling display %d to "
2281 "avoid infinite recursion.\n"),
2291 gdb_printf (_(
"There are no auto-display expressions now.\n"));
2293 gdb_printf (_(
"Auto-display expressions now in effect:\n\
2294Num Enb Expression\n"));
2298 gdb_printf (
"%d: %c ", d->number,
"ny"[(
int) d->enabled_p]);
2300 gdb_printf (
"/%d%c%c ", d->format.count, d->format.size,
2302 else if (d->format.format)
2306 gdb_printf (_(
" (cannot be evaluated in the current context)"));
2367 if (d->pspace != pspace)
2370 struct objfile *bl_objf =
nullptr;
2371 if (d->block !=
nullptr)
2373 bl_objf = d->block->
objfile ();
2379 || (d->exp !=
nullptr && d->exp->uses_objfile (
objfile)))
2399 struct ui_file *stream,
int indent)
2405 gdb_printf (stream,
"%*s%ps = ", 2 * indent,
"",
2419 opts.deref_ref =
true;
2426 catch (
const gdb_exception_error &except)
2429 "<error reading variable %s (%s)>",
name,
2445 gdb::byte_vector str;
2457 str.resize (len + 1);
2469 DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
2477 gdb_assert (str.size () == 0);
2479 for (len = 0;; len++)
2493 error (_(
"printed string requires %s bytes, which is more than "
2494 "max-value-size"), plongest (len + 1));
2499 gdb_assert (str.size () > 0);
2500 gdb_assert (str.back () == 0);
2504 DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
2518 const gdb_byte *str;
2522 "wchar_t", NULL, 0);
2523 int wcwidth = wctype->
length ();
2524 gdb::optional<gdb::byte_vector> tem_str;
2539 DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
2549 for (len = 0;; len += wcwidth)
2555 tem_str->resize (tem_str->size () + wcwidth);
2556 dst = tem_str->data () + len;
2572 dst = tem_str->data ();
2580 error (_(
"printed string requires %s bytes, which is more than "
2581 "max-value-size"), plongest (len + wcwidth));
2583 str = tem_str->data ();
2586 auto_obstack output;
2592 obstack_grow_str0 (&output,
"");
2595 DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
2596 gdb_printf (stream, format, obstack_base (&output));
2612 struct type *fmt_type;
2618 case long_double_arg:
2621 case dec32float_arg:
2624 case dec64float_arg:
2627 case dec128float_arg:
2631 gdb_assert_not_reached (
"unexpected argument class");
2654 if (fmt_type->
code () == TYPE_CODE_FLT)
2682#ifdef PRINTF_HAS_LONG_LONG
2692 const char *p = format;
2695 int is_percent = (*p ==
'%');
2697 fmt.push_back (*p++);
2701 fmt.push_back (*p++);
2708 fmt.push_back (
'#');
2712 while (*p ==
'-' || (*p >=
'0' && *p <
'9'))
2713 fmt.push_back (*p++);
2715 gdb_assert (*p ==
'p' && *(p + 1) ==
'\0');
2718#ifdef PRINTF_HAS_LONG_LONG
2719 fmt.push_back (
'l');
2721 fmt.push_back (
'l');
2722 fmt.push_back (
'x');
2724 DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
2730 fmt.push_back (
's');
2732 DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
2743 const char *s = arg;
2744 std::vector<struct value *> val_args;
2747 error_no_arg (_(
"format-control string and values to print"));
2749 s = skip_spaces (s);
2753 error (_(
"Bad format string, missing '\"'."));
2755 format_pieces fpieces (&s,
false,
true);
2758 error (_(
"Bad format string, non-terminated '\"'."));
2760 s = skip_spaces (s);
2762 if (*s !=
',' && *s != 0)
2763 error (_(
"Invalid argument syntax"));
2767 s = skip_spaces (s);
2772 const char *current_substring;
2775 for (
auto &&piece : fpieces)
2776 if (piece.argclass != literal_piece)
2794 if (val_args.size () != nargs_wanted)
2795 error (_(
"Wrong number of arguments for specified format-string"));
2799 for (
auto &&piece : fpieces)
2801 current_substring = piece.string;
2802 switch (piece.argclass)
2807 case wide_string_arg:
2814 "wchar_t", NULL, 0);
2815 struct type *valtype;
2816 const gdb_byte *bytes;
2818 valtype = val_args[i]->type ();
2820 || valtype->
code () != TYPE_CODE_INT)
2821 error (_(
"expected wchar_t argument for %%lc"));
2823 bytes = val_args[i]->contents ().data ();
2825 auto_obstack output;
2829 bytes, valtype->
length (),
2832 obstack_grow_str0 (&output,
"");
2835 DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
2837 obstack_base (&output));
2842#ifdef PRINTF_HAS_LONG_LONG
2847 DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
2853 error (_(
"long long not supported in printf"));
2860 DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
2870 DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
2880 DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
2887 case long_double_arg:
2888 case dec32float_arg:
2889 case dec64float_arg:
2890 case dec128float_arg:
2902 if (current_substring[2] ==
'[')
2904 std::string args (¤t_substring[3],
2905 strlen (¤t_substring[3]) - 1);
2907 const char *args_ptr = args.c_str ();
2917 if (*args_ptr !=
'\0')
2918 error (_(
"unexpected content in print options: %s"),
2935 DIAGNOSTIC_IGNORE_FORMAT_NONLITERAL
2940 internal_error (_(
"failed internal consistency check"));
2943 if (piece.argclass != literal_piece)
2979 error (_(
"Address %s not in a region mapped with a memory tagging flag."),
2988 error (_(
"Memory tagging not supported or disabled by the current"
3005 if (args ==
nullptr)
3022 struct value *tag_value
3065 gdb::byte_vector &tags,
3069 std::string address_string = extract_string_maybe_quoted (&args);
3076 std::string tag_string = extract_string_maybe_quoted (&args);
3079 if (address_string.empty () || tag_string.empty ())
3080 error (_(
"Missing arguments."));
3082 if (tag_string.length () != 2)
3083 error (_(
"Error parsing tags argument. The tag should be 2 digits."));
3085 tags = hex2bin (tag_string.c_str ());
3096 if (args ==
nullptr)
3099 gdb::byte_vector tags;
3125 gdb_printf (_(
"Could not update the logical tag data.\n"));
3138 size_t *length, gdb::byte_vector &tags)
3141 std::string address_string = extract_string_maybe_quoted (&args);
3149 std::string length_string = extract_string_maybe_quoted (&args);
3152 std::string tags_string = extract_string_maybe_quoted (&args);
3155 if (address_string.empty () || length_string.empty () || tags_string.empty ())
3156 error (_(
"Missing arguments."));
3159 const char *trailer =
nullptr;
3160 LONGEST parsed_length = strtoulst (length_string.c_str (), &trailer, 10);
3162 if (errno != 0 || (trailer !=
nullptr && trailer[0] !=
'\0'))
3163 error (_(
"Error parsing length argument."));
3165 if (parsed_length <= 0)
3166 error (_(
"Invalid zero or negative length."));
3168 *length = parsed_length;
3170 if (tags_string.length () % 2)
3171 error (_(
"Error parsing tags argument. Tags should be 2 digits per byte."));
3173 tags = hex2bin (tags_string.c_str ());
3190 if (args ==
nullptr)
3191 error_no_arg (_(
"<starting address> <length> <tag bytes>"));
3193 gdb::byte_vector tags;
3202 gdb_printf (_(
"Could not update the allocation tag(s).\n"));
3204 gdb_printf (_(
"Allocation tag(s) updated successfully.\n"));
3215 if (args ==
nullptr)
3244 gdb_printf (_(
"Logical tag (%s) does not match"
3245 " the allocation tag (%s) for address %s.\n"),
3246 ltag.c_str (), atag.c_str (),
3256 gdb_printf (_(
"Memory tags for address %s match (%s).\n"),
3273 _(
"Describe where symbol SYM is stored.\n\
3274Usage: info address SYM"));
3277Describe what symbol is at location ADDR.\n\
3278Usage: info symbol ADDR\n\
3279Only for symbols with fixed locations (global or static scope)."));
3282Examine memory: x/FMT ADDRESS.\n\
3283ADDRESS is an expression for the memory address to examine.\n\
3284FMT is a repeat count followed by a format letter and a size letter.\n\
3285Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\
3286 t(binary), f(float), a(address), i(instruction), c(char), s(string)\n\
3287 and z(hex, zero padded on the left).\n\
3288Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\
3289The specified number of objects of the specified size are printed\n\
3290according to the format. If a negative number is specified, memory is\n\
3291examined backward from the address.\n\n\
3292Defaults for format and size letters are those previously used.\n\
3293Default count is 1. Default address is following last thing printed\n\
3294with this command or \"print\"."));
3298Expressions to display when program stops, with code numbers.\n\
3299Usage: info display"));
3302Cancel some expressions to be displayed when program stops.\n\
3303Usage: undisplay [NUM]...\n\
3304Arguments are the code numbers of the expressions to stop displaying.\n\
3305No argument means cancel all automatic-display expressions.\n\
3306\"delete display\" has the same effect as this command.\n\
3307Do \"info display\" to see current list of code numbers."),
3311Print value of expression EXP each time the program stops.\n\
3312Usage: display[/FMT] EXP\n\
3313/FMT may be used before EXP as in the \"print\" command.\n\
3314/FMT \"i\" or \"s\" or including a size-letter is allowed,\n\
3315as in the \"x\" command, and then EXP is used to get the address to examine\n\
3316and examining is done as in the \"x\" command.\n\n\
3317With no argument, display all currently requested auto-display expressions.\n\
3318Use \"undisplay\" to cancel display requests previously made."));
3322Enable some expressions to be displayed when program stops.\n\
3323Usage: enable display [NUM]...\n\
3324Arguments are the code numbers of the expressions to resume displaying.\n\
3325No argument means enable all automatic-display expressions.\n\
3326Do \"info display\" to see current list of code numbers."), &
enablelist);
3329Disable some expressions to be displayed when program stops.\n\
3330Usage: disable display [NUM]...\n\
3331Arguments are the code numbers of the expressions to stop displaying.\n\
3332No argument means disable all automatic-display expressions.\n\
3333Do \"info display\" to see current list of code numbers."), &
disablelist);
3336Cancel some expressions to be displayed when program stops.\n\
3337Usage: delete display [NUM]...\n\
3338Arguments are the code numbers of the expressions to stop displaying.\n\
3339No argument means cancel all automatic-display expressions.\n\
3340Do \"info display\" to see current list of code numbers."), &
deletelist);
3343Formatted printing, like the C \"printf\" function.\n\
3344Usage: printf \"format string\", ARG1, ARG2, ARG3, ..., ARGN\n\
3345This supports most C printf format specifications, like %s, %d, etc."));
3348Like \"print\" but don't put in value history and don't print newline.\n\
3350This is useful in user-defined commands."));
3353Evaluate expression EXP and assign result to variable VAR.\n\
3354Usage: set VAR = EXP\n\
3355This uses assignment syntax appropriate for the current language\n\
3356(VAR = EXP or VAR := EXP for example).\n\
3357VAR may be a debugger \"convenience\" variable (names starting\n\
3358with $), a register (a few standard names starting with $), or an actual\n\
3359variable in the program being debugged. EXP is any valid expression.\n\
3360Use \"set variable\" for variables with names identical to set subcommands.\n\
3362With a subcommand, this command modifies parts of the gdb environment.\n\
3363You can see these environment settings with the \"show\" command."),
3368Call a function in the program.\n\
3370The argument is the function name and arguments, in the notation of the\n\
3371current working language. The result is printed and saved in the value\n\
3372history, if it is not void."));
3377Evaluate expression EXP and assign result to variable VAR.\n\
3378Usage: set variable VAR = EXP\n\
3379This uses assignment syntax appropriate for the current language\n\
3380(VAR = EXP or VAR := EXP for example).\n\
3381VAR may be a debugger \"convenience\" variable (names starting\n\
3382with $), a register (a few standard names starting with $), or an actual\n\
3383variable in the program being debugged. EXP is any valid expression.\n\
3384This may usually be abbreviated to simply \"set\"."),
3391Print value of expression EXP.\n\
3392Usage: print [[OPTION]... --] [/FMT] [EXP]\n\
3397Note: because this command accepts arbitrary expressions, if you\n\
3398specify any command option, you must use a double dash (\"--\")\n\
3399to mark the end of option processing. E.g.: \"print -o -- myobj\".\n\
3401Variables accessible are those of the lexical environment of the selected\n\
3402stack frame, plus all those whose scope is global or an entire file.\n\
3404$NUM gets previous value number NUM. $ and $$ are the last two values.\n\
3405$$NUM refers to NUM'th value back from the last one.\n\
3406Names starting with $ refer to registers (with the values they would have\n\
3407if the program were to return to the stack frame now selected, restoring\n\
3408all registers saved by frames farther in) or else to debugger\n\
3409\"convenience\" variables (any such name not a known register).\n\
3410Use assignment expressions to give values to convenience variables.\n\
3412{TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.\n\
3413@ is a binary operator for treating consecutive data objects\n\
3414anywhere in memory as an array. FOO@NUM gives an array whose first\n\
3415element is FOO, whose second element is stored in the space following\n\
3416where FOO is stored, etc. FOO must be an expression whose value\n\
3417resides in memory.\n\
3419EXP may be preceded with /FMT, where FMT is a format letter\n\
3420but no count or size letter (see \"x\" command)."),
3431Set the largest offset that will be printed in <SYMBOL+1234> form."), _(
"\
3432Show the largest offset that will be printed in <SYMBOL+1234> form."), _(
"\
3433Tell GDB to only display the symbolic form of an address if the\n\
3434offset between the closest earlier symbol and the address is less than\n\
3435the specified maximum offset. The default is \"unlimited\", which tells GDB\n\
3436to always print the symbolic form of an address if any symbol precedes\n\
3437it. Zero is equivalent to \"unlimited\"."),
3443Set printing of source filename and line number with <SYMBOL>."), _(
"\
3444Show printing of source filename and line number with <SYMBOL>."), NULL,
3450Construct a GDB command and then evaluate it.\n\
3451Usage: eval \"format string\", ARG1, ARG2, ARG3, ..., ARGN\n\
3452Convert the arguments to a string as \"printf\" would, but then\n\
3453treat this string as a command line, and evaluate it."));
3457Generic command for printing and manipulating memory tag properties."),
3461 (
"Print the logical tag from POINTER.\n\
3462Usage: memory-tag print-logical-tag <POINTER>.\n\
3463<POINTER> is an expression that evaluates to a pointer.\n\
3464Print the logical tag contained in POINTER. The tag interpretation is\n\
3465architecture-specific."),
3469 _(
"Print the allocation tag for ADDRESS.\n\
3470Usage: memory-tag print-allocation-tag <ADDRESS>.\n\
3471<ADDRESS> is an expression that evaluates to a memory address.\n\
3472Print the allocation tag associated with the memory address ADDRESS.\n\
3473The tag interpretation is architecture-specific."),
3476 _(
"Print a POINTER with a specific logical TAG.\n\
3477Usage: memory-tag with-logical-tag <POINTER> <TAG>\n\
3478<POINTER> is an expression that evaluates to a pointer.\n\
3479<TAG> is a sequence of hex bytes that is interpreted by the architecture\n\
3480as a single memory tag."),
3484 _(
"Set the allocation tag(s) for a memory range.\n\
3485Usage: memory-tag set-allocation-tag <ADDRESS> <LENGTH> <TAG_BYTES>\n\
3486<ADDRESS> is an expression that evaluates to a memory address\n\
3487<LENGTH> is the number of bytes that is added to <ADDRESS> to calculate\n\
3489<TAG_BYTES> is a sequence of hex bytes that is interpreted by the\n\
3490architecture as one or more memory tags.\n\
3491Sets the tags of the memory range [ADDRESS, ADDRESS + LENGTH)\n\
3494If the number of tags is greater than or equal to the number of tag granules\n\
3495in the [ADDRESS, ADDRESS + LENGTH) range, only the tags up to the\n\
3496number of tag granules are updated.\n\
3498If the number of tags is less than the number of tag granules, then the\n\
3499command is a fill operation. The TAG_BYTES are interpreted as a pattern\n\
3500that gets repeated until the number of tag granules in the memory range\n\
3501[ADDRESS, ADDRESS + LENGTH) is updated."),
3504 _(
"Validate a pointer's logical tag against the allocation tag.\n\
3505Usage: memory-tag check <POINTER>\n\
3506<POINTER> is an expression that evaluates to a pointer\n\
3507Fetch the logical and allocation tags for POINTER and compare them\n\
3508for equality. If the tags do not match, print additional information about\n\
void annotate_display_number_end(void)
void annotate_display_expression(void)
void annotate_value_end(void)
void annotate_value_history_begin(int histindex, struct type *type)
void annotate_display_end(void)
void annotate_display_value(void)
void annotate_display_begin(void)
void annotate_display_format(void)
void annotate_value_history_end(void)
void annotate_display_expression_end(void)
void annotate_value_history_value(void)
void annotate_value_begin(struct type *type)
struct gdbarch * get_current_arch(void)
struct gdbarch * target_gdbarch(void)
constexpr std::string_view s1
struct symbol * find_pc_sect_function(CORE_ADDR pc, struct obj_section *section)
bool c_is_string_type_p(struct type *type)
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)
ui_file_style style() const
void add_completion(gdb::unique_xmalloc_ptr< char > name, completion_match_for_lcd *match_for_lcd=NULL, const char *text=NULL, const char *word=NULL)
void advance_custom_word_point_by(int len)
void set_use_custom_word_point(bool enable)
const struct block * block() const
const char * cur_tok() const
const char * c_str() const
virtual void wrap_here(int indent)
struct cmd_list_element * showprintlist
struct cmd_list_element * deletelist
void error_no_arg(const char *why)
struct cmd_list_element * cmdlist
struct cmd_list_element * setprintlist
struct cmd_list_element * setlist
struct cmd_list_element * disablelist
struct cmd_list_element * enablelist
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *target, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
void set_cmd_completer_handle_brkchars(struct cmd_list_element *cmd, completer_handle_brkchars_ftype *func)
cmd_list_element * add_com_alias(const char *name, cmd_list_element *target, command_class theclass, int abbrev_flag)
void help_list(struct cmd_list_element *list, const char *cmdtype, enum command_class theclass, struct ui_file *stream)
struct cmd_list_element * add_com(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc)
set_show_commands add_setshow_uinteger_cmd(const char *name, enum command_class theclass, unsigned int *var, const literal_def *extra_literals, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct cmd_list_element * add_prefix_cmd(const char *name, enum command_class theclass, cmd_simple_func_ftype *fun, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list)
set_show_commands add_setshow_boolean_cmd(const char *name, enum command_class theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct cmd_list_element * add_info(const char *name, cmd_simple_func_ftype *fun, const char *doc)
std::string insert_user_defined_cmd_args(const char *line)
cli_style_option address_style
cli_style_option function_name_style
cli_style_option variable_name_style
cli_style_option file_name_style
cli_style_option metadata_style
void set_repeat_arguments(const char *args)
void expression_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *word)
const char * advance_to_expression_complete_word_point(completion_tracker &tracker, const char *text)
void read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
static void store_signed_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, LONGEST val)
static ULONGEST extract_unsigned_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
int gdb_print_insn(struct gdbarch *gdbarch, CORE_ADDR memaddr, struct ui_file *stream, int *branch_delay_insns)
int gdb_insn_length(struct gdbarch *gdbarch, CORE_ADDR addr)
struct value * parse_to_comma_and_eval(const char **expp)
CORE_ADDR parse_and_eval_address(const char *exp)
std::unique_ptr< expression > expression_up
expression_up parse_expression(const char *, innermost_block_tracker *=nullptr, parser_flags flags=0)
struct value * read_var_value(struct symbol *var, const struct block *var_block, frame_info_ptr frame)
bool get_frame_pc_if_available(frame_info_ptr frame, CORE_ADDR *pc)
frame_info_ptr get_selected_frame(const char *message)
const struct block * get_selected_block(CORE_ADDR *addr_in_block)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
const char * gdbarch_register_name(struct gdbarch *gdbarch, int regnr)
std::string gdbarch_memtag_to_string(struct gdbarch *gdbarch, struct value *tag)
int gdbarch_addr_bit(struct gdbarch *gdbarch)
bool gdbarch_set_memtags(struct gdbarch *gdbarch, struct value *address, size_t length, const gdb::byte_vector &tags, memtag_type tag_type)
struct value * gdbarch_get_memtag(struct gdbarch *gdbarch, struct value *address, memtag_type tag_type)
bool gdbarch_tagged_address_p(struct gdbarch *gdbarch, struct value *address)
bool gdbarch_memtag_matches_p(struct gdbarch *gdbarch, struct value *address)
CORE_ADDR gdbarch_memtag_granule_size(struct gdbarch *gdbarch)
CORE_ADDR gdbarch_addr_bits_remove(struct gdbarch *gdbarch, CORE_ADDR addr)
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
void execute_command(const char *, int)
enum bfd_endian type_byte_order(const struct type *type)
struct type * lookup_pointer_type(struct type *type)
struct type * lookup_typename(const struct language_defn *language, const char *name, const struct block *block, int noerr)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
bool is_fixed_point_type(struct type *type)
struct type * check_typedef(struct type *type)
#define TYPE_IS_REFERENCE(t)
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
const struct language_defn * current_language
bound_minimal_symbol lookup_minimal_symbol_by_pc_section(CORE_ADDR pc_in, struct obj_section *section, lookup_msym_prefer prefer, bound_minimal_symbol *previous)
struct bound_minimal_symbol lookup_bound_minimal_symbol(const char *name)
observable< struct objfile * > free_objfile
bool process_options(const char **args, process_options_mode mode, gdb::array_view< const option_def_group > options_group)
@ PROCESS_OPTIONS_REQUIRE_DELIMITER
@ PROCESS_OPTIONS_UNKNOWN_IS_ERROR
std::string build_help(const char *help_tmpl, gdb::array_view< const option_def_group > options_group)
bool complete_options(completion_tracker &tracker, const char **args, process_options_mode mode, gdb::array_view< const option_def_group > options_group)
const char * objfile_name(const struct objfile *objfile)
void print_scalar_formatted(const gdb_byte *valaddr, struct type *type, const struct value_print_options *options, int size, struct ui_file *stream)
static CORE_ADDR last_examine_address
int build_address_symbolic(struct gdbarch *gdbarch, CORE_ADDR addr, bool do_demangle, bool prefer_sym_over_minsym, std::string *name, int *offset, std::string *filename, int *line, int *unmapped)
static void undisplay_command(const char *args, int from_tty)
static bool print_symbol_filename
void set_next_address(struct gdbarch *gdbarch, CORE_ADDR addr)
static void parse_with_logical_tag_input(const char *args, struct value **val, gdb::byte_vector &tags, value_print_options *print_opts)
static void enable_display_command(const char *args, int from_tty)
static void printf_floating(struct ui_file *stream, const char *format, struct value *value, enum argclass argclass)
static void eval_command(const char *arg, int from_tty)
static value_ref_ptr last_examine_value
static void disable_display_command(const char *args, int from_tty)
static void do_one_display(struct display *)
static void printf_pointer(struct ui_file *stream, const char *format, struct value *value)
void _initialize_printcmd()
int print_address_symbolic(struct gdbarch *gdbarch, CORE_ADDR addr, struct ui_file *stream, int do_demangle, const char *leadin)
static void memory_tag_print_logical_tag_command(const char *args, int from_tty)
static void info_display_command(const char *ignore, int from_tty)
static void printf_c_string(struct ui_file *stream, const char *format, struct value *value)
static void ui_printf(const char *arg, struct ui_file *stream)
static void info_address_command(const char *exp, int from_tty)
static bool last_print_tags
static void display_command(const char *arg, int from_tty)
static void memory_tag_command(const char *arg, int from_tty)
static struct type * float_type_from_length(struct type *type)
void disable_display(int num)
static void show_print_symbol_filename(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static int branch_delay_insns
static struct cmd_list_element * memory_tag_list
static struct format_data decode_format(const char **string_ptr, int oformat, int osize)
static int integer_is_zero(const gdb_byte *x, int len)
static void set_command(const char *exp, int from_tty)
static void printf_wide_c_string(struct ui_file *stream, const char *format, struct value *value)
static void enable_disable_display_command(const char *args, int from_tty, bool enable)
static void printf_command(const char *arg, int from_tty)
static bool should_validate_memtags(struct value *value)
static CORE_ADDR find_instruction_backward(struct gdbarch *gdbarch, CORE_ADDR addr, int inst_count, int *inst_read)
static void memory_tag_set_allocation_tag_command(const char *args, int from_tty)
void print_command_parse_format(const char **expp, const char *cmdname, value_print_options *opts)
static CORE_ADDR next_address
static void print_formatted(struct value *val, int size, const struct value_print_options *options, struct ui_file *stream)
void disable_current_display(void)
static struct gdbarch * next_gdbarch
static void show_max_symbolic_offset(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
static void clear_dangling_display_expressions(struct objfile *objfile)
static unsigned int max_symbolic_offset
const char * pc_prefix(CORE_ADDR addr)
static CORE_ADDR find_string_backward(struct gdbarch *gdbarch, CORE_ADDR addr, int count, int char_size, const struct value_print_options *options, int *strings_counted)
static void memory_tag_with_logical_tag_command(const char *args, int from_tty)
static std::vector< std::unique_ptr< struct display > > all_displays
static void show_addr_not_tagged(CORE_ADDR address)
static void validate_format(struct format_data fmt, const char *cmdname)
void print_value(value *val, const value_print_options &opts)
static void print_command(const char *exp, int from_tty)
static void memory_tag_print_allocation_tag_command(const char *args, int from_tty)
static int display_number
static bool skip_over_slash_fmt(completion_tracker &tracker, const char **args)
void print_command_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *)
void print_variable_and_value(const char *name, struct symbol *var, frame_info_ptr frame, struct ui_file *stream, int indent)
static void delete_display(struct display *display)
int print_address_demangle(const struct value_print_options *opts, struct gdbarch *gdbarch, CORE_ADDR addr, struct ui_file *stream, int do_demangle)
static void memory_tag_check_command(const char *args, int from_tty)
static void print_command_1(const char *args, int voidprint)
static void parse_set_allocation_tag_input(const char *args, struct value **val, size_t *length, gdb::byte_vector &tags)
static void map_display_numbers(const char *args, gdb::function_view< void(struct display *)> function)
static void memory_tag_print_tag_command(const char *args, enum memtag_type tag_type)
static int current_display_number
static void do_examine(struct format_data fmt, struct gdbarch *gdbarch, CORE_ADDR addr)
void output_command(const char *exp, int from_tty)
void print_address(struct gdbarch *gdbarch, CORE_ADDR addr, struct ui_file *stream)
static void show_memory_tagging_unsupported(void)
static void call_command(const char *exp, int from_tty)
static void x_command(const char *exp, int from_tty)
static void info_symbol_command(const char *arg, int from_tty)
static struct value * process_print_command_args(const char *args, value_print_options *print_opts, bool voidprint)
static void display_and_x_command_completer(struct cmd_list_element *ignore, completion_tracker &tracker, const char *text, const char *)
static int read_memory_backward(struct gdbarch *gdbarch, CORE_ADDR memaddr, gdb_byte *myaddr, int len)
struct program_space * current_program_space
const char * symtab_to_filename_for_display(struct symtab *symtab)
bool contains(const struct block *a, bool allow_nested=false) const
CORE_ADDR entry_pc() const
CORE_ADDR value_address() const
struct minimal_symbol * minsym
struct obj_section * obj_section() const
struct type * builtin_declong
struct type * builtin_double
struct type * builtin_int8
struct type * builtin_data_ptr
struct type * builtin_true_unsigned_char
struct type * builtin_long_double
struct type * builtin_char16
struct type * builtin_int64
struct type * builtin_decfloat
struct type * builtin_int32
struct type * builtin_decdouble
struct type * builtin_char32
struct type * builtin_half
struct type * builtin_int16
struct type * builtin_float
struct type * builtin_true_char
display(const char *exp_string_, expression_up &&exp_, const struct format_data &format_, struct program_space *pspace_, const struct block *block_)
const struct block * block
struct format_data format
struct program_space * pspace
const char * print_name() const
struct obj_section * obj_section(const struct objfile *objfile) const
const char * linkage_name() const
enum language la_language
unsigned long size() const
minimal_symbol_type type() const
CORE_ADDR value_address(objfile *objfile) const
unrelocated_addr unrelocated_address() const
struct bfd_section * the_bfd_section
iterator_range< section_iterator > sections()
struct objfile * separate_debug_objfile_backlink
struct program_space * pspace
struct gdbarch * arch() const
objfile(gdb_bfd_ref_ptr, const char *, objfile_flags)
objfiles_range objfiles()
bool multi_objfile_p() const
const block * value_block() const
address_class aclass() const
LONGEST value_longest() const
bool is_objfile_owned() const
CORE_ADDR value_address() const
struct objfile * objfile() const
struct obj_section * section
struct type * pointer_type
bool bit_size_differs_p() const
range_bounds * bounds() const
const ui_file_style * ptr() const
bool memory_tag_violations
gdb::array_view< const gdb_byte > contents()
bool entirely_available()
struct type * type() const
enum lval_type lval() const
struct obj_section * find_pc_overlay(CORE_ADDR pc)
CORE_ADDR overlay_unmapped_address(CORE_ADDR pc, struct obj_section *section)
int section_is_mapped(struct obj_section *osect)
bool pc_in_unmapped_range(CORE_ADDR pc, struct obj_section *section)
CORE_ADDR overlay_mapped_address(CORE_ADDR pc, struct obj_section *section)
int section_is_overlay(struct obj_section *section)
enum overlay_debugging_state overlay_debugging
struct block_symbol lookup_symbol(const char *name, const struct block *block, domain_enum domain, struct field_of_this_result *is_a_field_of_this)
struct symtab_and_line find_pc_sect_line(CORE_ADDR pc, struct obj_section *section, int notcurrent)
#define SYMBOL_COMPUTED_OPS(symbol)
#define SYMBOL_REGISTER_OPS(symbol)
std::string target_float_to_string(const gdb_byte *addr, const struct type *type, const char *format)
bool target_supports_memory_tagging()
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
static styled_string_s * styled_string(const ui_file_style &style, const char *str, styled_string_s &&tmp={})
int query(const char *ctlstr,...)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
void fprintf_styled(struct ui_file *stream, const ui_file_style &style, const char *format,...)
void gdb_printf(struct ui_file *stream, const char *format,...)
void fputs_styled(const char *linebuffer, const ui_file_style &style, struct ui_file *stream)
void fprintf_symbol(struct ui_file *stream, const char *name, enum language lang, int arg_mode)
void gdb_flush(struct ui_file *stream)
void gdb_puts(const char *linebuffer, struct ui_file *stream)
struct value * value_at_lazy(struct type *type, CORE_ADDR addr, frame_info_ptr frame)
struct value * value_cast(struct type *type, struct value *arg2)
void get_formatted_print_options(struct value_print_options *opts, char format)
void value_print(struct value *val, struct ui_file *stream, const struct value_print_options *options)
void value_print_scalar_formatted(struct value *val, const struct value_print_options *options, int size, struct ui_file *stream)
void print_decimal_chars(struct ui_file *stream, const gdb_byte *valaddr, unsigned len, bool is_signed, enum bfd_endian byte_order)
void print_octal_chars(struct ui_file *stream, const gdb_byte *valaddr, unsigned len, enum bfd_endian byte_order)
gdb::option::option_def_group make_value_print_options_def_group(value_print_options *opts)
int val_print_string(struct type *elttype, const char *encoding, CORE_ADDR addr, int len, struct ui_file *stream, const struct value_print_options *options)
void get_user_print_options(struct value_print_options *opts)
void common_val_print_checked(struct value *val, struct ui_file *stream, int recurse, const struct value_print_options *options, const struct language_defn *language)
void print_hex_chars(struct ui_file *stream, const gdb_byte *valaddr, unsigned len, enum bfd_endian byte_order, bool zero_pad)
void print_floating(const gdb_byte *valaddr, struct type *type, struct ui_file *stream)
void print_binary_chars(struct ui_file *stream, const gdb_byte *valaddr, unsigned len, enum bfd_endian byte_order, bool zero_pad, const struct value_print_options *options)
static unsigned int get_print_max_chars(const struct value_print_options *options)
void clear_internalvar(struct internalvar *var)
CORE_ADDR value_as_address(struct value *val)
struct value * value_from_ulongest(struct type *type, ULONGEST num)
struct value * value_from_longest(struct type *type, LONGEST num)
struct value * coerce_ref(struct value *arg)
struct value * value_from_contents(struct type *type, const gdb_byte *contents)
void set_internalvar(struct internalvar *var, struct value *val)
struct internalvar * lookup_internalvar(const char *name)
LONGEST value_as_long(struct value *val)
bool exceeds_max_value_size(ULONGEST length)
struct value * value_from_pointer(struct type *type, CORE_ADDR addr)
struct value * access_value_history(int num)
value_ref_ptr release_value(struct value *val)
LONGEST unpack_long(struct type *type, const gdb_byte *valaddr)
gdb::ref_ptr< struct value, value_ref_policy > value_ref_ptr