This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Adding bit position to ptype


Hi, I am having trouble looking up field offsets when reading disassembled text.
So I add an extra field to ptype:
(gdb) ptype WebCore::FrameLoader
type = class WebCore::FrameLoader {
  private:
    WebCore::Frame *m_frame bitpos: 0;
    WebCore::FrameLoaderClient *m_client bitpos: 32;
    WebCore::PolicyChecker m_policyChecker bitpos: 64;
    WebCore::HistoryController m_history bitpos: 3264;
    WebCore::ResourceLoadNotifier m_notifer bitpos: 3552;
    WebCore::SubframeLoader m_subframeLoader bitpos: 3584;
    WebCore::FrameLoaderStateMachine m_stateMachine bitpos: 3680;
    WebCore::IconController m_icon bitpos: 3712;
...

That helps me a lot to understand what "ldr r0, [r4, #408]" means.
---
 gdb/c-typeprint.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 4edc9ec..9fbbc36 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -1110,6 +1110,12 @@ c_type_print_base (struct type *type, struct ui_file *stream,
 		    fprintf_filtered (stream, " : %d",
 				      TYPE_FIELD_BITSIZE (type, i));
 		  }
+		else if (!field_is_static (&TYPE_FIELD (type, i)))
+		  {
+		    /* print the bit pos.  */
+		    fprintf_filtered (stream, " bitpos: %d",
+		                      TYPE_FIELD_BITPOS (type, i));
+		  }
 		fprintf_filtered (stream, ";\n");
 	      }
 
-- 
1.9.1



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]