public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM] archer-pmuldoon-python-value-infcall: Add rudimenary argument support to inferior function calls.
@ 2009-08-25 16:34 pmuldoon
0 siblings, 0 replies; only message in thread
From: pmuldoon @ 2009-08-25 16:34 UTC (permalink / raw)
To: archer-commits
The branch, archer-pmuldoon-python-value-infcall has been updated
via 8d4d7a536db2bbdaab0e99998a7b6a3ca7914044 (commit)
from e8ddfca4de24901381537079b6b696836d5e9727 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email.
- Log -----------------------------------------------------------------
commit 8d4d7a536db2bbdaab0e99998a7b6a3ca7914044
Author: Phil Muldoon <pmuldoon@redhat.com>
Date: Tue Aug 25 17:33:38 2009 +0100
Add rudimenary argument support to inferior function calls.
-----------------------------------------------------------------------
Summary of changes:
gdb/python/python-value.c | 33 +++++++++++++++++++++--------
gdb/testsuite/gdb.python/python-value.c | 8 ++++++-
gdb/testsuite/gdb.python/python-value.exp | 4 +++
3 files changed, 35 insertions(+), 10 deletions(-)
First 500 lines of diff:
diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c
index 4c9f8c7..f3220c8 100644
--- a/gdb/python/python-value.c
+++ b/gdb/python/python-value.c
@@ -347,22 +347,37 @@ valpy_setitem (PyObject *self, PyObject *key, PyObject *value)
return -1;
}
-/* Called by the Python interpreter to obtain string representation
- of the object. */
+/* Called by the Python interpreter to perform an inferior function
+ call on the value in question. */
static PyObject *
valpy_call (PyObject *self, PyObject *args, PyObject *keywords)
{
+ int args_count = 0;
struct value *res_val = NULL;
struct value *value = ((value_object *) self)->value;
- /* Phil: No programmed safety in this call, so call with care. */
- /* TODO: How are argument lists constructed in
- call_function_by_hand? */
- /* TODO: Symbol safety (actually a function?). Argument safety?
- Though GDB does not seem to check arguments passed to function
- pointers. Maybe it cannot. */
+ /* TODO: Better handling if there are no args.
+ Symbol checks, is this a function?
+ Argument safety.
+ Call safety.
+ Error handling.
+ */
+
+ args_count = PyTuple_Size (args);
+ {
+ struct value *vargs[args_count];
+ int i;
+ PyObject *item;
+
+ for (i=0; i<args_count; i++)
+ {
+ item = PyTuple_GetItem (args, i);
+ vargs[i] = convert_value_from_python (item);
+ }
+
+ res_val = call_function_by_hand (value, args_count, vargs);
+ }
- res_val = call_function_by_hand (value, 0, NULL);
return value_to_value_object (res_val);
}
diff --git a/gdb/testsuite/gdb.python/python-value.c b/gdb/testsuite/gdb.python/python-value.c
index e9ccb33..8350efb 100644
--- a/gdb/testsuite/gdb.python/python-value.c
+++ b/gdb/testsuite/gdb.python/python-value.c
@@ -55,6 +55,11 @@ void func3 ()
printf ("void function called\n");
}
+int func4 (int arg1, int arg2)
+{
+ return arg1 + arg2;
+}
+
int
main (int argc, char *argv[])
{
@@ -67,12 +72,13 @@ main (int argc, char *argv[])
int (*fp1) (int) = &func1;
int (*fp2) (void) = &func2;
void (*fp3) (void) = &func3;
-
+ int (*fp4) (int, int) = &func4;
s.a = 3;
s.b = 5;
u.a = 7;
(*fp1) (1);
(*fp2) ();
(*fp3) ();
+ (*fp4) (10,20);
return 0; /* break to inspect struct and union */
}
diff --git a/gdb/testsuite/gdb.python/python-value.exp b/gdb/testsuite/gdb.python/python-value.exp
index ff8f3fc..53c2121 100644
--- a/gdb/testsuite/gdb.python/python-value.exp
+++ b/gdb/testsuite/gdb.python/python-value.exp
@@ -228,6 +228,10 @@ proc test_inferior_function_call {} {
gdb_py_test_silent_cmd "python fp2 = gdb.history (0)" "get value from history" 1
gdb_test "python result2 = fp2()" ""
gdb_test "python print result2" "999"
+ gdb_test "p/x fp4" " = $hex.*"
+ gdb_py_test_silent_cmd "python fp4 = gdb.history (0)" "get value from history" 1
+ gdb_test "python result3 = fp4(10,20)" ""
+ gdb_test "python print result3" "30"
}
hooks/post-receive
--
Repository for Project Archer.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-08-25 16:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-25 16:34 [SCM] archer-pmuldoon-python-value-infcall: Add rudimenary argument support to inferior function calls pmuldoon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).