* [RFC] New method gdb.Frame.arch_name which return's the name of frame's architecture
@ 2013-01-11 14:56 Siva Chandra
2013-01-11 15:43 ` Eli Zaretskii
2013-01-14 21:44 ` Tom Tromey
0 siblings, 2 replies; 3+ messages in thread
From: Siva Chandra @ 2013-01-11 14:56 UTC (permalink / raw)
To: gdb-patches; +Cc: Phil Muldoon
[-- Attachment #1: Type: text/plain, Size: 933 bytes --]
Hello,
Attached is a patch which adds a new method 'arch_name' to the class
gdb.Frame. This new method returns the name of the frame's
architecture as a string value.
Phil Muldoon (copied in this mail) asked sometime back whether I
intend to expose frame's architecture as an object by itself. All I
want for now is a way to get the name of the frame's architecture.
Changelog:
2013-01-11 Siva Chandra Reddy <sivachandra@google.com>
New method gdb.Frame.arch_name() which returns the name of
frame's architecture.
* NEWS: Add entry about the new method.
* python/py-frame.c (frapy_arch_name): Implementation of
gdb.Frame.arch_name.
(frame_object_methods): Add method table entry for the new
method.
doc/
* gdb.texinfo: Add description of the new method.
testsuite/
* gdb.python/py-frame.exp: Add a test to test the new method.
Thanks,
Siva Chandra
[-- Attachment #2: frame_arch_name_patch.txt --]
[-- Type: text/plain, Size: 3284 bytes --]
diff --git a/gdb/NEWS b/gdb/NEWS
index 36bbd12..ffe56f1 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -39,6 +39,9 @@ Lynx 178 PowerPC powerpc-*-lynx*178
** Python 3 is now supported (in addition to Python 2.4 or later)
+ ** New method 'arch_name' added to gdb.Frame class which returns
+ the name of the frame's architecture.
+
* New Python-based convenience functions:
** $_memeq(buf1, buf2, length)
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index f973263..9d66588 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -25111,6 +25111,10 @@ newest frame.
@end table
@end defun
+@defun Frame.arch_name ()
+Returns the name (string value) of the frame's architecture.
+@end defun
+
@defun Frame.unwind_stop_reason ()
Return an integer representing the reason why it's not possible to find
more frames toward the outermost frame. Use
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index 4b025db..f1bade0 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -167,6 +167,30 @@ frapy_type (PyObject *self, PyObject *args)
return PyInt_FromLong (type);
}
+/* Implementation of gdb.Frame.arch_name (self) -> String.
+ Returns the name of frame's architecture. */
+
+static PyObject *
+frapy_arch_name (PyObject *self, PyObject *args)
+{
+ struct frame_info *frame;
+ frame_object *obj = (frame_object *) self;
+ PyObject *py_str = NULL;
+ const char *arch_name;
+ volatile struct gdb_exception except;
+
+ TRY_CATCH (except, RETURN_MASK_ALL)
+ {
+ FRAPY_REQUIRE_VALID (self, frame);
+
+ arch_name = gdbarch_bfd_arch_info (obj->gdbarch)->printable_name;
+ py_str = PyString_FromString (arch_name);
+ }
+ GDB_PY_HANDLE_EXCEPTION (except);
+
+ return py_str;
+}
+
/* Implementation of gdb.Frame.unwind_stop_reason (self) -> Integer.
Returns one of the gdb.FRAME_UNWIND_* constants. */
@@ -632,6 +656,9 @@ Return the function name of the frame, or None if it can't be determined." },
{ "type", frapy_type, METH_NOARGS,
"type () -> Integer.\n\
Return the type of the frame." },
+ { "arch_name", frapy_arch_name, METH_NOARGS,
+ "arch_name () - > String.\n\
+Return the name of the frame's architecture." },
{ "unwind_stop_reason", frapy_unwind_stop_reason, METH_NOARGS,
"unwind_stop_reason () -> Integer.\n\
Return the reason why it's not possible to find frames older than this." },
diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp
index aa4d937..fcad68d 100644
--- a/gdb/testsuite/gdb.python/py-frame.exp
+++ b/gdb/testsuite/gdb.python/py-frame.exp
@@ -43,6 +43,10 @@ gdb_test "python print (bf1.read_var(\"i\"))" "\"stuff\"" "test i"
gdb_test "python print (bf1.read_var(\"f\"))" "\"foo\"" "test f"
gdb_test "python print (bf1.read_var(\"b\"))" "\"bar\"" "test b"
+# Test Frame.arch_name()
+gdb_py_test_silent_cmd "python show_arch = (gdb.execute(\"show architecture\", to_string=True))" "get arch name" 0
+gdb_test "python print bf1.arch_name() in show_arch" "True" "test Frame.arch_name()"
+
# Test the read_var function in another block other than the current
# block (in this case, the super block). Test thar read_var is reading
# the correct variables of i and f but they are the correct value and type.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [RFC] New method gdb.Frame.arch_name which return's the name of frame's architecture
2013-01-11 14:56 [RFC] New method gdb.Frame.arch_name which return's the name of frame's architecture Siva Chandra
@ 2013-01-11 15:43 ` Eli Zaretskii
2013-01-14 21:44 ` Tom Tromey
1 sibling, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2013-01-11 15:43 UTC (permalink / raw)
To: Siva Chandra; +Cc: gdb-patches, pmuldoon
> Date: Fri, 11 Jan 2013 06:56:22 -0800
> From: Siva Chandra <sivachandra@google.com>
> Cc: Phil Muldoon <pmuldoon@redhat.com>
>
> Attached is a patch which adds a new method 'arch_name' to the class
> gdb.Frame. This new method returns the name of the frame's
> architecture as a string value.
Thanks.
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -39,6 +39,9 @@ Lynx 178 PowerPC powerpc-*-lynx*178
>
> ** Python 3 is now supported (in addition to Python 2.4 or later)
>
> + ** New method 'arch_name' added to gdb.Frame class which returns
> + the name of the frame's architecture.
We describe the _state_ of GDB, not the actions which led to that
state. So it would be better to reword like this:
A new method 'arch_name' of the gdb.Frame class returns the name of
the frame's architecture.
> +@defun Frame.arch_name ()
> +Returns the name (string value) of the frame's architecture.
"Return", not "Returns", for consistency with other method
descriptions.
The documentation parts are OK with these changes.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] New method gdb.Frame.arch_name which return's the name of frame's architecture
2013-01-11 14:56 [RFC] New method gdb.Frame.arch_name which return's the name of frame's architecture Siva Chandra
2013-01-11 15:43 ` Eli Zaretskii
@ 2013-01-14 21:44 ` Tom Tromey
1 sibling, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2013-01-14 21:44 UTC (permalink / raw)
To: Siva Chandra; +Cc: gdb-patches, Phil Muldoon
>>>>> "Siva" == Siva Chandra <sivachandra@google.com> writes:
Siva> Attached is a patch which adds a new method 'arch_name' to the class
Siva> gdb.Frame. This new method returns the name of the frame's
Siva> architecture as a string value.
Siva> Phil Muldoon (copied in this mail) asked sometime back whether I
Siva> intend to expose frame's architecture as an object by itself. All I
Siva> want for now is a way to get the name of the frame's architecture.
If we think we'll want to expose the architecture in the long term --
and I think we probably do -- then it seems cleaner to me to introduce
the class now and just give it a single method.
Tom
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-01-14 21:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-11 14:56 [RFC] New method gdb.Frame.arch_name which return's the name of frame's architecture Siva Chandra
2013-01-11 15:43 ` Eli Zaretskii
2013-01-14 21:44 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox