* [Bug python/13326] Need support for C++ method call for a gdb.Value object from within python
2011-10-20 5:14 [Bug python/13326] New: Need support for C++ method call for a gdb.Value object from within python lxmachine at gmail dot com
@ 2012-05-05 20:13 ` vmiklos at frugalware dot org
2013-02-25 17:42 ` tfogal at alumni dot unh.edu
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: vmiklos at frugalware dot org @ 2012-05-05 20:13 UTC (permalink / raw)
To: gdb-prs
http://sourceware.org/bugzilla/show_bug.cgi?id=13326
Miklos Vajna <vmiklos at frugalware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vmiklos at frugalware dot
| |org
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug python/13326] Need support for C++ method call for a gdb.Value object from within python
2011-10-20 5:14 [Bug python/13326] New: Need support for C++ method call for a gdb.Value object from within python lxmachine at gmail dot com
2012-05-05 20:13 ` [Bug python/13326] " vmiklos at frugalware dot org
@ 2013-02-25 17:42 ` tfogal at alumni dot unh.edu
2021-01-21 19:27 ` malcolm.parsons at gmail dot com
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: tfogal at alumni dot unh.edu @ 2013-02-25 17:42 UTC (permalink / raw)
To: gdb-prs
http://sourceware.org/bugzilla/show_bug.cgi?id=13326
tom fogal <tfogal at alumni dot unh.edu> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tfogal at alumni dot
| |unh.edu
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug python/13326] Need support for C++ method call for a gdb.Value object from within python
2011-10-20 5:14 [Bug python/13326] New: Need support for C++ method call for a gdb.Value object from within python lxmachine at gmail dot com
2012-05-05 20:13 ` [Bug python/13326] " vmiklos at frugalware dot org
2013-02-25 17:42 ` tfogal at alumni dot unh.edu
@ 2021-01-21 19:27 ` malcolm.parsons at gmail dot com
2021-08-12 19:24 ` jwakely.gcc at gmail dot com
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: malcolm.parsons at gmail dot com @ 2021-01-21 19:27 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=13326
Malcolm Parsons <malcolm.parsons at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |malcolm.parsons at gmail dot com
--- Comment #3 from Malcolm Parsons <malcolm.parsons at gmail dot com> ---
Use from a python pretty-printer is a bit convoluted, but it works:
def to_string(self):
gdb.set_convenience_variable('_tmp', self.val.reference_value())
return gdb.parse_and_eval('$_tmp.str()')
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug python/13326] Need support for C++ method call for a gdb.Value object from within python
2011-10-20 5:14 [Bug python/13326] New: Need support for C++ method call for a gdb.Value object from within python lxmachine at gmail dot com
` (2 preceding siblings ...)
2021-01-21 19:27 ` malcolm.parsons at gmail dot com
@ 2021-08-12 19:24 ` jwakely.gcc at gmail dot com
2023-07-24 16:30 ` joelhock at gmail dot com
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jwakely.gcc at gmail dot com @ 2021-08-12 19:24 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=13326
Jonathan Wakely <jwakely.gcc at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jwakely.gcc at gmail dot com
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug python/13326] Need support for C++ method call for a gdb.Value object from within python
2011-10-20 5:14 [Bug python/13326] New: Need support for C++ method call for a gdb.Value object from within python lxmachine at gmail dot com
` (3 preceding siblings ...)
2021-08-12 19:24 ` jwakely.gcc at gmail dot com
@ 2023-07-24 16:30 ` joelhock at gmail dot com
2023-12-15 16:11 ` ssbssa at sourceware dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: joelhock at gmail dot com @ 2023-07-24 16:30 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=13326
Joel Hock <joelhock at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |joelhock at gmail dot com
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug python/13326] Need support for C++ method call for a gdb.Value object from within python
2011-10-20 5:14 [Bug python/13326] New: Need support for C++ method call for a gdb.Value object from within python lxmachine at gmail dot com
` (4 preceding siblings ...)
2023-07-24 16:30 ` joelhock at gmail dot com
@ 2023-12-15 16:11 ` ssbssa at sourceware dot org
2024-02-08 19:10 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: ssbssa at sourceware dot org @ 2023-12-15 16:11 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=13326
Hannes Domani <ssbssa at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ssbssa at sourceware dot org
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug python/13326] Need support for C++ method call for a gdb.Value object from within python
2011-10-20 5:14 [Bug python/13326] New: Need support for C++ method call for a gdb.Value object from within python lxmachine at gmail dot com
` (5 preceding siblings ...)
2023-12-15 16:11 ` ssbssa at sourceware dot org
@ 2024-02-08 19:10 ` cvs-commit at gcc dot gnu.org
2024-02-08 19:13 ` ssbssa at sourceware dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-08 19:10 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=13326
--- Comment #4 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Hannes Domani <ssbssa@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=2e08907d0672711617f71ef4604df190106b992e
commit 2e08907d0672711617f71ef4604df190106b992e
Author: Hannes Domani <ssbssa@yahoo.de>
Date: Thu Feb 8 20:09:25 2024 +0100
Allow calling of C++ methods from python
Currently it's not possible to call C++ methods from python.
Using this example:
```
class B
{
static int static_func ();
int arg0_func ();
int arg1_func (int arg1);
int arg2_func (int arg1, int arg2);
};
B *b_obj = new B;
```
Trying to call B::static_func gives this error:
```
(gdb) py b_obj = gdb.parse_and_eval('b_obj')
(gdb) py print(b_obj['static_func']())
Traceback (most recent call last):
File "<string>", line 1, in <module>
RuntimeError: Value is not callable (not TYPE_CODE_FUNC).
Error while executing Python code.
```
TYPE_CODE_METHOD was simply missing as a possible type in
valpy_call, now the same is possible:
```
(gdb) py b_obj = gdb.parse_and_eval('b_obj')
(gdb) py print(b_obj['static_func']())
1111
```
Note that it's necessary to explicitely add the this pointer
as the first argument in a call of non-static methods:
```
(gdb) py print(b_obj['arg0_func']())
Traceback (most recent call last):
File "<string>", line 1, in <module>
gdb.error: Too few arguments in function call.
Error while executing Python code.
(gdb) py print(b_obj['arg0_func'](b_obj))
198
```
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=13326
Approved-By: Tom Tromey <tom@tromey.com>
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug python/13326] Need support for C++ method call for a gdb.Value object from within python
2011-10-20 5:14 [Bug python/13326] New: Need support for C++ method call for a gdb.Value object from within python lxmachine at gmail dot com
` (6 preceding siblings ...)
2024-02-08 19:10 ` cvs-commit at gcc dot gnu.org
@ 2024-02-08 19:13 ` ssbssa at sourceware dot org
2024-06-03 15:19 ` cvs-commit at gcc dot gnu.org
2024-06-03 15:26 ` ssbssa at sourceware dot org
9 siblings, 0 replies; 11+ messages in thread
From: ssbssa at sourceware dot org @ 2024-02-08 19:13 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=13326
Hannes Domani <ssbssa at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |15.1
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #5 from Hannes Domani <ssbssa at sourceware dot org> ---
Fixed.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug python/13326] Need support for C++ method call for a gdb.Value object from within python
2011-10-20 5:14 [Bug python/13326] New: Need support for C++ method call for a gdb.Value object from within python lxmachine at gmail dot com
` (7 preceding siblings ...)
2024-02-08 19:13 ` ssbssa at sourceware dot org
@ 2024-06-03 15:19 ` cvs-commit at gcc dot gnu.org
2024-06-03 15:26 ` ssbssa at sourceware dot org
9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-06-03 15:19 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=13326
--- Comment #6 from Sourceware Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Hannes Domani <ssbssa@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f74da7b8b3d6f14ba9ad21b380f743e4bdc4e952
commit f74da7b8b3d6f14ba9ad21b380f743e4bdc4e952
Author: Hannes Domani <ssbssa@yahoo.de>
Date: Mon Jun 3 17:18:30 2024 +0200
Allow calling of convenience functions with python
As mentioned in PR13326, currently when you try to call a
convenience function with python, you get this error:
(gdb) py print(gdb.convenience_variable("_isvoid")(3))
Traceback (most recent call last):
File "<string>", line 1, in <module>
RuntimeError: Value is not callable (not TYPE_CODE_FUNC or
TYPE_CODE_METHOD).
Error while executing Python code.
So this extends valpy_call to handle TYPE_CODE_INTERNAL_FUNCTION as
well, making this possible:
(gdb) py print(gdb.convenience_variable("_isvoid")(3))
0
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=13326
Approved-By: Tom Tromey <tom@tromey.com>
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug python/13326] Need support for C++ method call for a gdb.Value object from within python
2011-10-20 5:14 [Bug python/13326] New: Need support for C++ method call for a gdb.Value object from within python lxmachine at gmail dot com
` (8 preceding siblings ...)
2024-06-03 15:19 ` cvs-commit at gcc dot gnu.org
@ 2024-06-03 15:26 ` ssbssa at sourceware dot org
9 siblings, 0 replies; 11+ messages in thread
From: ssbssa at sourceware dot org @ 2024-06-03 15:26 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=13326
--- Comment #7 from Hannes Domani <ssbssa at sourceware dot org> ---
(In reply to vuvova from comment #1)
> Same for TYPE_CODE_INTERNAL_FUNCTION:
>
> (gdb) pi a=gdb.parse_and_eval('$_streq')
> (gdb) pi print a.type.code == gdb.TYPE_CODE_INTERNAL_FUNCTION
> True
> (gdb) pi a("1","2")
> Python Exception <type 'exceptions.RuntimeError'> Value is not callable (not
> TYPE_CODE_FUNC).:
Now this is fixed as well.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 11+ messages in thread