[v2] MI: Fix printing of frame architecture with Python frame filters enabled

Message ID 20180827205244.28098-1-jan.vrany@fit.cvut.cz
State New, archived
Headers

Commit Message

Jan Vrany Aug. 27, 2018, 8:52 p.m. UTC
  Commit 6d52907e226a (MI: Print frame architecture when printing frames
on an MI channel) added frame's architecture to MI frame output. However
the frame architecture was not correctly printed in the output of
"-stack-list-frames" with frame filters enabled (via "-enable-frame-filters").
This was because with frame filters enabled, the actual frame printing is
done in "py_print_frame" rather than "print_frame". This issue is now fixed.

gdb/Changelog:
2018-08-27  Jan Vrany  <jan.vrany@fit.cvut.cz>

	* python/py-framefilter.c (py_print_frame): Print frame architecture
	when printing on an MI output.

gdb/testsuite/Changelog:
2018-08-27  Jan Vrany  <jan.vrany@fit.cvut.cz>

	* gdb.python/py-framefilter-mi.exp: Update regexp to
	check for "arch" field in frame output.
---
 gdb/ChangeLog                                  | 5 +++++
 gdb/python/py-framefilter.c                    | 3 +++
 gdb/testsuite/ChangeLog                        | 5 +++++
 gdb/testsuite/gdb.python/py-framefilter-mi.exp | 8 +++++---
 4 files changed, 18 insertions(+), 3 deletions(-)
  

Comments

Simon Marchi Aug. 27, 2018, 9:15 p.m. UTC | #1
On 2018-08-27 16:52, Jan Vrany wrote:
> Commit 6d52907e226a (MI: Print frame architecture when printing frames
> on an MI channel) added frame's architecture to MI frame output. 
> However
> the frame architecture was not correctly printed in the output of
> "-stack-list-frames" with frame filters enabled (via 
> "-enable-frame-filters").
> This was because with frame filters enabled, the actual frame printing 
> is
> done in "py_print_frame" rather than "print_frame". This issue is now 
> fixed.
> 
> gdb/Changelog:
> 2018-08-27  Jan Vrany  <jan.vrany@fit.cvut.cz>
> 
> 	* python/py-framefilter.c (py_print_frame): Print frame architecture
> 	when printing on an MI output.
> 
> gdb/testsuite/Changelog:
> 2018-08-27  Jan Vrany  <jan.vrany@fit.cvut.cz>
> 
> 	* gdb.python/py-framefilter-mi.exp: Update regexp to
> 	check for "arch" field in frame output.

Ah, in my reply to v1 I really meant "you can push with that typo 
fixed", but forgot you don't have a sourceware account (yet!).  I would 
not have made you send a v2 just for that if I had remembered, I would 
have fixed it and pushed myself.  Anyway, I pushed it now, thanks!

Simon
  

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 99eb36a64d..b43cbcdde7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@ 
+2018-08-27  Jan Vrany  <jan.vrany@fit.cvut.cz>
+
+	* python/py-framefilter.c (py_print_frame): Print frame architecture
+	when printing on an MI output.
+
 2018-08-26  Simon Marchi  <simon.marchi@polymtl.ca>
 
 	* solist.h (struct solist, struct target_so_ops): Fix
diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c
index 4edefd48f9..fe17b70f53 100644
--- a/gdb/python/py-framefilter.c
+++ b/gdb/python/py-framefilter.c
@@ -958,6 +958,9 @@  py_print_frame (PyObject *filter, frame_filter_flags flags,
 	      out->field_int ("line", line);
 	    }
 	}
+      if (out->is_mi_like_p ())
+        out->field_string ("arch",
+                           (gdbarch_bfd_arch_info (gdbarch))->printable_name);
     }
 
   /* For MI we need to deal with the "children" list population of
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 6b5275a4cb..03b36afbe0 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@ 
+2018-08-27  Jan Vrany  <jan.vrany@fit.cvut.cz>
+
+	* gdb.python/py-framefilter-mi.exp: Update regexp to
+	check for "arch" field in frame output.
+
 2018-08-23  Kevin Buettner  <kevinb@redhat.com>
 
 	* gdb.dwarf2/dw2-ranges-func.c: New file.
diff --git a/gdb/testsuite/gdb.python/py-framefilter-mi.exp b/gdb/testsuite/gdb.python/py-framefilter-mi.exp
index 2ee8216bf0..6765f5c67d 100644
--- a/gdb/testsuite/gdb.python/py-framefilter-mi.exp
+++ b/gdb/testsuite/gdb.python/py-framefilter-mi.exp
@@ -64,14 +64,16 @@  mi_gdb_test "-stack-list-locals --all-values" \
 mi_continue_to_line [gdb_get_line_number {Backtrace end breakpoint} ${srcfile}] \
   "step to breakpoint"
 
+set any "\[^\"\]+"
+
 mi_gdb_test "-stack-list-frames" \
-    "\\^done,stack=\\\[frame={level=\"0\",addr=\"$hex\",func=\"cnuf_dne.*\".*},frame={level=\"1\",addr=\"$hex\",func=\"acnuf\".*},frame={level=\"2\",addr=\"$hex\",func=\"bcnuf\".*},frame={level=\"3\",addr=\"$hex\",func=\"acnuf\".*},frame={level=\"22\",addr=\"$hex\",func=\"1cnuf\".*,children=\\\[frame={level=\"23\",addr=\"$hex\",func=\"func2\".*}\\\]},frame={level=\"24\",addr=\"$hex\",func=\"3cnuf\".*},frame={level=\"27\",addr=\"$hex\",func=\"niam\".*}\\\].*" \
+    "\\^done,stack=\\\[frame={level=\"0\",addr=\"$hex\",func=\"cnuf_dne.*\".*,arch=\"$any\"},frame={level=\"1\",addr=\"$hex\",func=\"acnuf\".*,arch=\"$any\"},frame={level=\"2\",addr=\"$hex\",func=\"bcnuf\".*,arch=\"$any\"},frame={level=\"3\",addr=\"$hex\",func=\"acnuf\".*,arch=\"$any\"},frame={level=\"22\",addr=\"$hex\",func=\"1cnuf\".*,arch=\"$any\",children=\\\[frame={level=\"23\",addr=\"$hex\",func=\"func2\".*,arch=\"$any\"}\\\]},frame={level=\"24\",addr=\"$hex\",func=\"3cnuf\".*,arch=\"$any\"},frame={level=\"27\",addr=\"$hex\",func=\"niam\".*,arch=\"$any\"}\\\].*" \
     "filtered stack listing"
 mi_gdb_test "-stack-list-frames 0 3" \
-    "\\^done,stack=\\\[frame={level=\"0\",addr=\"$hex\",func=\"cnuf_dne.*\".*},frame={level=\"1\",addr=\"$hex\",func=\"acnuf\".*},frame={level=\"2\",addr=\"$hex\",func=\"bcnuf\".*},frame={level=\"3\",addr=\"$hex\",func=\"acnuf\".*}\\\]" \
+    "\\^done,stack=\\\[frame={level=\"0\",addr=\"$hex\",func=\"cnuf_dne.*\".*,arch=\"$any\"},frame={level=\"1\",addr=\"$hex\",func=\"acnuf\".*,arch=\"$any\"},frame={level=\"2\",addr=\"$hex\",func=\"bcnuf\".*,arch=\"$any\"},frame={level=\"3\",addr=\"$hex\",func=\"acnuf\".*,arch=\"$any\"}\\\]" \
     "filtered stack list 0 3"
 mi_gdb_test "-stack-list-frames 22 24" \
-    "\\^done,stack=\\\[frame={level=\"22\",addr=\"$hex\",func=\"1cnuf\".*,children=\\\[frame={level=\"23\",addr=\"$hex\",func=\"func2\".*}\\\]},frame={level=\"24\",addr=\"$hex\",func=\"3cnuf\".*}\\\]" \
+    "\\^done,stack=\\\[frame={level=\"22\",addr=\"$hex\",func=\"1cnuf\".*,arch=\"$any\",children=\\\[frame={level=\"23\",addr=\"$hex\",func=\"func2\".*,arch=\"$any\"}\\\]},frame={level=\"24\",addr=\"$hex\",func=\"3cnuf\".*,arch=\"$any\"}\\\]" \
     "filtered stack list 22 24"
 
 #stack list arguments