From: Phil Muldoon <pmuldoon@redhat.com>
To: jeffm@suse.com, gdb-patches@sourceware.org
Subject: Re: [PATCH 2/7] py-value: properly handle unsigned and pointer types
Date: Fri, 05 Feb 2016 12:12:00 -0000 [thread overview]
Message-ID: <56B491A7.1050905@redhat.com> (raw)
In-Reply-To: <1454606973-31017-3-git-send-email-jeffm@suse.com>
On 04/02/16 17:29, jeffm@suse.com wrote:
> From: Jeff Mahoney <jeffm@suse.com>
>
> GDB passes signed long values into python whether they're signed or
> not. This results in a situation where the caller needs to convert
> it back to an unsigned value, which requires knowledge of the underlying
> size of the value. The information to do that is available in the API,
> but it's unnecessary. We know it's an unsigned value so pass it as
> an unsigned value.
> ---
> gdb/python/py-value.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
> index 140aaf5..c557d95 100644
> --- a/gdb/python/py-value.c
> +++ b/gdb/python/py-value.c
> @@ -1475,6 +1475,7 @@ valpy_int (PyObject *self)
> {
> struct value *value = ((value_object *) self)->value;
> struct type *type = value_type (value);
> + int is_unsigned = 0;
> LONGEST l
>>
>> jeff
>>
> = 0;
>
> TRY
> @@ -1482,6 +1483,9 @@ valpy_int (PyObject *self)
> if (!is_integral_type (type))
> error (_("Cannot convert value to int."));
>
> + if (TYPE_CODE (type) == TYPE_CODE_PTR ||
> + TYPE_UNSIGNED(type))
Nit, space after the macro/function name and before (.
> + is_unsigned = 1;
> l = value_as_long (value);
> }
> CATCH (exc
>>
>> jeff
>>
> ept, RETURN_MASK_ALL)
> @@ -1490,6 +1494,8 @@ valpy_int (PyObject *self)
> }
> END_CATCH
>
> + if (is_unsigned)
> + return gdb_py_object_from_ulongest ((ULONGEST)l);
> return gdb_py_object_from_longest (l);
> }
> #endif
> @@ -1500,6 +1506,7 @@ valpy_long (PyObject *self)
> {
> struct value *value = ((value_object *) self)->value;
> struct type *type = value_type (value);
> + int is_unsigned = 0;
> LONGEST l = 0;
>
> TRY
> @@ -1510,6 +1517,9 @@ valpy_long (PyObject *self)
> && TYPE_CODE (type) != TYPE_CODE_PTR)
> error (_("Cannot convert value to long."));
>
> + if (TYPE_CODE (type) == TYPE_CODE_PTR ||
> + TYPE_UNSIGNED(type))
Nit, space after the macro/function name and before (.
> + is_unsigned = 1;
> l = value_as_long (value);
> }
> CATCH (except, RETURN_MASK_ALL)
> @@ -1518,6 +1528,8 @@ valpy_long (PyObject *self)
> }
> END_CATCH
>
> + if (is_unsigned)
> + return gdb_py_long_from_ulongest ((ULONGEST)l);
> return gdb_py_long_from_longest (l);
> }
>
Thanks. This needs tests and documentation changes for the changes in functionality.
Cheers
Phil
next prev parent reply other threads:[~2016-02-05 12:12 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-04 17:29 [PATCH 0/7] Python extension patchset jeffm
2016-02-04 17:29 ` [PATCH 1/7] check_types_equal: short circuit check if identical pointers are used jeffm
2016-02-04 17:29 ` [PATCH 4/7] py-symbol: Require a frame for lookup_symbol only when necessary jeffm
2016-02-05 12:17 ` Phil Muldoon
2016-02-05 16:08 ` Jeff Mahoney
2016-02-05 16:35 ` Phil Muldoon
2016-02-04 17:29 ` [PATCH 7/7] py-regcache: Add interface to regcache jeffm
2016-02-04 17:29 ` [PATCH 6/7] py-minsymbol: Add interface to access minimal_symbols jeffm
2016-02-05 12:25 ` Phil Muldoon
2016-02-05 16:43 ` Phil Muldoon
2016-02-08 15:51 ` Jeff Mahoney
2016-02-04 17:29 ` [PATCH 3/7] py-symbol: use Py_RETURN_NONE instead of open coding it jeffm
2016-02-04 17:43 ` [PATCH 5/7] py-symbol: export section name jeffm
2016-02-05 12:18 ` Phil Muldoon
2016-02-04 17:43 ` [PATCH 2/7] py-value: properly handle unsigned and pointer types jeffm
2016-02-05 12:12 ` Phil Muldoon [this message]
2016-02-05 12:29 ` Phil Muldoon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56B491A7.1050905@redhat.com \
--to=pmuldoon@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=jeffm@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox