* [PATCH 1/2] Remove parameter valaddr from c print functions
@ 2016-11-10 14:54 Yao Qi
2016-11-10 14:54 ` [PATCH 2/2] Remove apply_val_pretty_printer parameter valaddr Yao Qi
2016-11-10 17:54 ` [PATCH 1/2] Remove parameter valaddr from c print functions Doug Evans
0 siblings, 2 replies; 5+ messages in thread
From: Yao Qi @ 2016-11-10 14:54 UTC (permalink / raw)
To: gdb-patches
This patch removes parameter valaddr from some c print functions.
Regression tested on x86_64-linux.
gdb:
2016-11-10 Yao Qi <yao.qi@linaro.org>
* c-lang.h (cp_print_value_fields): Update declaration.
* cp-valprint.c (cp_print_value): Update declaration.
(cp_print_value_fields): Remove parameter valaddr. Callers
updated.
(cp_print_value): Likewise.
---
gdb/c-lang.h | 2 +-
gdb/cp-valprint.c | 16 +++++++++-------
gdb/m2-valprint.c | 2 +-
3 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/gdb/c-lang.h b/gdb/c-lang.h
index 25cd93c..b898b708 100644
--- a/gdb/c-lang.h
+++ b/gdb/c-lang.h
@@ -123,7 +123,7 @@ extern void cp_print_class_member (const gdb_byte *, struct type *,
struct ui_file *, char *);
extern void cp_print_value_fields (struct type *, struct type *,
- const gdb_byte *, LONGEST, CORE_ADDR,
+ LONGEST, CORE_ADDR,
struct ui_file *, int,
struct value *,
const struct value_print_options *,
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 82e505a..57d5d02 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -80,7 +80,7 @@ static void cp_print_static_field (struct type *, struct value *,
const struct value_print_options *);
static void cp_print_value (struct type *, struct type *,
- const gdb_byte *, LONGEST,
+ LONGEST,
CORE_ADDR, struct ui_file *,
int, struct value *,
const struct value_print_options *,
@@ -154,7 +154,7 @@ cp_is_vtbl_member (struct type *type)
void
cp_print_value_fields (struct type *type, struct type *real_type,
- const gdb_byte *valaddr, LONGEST offset,
+ LONGEST offset,
CORE_ADDR address, struct ui_file *stream,
int recurse, struct value *val,
const struct value_print_options *options,
@@ -194,7 +194,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
duplicates of virtual baseclasses. */
if (n_baseclasses > 0)
- cp_print_value (type, real_type, valaddr,
+ cp_print_value (type, real_type,
offset, address, stream,
recurse + 1, val, options,
dont_print_vb);
@@ -228,6 +228,8 @@ cp_print_value_fields (struct type *type, struct type *real_type,
vptr_fieldno = get_vptr_fieldno (type, &vptr_basetype);
for (i = n_baseclasses; i < len; i++)
{
+ const gdb_byte *valaddr = value_contents_for_printing (val);
+
/* If requested, skip printing of static fields. */
if (!options->static_field_print
&& field_is_static (&TYPE_FIELD (type, i)))
@@ -449,7 +451,7 @@ cp_print_value_fields_rtti (struct type *type,
if (!real_type)
real_type = type;
- cp_print_value_fields (type, real_type, valaddr, offset,
+ cp_print_value_fields (type, real_type, offset,
address, stream, recurse, val, options,
dont_print_vb, dont_print_statmem);
}
@@ -459,7 +461,7 @@ cp_print_value_fields_rtti (struct type *type,
static void
cp_print_value (struct type *type, struct type *real_type,
- const gdb_byte *valaddr, LONGEST offset,
+ LONGEST offset,
CORE_ADDR address, struct ui_file *stream,
int recurse, struct value *val,
const struct value_print_options *options,
@@ -471,6 +473,7 @@ cp_print_value (struct type *type, struct type *real_type,
int i, n_baseclasses = TYPE_N_BASECLASSES (type);
LONGEST thisoffset;
struct type *thistype;
+ const gdb_byte *valaddr = value_contents_for_printing (val);
if (dont_print_vb == 0)
{
@@ -596,7 +599,7 @@ cp_print_value (struct type *type, struct type *real_type,
current_language);
if (!result)
- cp_print_value_fields (baseclass, thistype, base_valaddr,
+ cp_print_value_fields (baseclass, thistype,
thisoffset + boffset,
value_address (base_val),
stream, recurse, base_val, options,
@@ -671,7 +674,6 @@ cp_print_static_field (struct type *type,
sizeof (CORE_ADDR));
type = check_typedef (type);
cp_print_value_fields (type, value_enclosing_type (val),
- value_contents_for_printing (val),
value_embedded_offset (val), addr,
stream, recurse, val,
options, NULL, 1);
diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index f43a2d2..50c2b30 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -398,7 +398,7 @@ m2_val_print (struct type *type, int embedded_offset,
m2_print_unbounded_array (type, valaddr, embedded_offset,
address, stream, recurse, options);
else
- cp_print_value_fields (type, type, valaddr, embedded_offset,
+ cp_print_value_fields (type, type, embedded_offset,
address, stream, recurse, original_value,
options, NULL, 0);
break;
--
1.9.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] Remove apply_val_pretty_printer parameter valaddr
2016-11-10 14:54 [PATCH 1/2] Remove parameter valaddr from c print functions Yao Qi
@ 2016-11-10 14:54 ` Yao Qi
2016-11-10 17:53 ` Doug Evans
2016-11-10 17:54 ` [PATCH 1/2] Remove parameter valaddr from c print functions Doug Evans
1 sibling, 1 reply; 5+ messages in thread
From: Yao Qi @ 2016-11-10 14:54 UTC (permalink / raw)
To: gdb-patches
This patch removes the parameter valaddr of
extension_language_ops::apply_val_pretty_printer and remove const from
"struct value *val". valaddr can be got in each extension language's
implementation of apply_val_pretty_printer.
gdb:
2016-11-10 Yao Qi <yao.qi@linaro.org>
* cp-valprint.c (cp_print_value): Remove local base_valaddr.
* extension-priv.h (struct extension_language_ops)
<apply_val_pretty_printer>: Remove the second parameter.
Remove const from "struct value *". Callers updated.
* extension.c (apply_ext_lang_val_pretty_printer): Update
comments. Remove parameter valaddr. Remove const from
"struct value *".
* extension.h (apply_ext_lang_val_pretty_printer): Update
declaration.
* guile/guile-internal.h (gdbscm_apply_val_pretty_printer):
Update declaration.
* guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer):
Remove parameter valaddr. Remove const from "struct value *".
* python/py-prettyprint.c (gdbpy_apply_val_pretty_printer):
Likewise.
* python/python-internal.h (gdbpy_apply_val_pretty_printer):
Update declaration.
---
gdb/cp-valprint.c | 6 +-----
gdb/extension-priv.h | 14 +++++++-------
gdb/extension.c | 16 ++++++++--------
gdb/extension.h | 4 ++--
gdb/guile/guile-internal.h | 4 ++--
gdb/guile/scm-pretty-print.c | 9 ++++-----
gdb/python/py-prettyprint.c | 9 ++++-----
gdb/python/python-internal.h | 4 ++--
gdb/valprint.c | 5 +----
9 files changed, 31 insertions(+), 40 deletions(-)
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 57d5d02..9432c83 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -490,7 +490,6 @@ cp_print_value (struct type *type, struct type *real_type,
int skip = 0;
struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
const char *basename = TYPE_NAME (baseclass);
- const gdb_byte *base_valaddr = NULL;
struct value *base_val = NULL;
if (BASETYPE_VIA_VIRTUAL (type, i))
@@ -551,18 +550,15 @@ cp_print_value (struct type *type, struct type *real_type,
thisoffset = 0;
boffset = 0;
thistype = baseclass;
- base_valaddr = value_contents_for_printing_const (base_val);
do_cleanups (back_to);
}
else
{
- base_valaddr = valaddr;
base_val = val;
}
}
else
{
- base_valaddr = valaddr;
base_val = val;
}
}
@@ -591,7 +587,7 @@ cp_print_value (struct type *type, struct type *real_type,
baseclass if possible. */
if (!options->raw)
result
- = apply_ext_lang_val_pretty_printer (baseclass, base_valaddr,
+ = apply_ext_lang_val_pretty_printer (baseclass,
thisoffset + boffset,
value_address (base_val),
stream, recurse,
diff --git a/gdb/extension-priv.h b/gdb/extension-priv.h
index 26bd21f..161d99b 100644
--- a/gdb/extension-priv.h
+++ b/gdb/extension-priv.h
@@ -171,19 +171,19 @@ struct extension_language_ops
void (*free_type_printers) (const struct extension_language_defn *,
struct ext_lang_type_printers *);
- /* Try to pretty-print a value of type TYPE located at VALADDR
- + EMBEDDED_OFFSET, which came from the inferior at address ADDRESS
- + EMBEDDED_OFFSET, onto stdio stream STREAM according to OPTIONS.
- VAL is the whole object that came from ADDRESS. VALADDR must point to
- the head of VAL's contents buffer.
+ /* Try to pretty-print a value of type TYPE located at VAL's contents
+ buffer + EMBEDDED_OFFSET, which came from the inferior at address
+ ADDRESS + EMBEDDED_OFFSET, onto stdio stream STREAM according to
+ OPTIONS.
+ VAL is the whole object that came from ADDRESS.
Returns EXT_LANG_RC_OK upon success, EXT_LANG_RC_NOP if the value
is not recognized, and EXT_LANG_RC_ERROR if an error was encountered. */
enum ext_lang_rc (*apply_val_pretty_printer)
(const struct extension_language_defn *,
- struct type *type, const gdb_byte *valaddr,
+ struct type *type,
LONGEST embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
- const struct value *val, const struct value_print_options *options,
+ struct value *val, const struct value_print_options *options,
const struct language_defn *language);
/* GDB access to the "frame filter" feature.
diff --git a/gdb/extension.c b/gdb/extension.c
index c9f5664..40c63a6 100644
--- a/gdb/extension.c
+++ b/gdb/extension.c
@@ -478,11 +478,11 @@ free_ext_lang_type_printers (struct ext_lang_type_printers *printers)
xfree (printers);
}
\f
-/* Try to pretty-print a value of type TYPE located at VALADDR
- + EMBEDDED_OFFSET, which came from the inferior at address ADDRESS
- + EMBEDDED_OFFSET, onto stdio stream STREAM according to OPTIONS.
- VAL is the whole object that came from ADDRESS. VALADDR must point to
- the head of VAL's contents buffer.
+/* Try to pretty-print a value of type TYPE located at VAL's contents
+ buffer + EMBEDDED_OFFSET, which came from the inferior at address
+ ADDRESS + EMBEDDED_OFFSET, onto stdio stream STREAM according to
+ OPTIONS.
+ VAL is the whole object that came from ADDRESS.
Returns non-zero if the value was successfully pretty-printed.
Extension languages are tried in the order specified by
@@ -496,10 +496,10 @@ free_ext_lang_type_printers (struct ext_lang_type_printers *printers)
errors that trigger an exception in the extension language. */
int
-apply_ext_lang_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
+apply_ext_lang_val_pretty_printer (struct type *type,
LONGEST embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
- const struct value *val,
+ struct value *val,
const struct value_print_options *options,
const struct language_defn *language)
{
@@ -512,7 +512,7 @@ apply_ext_lang_val_pretty_printer (struct type *type, const gdb_byte *valaddr,
if (extlang->ops->apply_val_pretty_printer == NULL)
continue;
- rc = extlang->ops->apply_val_pretty_printer (extlang, type, valaddr,
+ rc = extlang->ops->apply_val_pretty_printer (extlang, type,
embedded_offset, address,
stream, recurse, val,
options, language);
diff --git a/gdb/extension.h b/gdb/extension.h
index fa11f25..66bcb03 100644
--- a/gdb/extension.h
+++ b/gdb/extension.h
@@ -225,10 +225,10 @@ extern char *apply_ext_lang_type_printers (struct ext_lang_type_printers *,
extern void free_ext_lang_type_printers (struct ext_lang_type_printers *);
extern int apply_ext_lang_val_pretty_printer
- (struct type *type, const gdb_byte *valaddr,
+ (struct type *type,
LONGEST embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
- const struct value *val, const struct value_print_options *options,
+ struct value *val, const struct value_print_options *options,
const struct language_defn *language);
extern enum ext_lang_bt_status apply_ext_lang_frame_filter
diff --git a/gdb/guile/guile-internal.h b/gdb/guile/guile-internal.h
index 5f819b8..3865f77 100644
--- a/gdb/guile/guile-internal.h
+++ b/gdb/guile/guile-internal.h
@@ -597,10 +597,10 @@ extern void gdbscm_preserve_values
extern enum ext_lang_rc gdbscm_apply_val_pretty_printer
(const struct extension_language_defn *,
- struct type *type, const gdb_byte *valaddr,
+ struct type *type,
LONGEST embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
- const struct value *val,
+ struct value *val,
const struct value_print_options *options,
const struct language_defn *language);
diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c
index afdd0c7..5253def 100644
--- a/gdb/guile/scm-pretty-print.c
+++ b/gdb/guile/scm-pretty-print.c
@@ -957,10 +957,10 @@ ppscm_print_children (SCM printer, enum display_hint hint,
enum ext_lang_rc
gdbscm_apply_val_pretty_printer (const struct extension_language_defn *extlang,
- struct type *type, const gdb_byte *valaddr,
+ struct type *type,
LONGEST embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
- const struct value *val,
+ struct value *val,
const struct value_print_options *options,
const struct language_defn *language)
{
@@ -973,6 +973,7 @@ gdbscm_apply_val_pretty_printer (const struct extension_language_defn *extlang,
struct cleanup *cleanups;
enum ext_lang_rc result = EXT_LANG_RC_NOP;
enum string_repr_result print_result;
+ const gdb_byte *valaddr = value_contents_for_printing (val);
/* No pretty-printer support for unavailable values. */
if (!value_bytes_available (val, embedded_offset, TYPE_LENGTH (type)))
@@ -984,9 +985,7 @@ gdbscm_apply_val_pretty_printer (const struct extension_language_defn *extlang,
cleanups = make_cleanup (null_cleanup, NULL);
/* Instantiate the printer. */
- if (valaddr)
- valaddr += embedded_offset;
- value = value_from_contents_and_address (type, valaddr,
+ value = value_from_contents_and_address (type, valaddr + embedded_offset,
address + embedded_offset);
set_value_component_location (value, val);
diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c
index 8834344..cc8f0f9 100644
--- a/gdb/python/py-prettyprint.c
+++ b/gdb/python/py-prettyprint.c
@@ -702,10 +702,10 @@ print_children (PyObject *printer, const char *hint,
enum ext_lang_rc
gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang,
- struct type *type, const gdb_byte *valaddr,
+ struct type *type,
LONGEST embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
- const struct value *val,
+ struct value *val,
const struct value_print_options *options,
const struct language_defn *language)
{
@@ -717,6 +717,7 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang,
struct cleanup *cleanups;
enum ext_lang_rc result = EXT_LANG_RC_NOP;
enum string_repr_result print_result;
+ const gdb_byte *valaddr = value_contents_for_printing (val);
/* No pretty-printer support for unavailable values. */
if (!value_bytes_available (val, embedded_offset, TYPE_LENGTH (type)))
@@ -728,9 +729,7 @@ gdbpy_apply_val_pretty_printer (const struct extension_language_defn *extlang,
cleanups = ensure_python_env (gdbarch, language);
/* Instantiate the printer. */
- if (valaddr)
- valaddr += embedded_offset;
- value = value_from_contents_and_address (type, valaddr,
+ value = value_from_contents_and_address (type, valaddr + embedded_offset,
address + embedded_offset);
set_value_component_location (value, val);
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h
index 8545c7b..3458724 100644
--- a/gdb/python/python-internal.h
+++ b/gdb/python/python-internal.h
@@ -315,10 +315,10 @@ extern int gdbpy_auto_load_enabled (const struct extension_language_defn *);
extern enum ext_lang_rc gdbpy_apply_val_pretty_printer
(const struct extension_language_defn *,
- struct type *type, const gdb_byte *valaddr,
+ struct type *type,
LONGEST embedded_offset, CORE_ADDR address,
struct ui_file *stream, int recurse,
- const struct value *val,
+ struct value *val,
const struct value_print_options *options,
const struct language_defn *language);
extern enum ext_lang_bt_status gdbpy_apply_frame_filter
diff --git a/gdb/valprint.c b/gdb/valprint.c
index b18ece3..c0cdb34 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1098,9 +1098,7 @@ val_print (struct type *type, LONGEST embedded_offset,
if (!options->raw)
{
- const gdb_byte *valaddr = value_contents_for_printing (val);
-
- ret = apply_ext_lang_val_pretty_printer (type, valaddr, embedded_offset,
+ ret = apply_ext_lang_val_pretty_printer (type, embedded_offset,
address, stream, recurse,
val, options, language);
if (ret)
@@ -1223,7 +1221,6 @@ value_print (struct value *val, struct ui_file *stream,
{
int r
= apply_ext_lang_val_pretty_printer (value_type (val),
- value_contents_for_printing (val),
value_embedded_offset (val),
value_address (val),
stream, 0,
--
1.9.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] Remove apply_val_pretty_printer parameter valaddr
2016-11-10 14:54 ` [PATCH 2/2] Remove apply_val_pretty_printer parameter valaddr Yao Qi
@ 2016-11-10 17:53 ` Doug Evans
0 siblings, 0 replies; 5+ messages in thread
From: Doug Evans @ 2016-11-10 17:53 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
On Thu, Nov 10, 2016 at 6:54 AM, Yao Qi <qiyaoltc@gmail.com> wrote:
> This patch removes the parameter valaddr of
> extension_language_ops::apply_val_pretty_printer and remove const from
> "struct value *val". valaddr can be got in each extension language's
> implementation of apply_val_pretty_printer.
>
> gdb:
>
> 2016-11-10 Yao Qi <yao.qi@linaro.org>
>
> * cp-valprint.c (cp_print_value): Remove local base_valaddr.
> * extension-priv.h (struct extension_language_ops)
> <apply_val_pretty_printer>: Remove the second parameter.
> Remove const from "struct value *". Callers updated.
> * extension.c (apply_ext_lang_val_pretty_printer): Update
> comments. Remove parameter valaddr. Remove const from
> "struct value *".
> * extension.h (apply_ext_lang_val_pretty_printer): Update
> declaration.
> * guile/guile-internal.h (gdbscm_apply_val_pretty_printer):
> Update declaration.
> * guile/scm-pretty-print.c (gdbscm_apply_val_pretty_printer):
> Remove parameter valaddr. Remove const from "struct value *".
> * python/py-prettyprint.c (gdbpy_apply_val_pretty_printer):
> Likewise.
> * python/python-internal.h (gdbpy_apply_val_pretty_printer):
> Update declaration.
LGTM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] Remove parameter valaddr from c print functions
2016-11-10 14:54 [PATCH 1/2] Remove parameter valaddr from c print functions Yao Qi
2016-11-10 14:54 ` [PATCH 2/2] Remove apply_val_pretty_printer parameter valaddr Yao Qi
@ 2016-11-10 17:54 ` Doug Evans
2016-11-11 8:41 ` Yao Qi
1 sibling, 1 reply; 5+ messages in thread
From: Doug Evans @ 2016-11-10 17:54 UTC (permalink / raw)
To: Yao Qi; +Cc: gdb-patches
On Thu, Nov 10, 2016 at 6:54 AM, Yao Qi <qiyaoltc@gmail.com> wrote:
> This patch removes parameter valaddr from some c print functions.
>
> Regression tested on x86_64-linux.
>
> gdb:
>
> 2016-11-10 Yao Qi <yao.qi@linaro.org>
>
> * c-lang.h (cp_print_value_fields): Update declaration.
> * cp-valprint.c (cp_print_value): Update declaration.
> (cp_print_value_fields): Remove parameter valaddr. Callers
> updated.
> (cp_print_value): Likewise.
LGTM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] Remove parameter valaddr from c print functions
2016-11-10 17:54 ` [PATCH 1/2] Remove parameter valaddr from c print functions Doug Evans
@ 2016-11-11 8:41 ` Yao Qi
0 siblings, 0 replies; 5+ messages in thread
From: Yao Qi @ 2016-11-11 8:41 UTC (permalink / raw)
To: Doug Evans; +Cc: gdb-patches
On Thu, Nov 10, 2016 at 5:53 PM, Doug Evans <dje@google.com> wrote:
> On Thu, Nov 10, 2016 at 6:54 AM, Yao Qi <qiyaoltc@gmail.com> wrote:
>> This patch removes parameter valaddr from some c print functions.
>>
>> Regression tested on x86_64-linux.
>>
>> gdb:
>>
>> 2016-11-10 Yao Qi <yao.qi@linaro.org>
>>
>> * c-lang.h (cp_print_value_fields): Update declaration.
>> * cp-valprint.c (cp_print_value): Update declaration.
>> (cp_print_value_fields): Remove parameter valaddr. Callers
>> updated.
>> (cp_print_value): Likewise.
>
> LGTM
Thanks for the review, patch is pushed in.
--
Yao (齐尧)
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-11-11 8:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-10 14:54 [PATCH 1/2] Remove parameter valaddr from c print functions Yao Qi
2016-11-10 14:54 ` [PATCH 2/2] Remove apply_val_pretty_printer parameter valaddr Yao Qi
2016-11-10 17:53 ` Doug Evans
2016-11-10 17:54 ` [PATCH 1/2] Remove parameter valaddr from c print functions Doug Evans
2016-11-11 8:41 ` Yao Qi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox