<bdo id='MpPFZ'></bdo><ul id='MpPFZ'></ul>
  • <legend id='MpPFZ'><style id='MpPFZ'><dir id='MpPFZ'><q id='MpPFZ'></q></dir></style></legend>
  • <small id='MpPFZ'></small><noframes id='MpPFZ'>

  • <i id='MpPFZ'><tr id='MpPFZ'><dt id='MpPFZ'><q id='MpPFZ'><span id='MpPFZ'><b id='MpPFZ'><form id='MpPFZ'><ins id='MpPFZ'></ins><ul id='MpPFZ'></ul><sub id='MpPFZ'></sub></form><legend id='MpPFZ'></legend><bdo id='MpPFZ'><pre id='MpPFZ'><center id='MpPFZ'></center></pre></bdo></b><th id='MpPFZ'></th></span></q></dt></tr></i><div id='MpPFZ'><tfoot id='MpPFZ'></tfoot><dl id='MpPFZ'><fieldset id='MpPFZ'></fieldset></dl></div>
      1. <tfoot id='MpPFZ'></tfoot>

        内存转储格式为 gdb 中的 xxd

        Memory dump formatted like xxd from gdb(内存转储格式为 gdb 中的 xxd)

          <tfoot id='BOKtE'></tfoot>

          1. <small id='BOKtE'></small><noframes id='BOKtE'>

            1. <legend id='BOKtE'><style id='BOKtE'><dir id='BOKtE'><q id='BOKtE'></q></dir></style></legend>
                <tbody id='BOKtE'></tbody>

                • <bdo id='BOKtE'></bdo><ul id='BOKtE'></ul>
                  <i id='BOKtE'><tr id='BOKtE'><dt id='BOKtE'><q id='BOKtE'><span id='BOKtE'><b id='BOKtE'><form id='BOKtE'><ins id='BOKtE'></ins><ul id='BOKtE'></ul><sub id='BOKtE'></sub></form><legend id='BOKtE'></legend><bdo id='BOKtE'><pre id='BOKtE'><center id='BOKtE'></center></pre></bdo></b><th id='BOKtE'></th></span></q></dt></tr></i><div id='BOKtE'><tfoot id='BOKtE'></tfoot><dl id='BOKtE'><fieldset id='BOKtE'></fieldset></dl></div>

                  本文介绍了内存转储格式为 gdb 中的 xxd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  I'm trying to inspect a buffer which contains a binary formatted message, but also contains string data. As an example, I'm using this C code:

                  int main (void) {
                      char buf[100] = "x01x02x03x04String DataxAAxBBxCC";
                  
                      return 0;
                  }
                  

                  I'd like to get a hex dump of what's in buf, of a format similar to xxd (I don't care if it's an exact match, what I'm really looking for is a hex dump side by side with printable chars).

                  Inside GDB I can use something like:

                  (gdb) x /100bx buf
                  0x7fffffffdf00: 0x01    0x02    0x03    0x04    0x53    0x74    0x72    0x69
                  0x7fffffffdf08: 0x6e    0x67    0x20    0x44    0x61    0x74    0x61    0xaa
                  0x7fffffffdf10: 0xbb    0xcc    0x00    0x00    0x00    0x00    0x00    0x00
                  0x7fffffffdf18: 0x00    0x00    0x00    0x00    0x00    0x00    0x00    0x00
                  0x7fffffffdf20: 0x00    0x00    0x00    0x00    0x00    0x00    0x00    0x00
                  0x7fffffffdf28: 0x00    0x00    0x00    0x00    0x00    0x00    0x00    0x00
                  0x7fffffffdf30: 0x00    0x00    0x00    0x00    0x00    0x00    0x00    0x00
                  0x7fffffffdf38: 0x00    0x00    0x00    0x00    0x00    0x00    0x00    0x00
                  0x7fffffffdf40: 0x00    0x00    0x00    0x00    0x00    0x00    0x00    0x00
                  0x7fffffffdf48: 0x00    0x00    0x00    0x00    0x00    0x00    0x00    0x00
                  0x7fffffffdf50: 0x00    0x00    0x00    0x00    0x00    0x00    0x00    0x00
                  0x7fffffffdf58: 0x00    0x00    0x00    0x00    0x00    0x00    0x00    0x00
                  

                  which is fine, but it's hard to pick out strings that way... or I can use

                  (gdb) x /100bs buf
                  0x7fffffffdf00:  "01020304String Data252273314"
                  0x7fffffffdf13:  ""
                  0x7fffffffdf14:  ""
                  0x7fffffffdf15:  ""
                  0x7fffffffdf16:  ""
                  0x7fffffffdf17:  ""
                  ...
                  

                  which makes it hard to read the binary part... the actual messages I'm dealing with have plenty of ascii nul's in them, too, so really it just looks like a mess.

                  The best I can come up with is to do this:

                  (gdb) dump binary memory dump.bin buf buf+100
                  

                  and then

                  $ xxd dump.bin
                  0000000: 0102 0304 5374 7269 6e67 2044 6174 61aa  ....String Data.
                  0000010: bbcc 0000 0000 0000 0000 0000 0000 0000  ................
                  0000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................
                  0000030: 0000 0000 0000 0000 0000 0000 0000 0000  ................
                  0000040: 0000 0000 0000 0000 0000 0000 0000 0000  ................
                  0000050: 0000 0000 0000 0000 0000 0000 0000 0000  ................
                  0000060: 0000 0000                                ....
                  

                  but that's a pain to do that every time. I figured somebody out there has wanted this before, so wondering if anybody has found a way to do it inside gdb. Plus you lose the addresses from the original memory this way.

                  I'm using GDB 7.4 with python support built in, so I'm open to the idea of using a pretty printer or similar, but I don't know how to set that up.

                  解决方案

                  (gdb) define xxd
                  >dump binary memory dump.bin $arg0 $arg0+$arg1
                  >shell xxd dump.bin
                  >end
                  (gdb) xxd &j 10 
                  0000000: 0000 0000 0000 0000 0000 0000 4d8c a7f7  ............M...
                  0000010: ff7f 0000 0000 0000 0000 0000 c8d7 ffff  ................
                  0000020: ff7f 0000 0000 0000
                  

                  Seems easy enough ;-)

                  You could likely write a Python script (modern GDB versions have embedded Python interpreter) to do the same, and get rid of the need to "shell out".

                  这篇关于内存转储格式为 gdb 中的 xxd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Initialize Multiple Numpy Arrays (Multiple Assignment) - Like MATLAB deal()(初始化多个 Numpy 数组(多重赋值) - 像 MATLAB deal())
                  How to extend Python class init(如何扩展 Python 类初始化)
                  What#39;s the difference between dict() and {}?(dict() 和 {} 有什么区别?)
                  What is a wrapper_descriptor, and why is Foo.__init__() one in this case?(什么是 wrapper_descriptor,为什么 Foo.__init__() 在这种情况下是其中之一?)
                  Initialize list with same bool value(使用相同的布尔值初始化列表)
                  setattr with kwargs, pythonic or not?(setattr 与 kwargs,pythonic 与否?)
                      <bdo id='8phBO'></bdo><ul id='8phBO'></ul>
                    • <legend id='8phBO'><style id='8phBO'><dir id='8phBO'><q id='8phBO'></q></dir></style></legend>

                        <i id='8phBO'><tr id='8phBO'><dt id='8phBO'><q id='8phBO'><span id='8phBO'><b id='8phBO'><form id='8phBO'><ins id='8phBO'></ins><ul id='8phBO'></ul><sub id='8phBO'></sub></form><legend id='8phBO'></legend><bdo id='8phBO'><pre id='8phBO'><center id='8phBO'></center></pre></bdo></b><th id='8phBO'></th></span></q></dt></tr></i><div id='8phBO'><tfoot id='8phBO'></tfoot><dl id='8phBO'><fieldset id='8phBO'></fieldset></dl></div>
                            <tbody id='8phBO'></tbody>
                          <tfoot id='8phBO'></tfoot>

                            <small id='8phBO'></small><noframes id='8phBO'>