diff options
author | Pedro Alves <palves@redhat.com> | 2019-06-07 22:45:09 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2019-07-01 14:07:58 +0100 |
commit | ebcc5fb83fb0c6e98db2501c5868ba8cee6dd1f8 (patch) | |
tree | 87214c30bd185cb519d7aef6d14471608577581e /gdb/ui-out.h | |
parent | fd5bce2ea4716552ce9c3f9fdac7628cbf5a5cd2 (diff) | |
download | binutils-gdb-users/palves/format_strings-experiment.tar.gz |
string_fieldusers/palves/format_strings-experiment
Diffstat (limited to 'gdb/ui-out.h')
-rw-r--r-- | gdb/ui-out.h | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/gdb/ui-out.h b/gdb/ui-out.h index fbf9c9bd326..e682d44383e 100644 --- a/gdb/ui-out.h +++ b/gdb/ui-out.h @@ -68,11 +68,24 @@ enum ui_out_type ui_out_type_list }; +enum class field_kind + { + INT, + STRING, + }; + /* An int field, to be passed to %pF in format strings. */ -struct int_field_s +struct base_field_s { const char *name; + field_kind kind; +}; + +/* An int field, to be passed to %pF in format strings. */ + +struct int_field_s : base_field_s +{ int val; }; @@ -85,10 +98,32 @@ int_field (const char *name, int val, int_field_s &&tmp = {}) { tmp.name = name; + tmp.kind = field_kind::INT; tmp.val = val; return &tmp; } +/* A string field, to be passed to %pF in format strings. */ + +struct string_field_s : base_field_s +{ + const char *str; +}; + +/* Construct a temporary string_field_s on the caller's stack and + return a pointer to the constructed object. We use this because + it's not possible to pass a reference via va_args. */ + +static inline string_field_s * +string_field (const char *name, const char *str, + string_field_s &&tmp = {}) +{ + tmp.name = name; + tmp.kind = field_kind::STRING; + tmp.str = str; + return &tmp; +} + /* A styled string. */ struct styled_string_s |