* How to write native (i.e. C/C++) plugin for gdb? @ 2013-12-24 12:31 Dmitry Samersoff 2013-12-24 13:16 ` Hui Zhu 0 siblings, 1 reply; 8+ messages in thread From: Dmitry Samersoff @ 2013-12-24 12:31 UTC (permalink / raw) To: gdb -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Everybody, I'm about to write a plugin to deal with complicated data (Java VM coredump). Unfortunately, python is not an option, as I plan to re-use already existing C++ code of JVM to access internal structures. Is there API, documentation, examples of such plugin? Any advice is much appreciated. - -Dmitry - -- Dmitry Samersoff Saint Petersburg, Russia, http://devnull.samersoff.net * There will come soft rains ... -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSuX60AAoJEHEy08c4gIABbxkH/iTOVBz38dePkJYC8l1TJG0T lWdhwnre1BbgAK6QqNXhaTj+uTr3an16qZnVFTJ42wTu2juPLc3bOx0kWl23tDWY OSw28EL8jLvgdE828cGL3tNz+8/xdag7ylhzqVv5fRsLoRBMcn3EslGMRmj/AJLb QnRPUJjzvh1PdCMTVekz8JNIacriVpX5cAPp7SBb98it6hBbswwUw0syMiiuzlbl mIb4wvPnPjM75rMFSEuZb07m15AT3qA/qAiPbwZXWU6K23lwZCUo6Glli0MYNW+x ZK7hDNPN56hlGhX9uuVUVD3q3PEcr8buQsOwIjEDE85lOjDPXQGdOIx5nC6qKq0= =YyOr -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to write native (i.e. C/C++) plugin for gdb? 2013-12-24 12:31 How to write native (i.e. C/C++) plugin for gdb? Dmitry Samersoff @ 2013-12-24 13:16 ` Hui Zhu 2013-12-24 14:13 ` Dmitry Samersoff 0 siblings, 1 reply; 8+ messages in thread From: Hui Zhu @ 2013-12-24 13:16 UTC (permalink / raw) To: Dmitry Samersoff; +Cc: gdb https://sourceware.org/gdb/current/onlinedocs/gdb/JIT-Interface.html Maybe this is helpful. On Tue, Dec 24, 2013 at 8:31 PM, Dmitry Samersoff <dms@samersoff.net> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi Everybody, > > I'm about to write a plugin to deal with complicated data (Java VM > coredump). > > Unfortunately, python is not an option, as I plan to re-use already > existing C++ code of JVM to access internal structures. > > Is there API, documentation, examples of such plugin? > > Any advice is much appreciated. > > - -Dmitry > > - -- > Dmitry Samersoff > Saint Petersburg, Russia, http://devnull.samersoff.net > * There will come soft rains ... > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v2.0.20 (GNU/Linux) > Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ > > iQEcBAEBAgAGBQJSuX60AAoJEHEy08c4gIABbxkH/iTOVBz38dePkJYC8l1TJG0T > lWdhwnre1BbgAK6QqNXhaTj+uTr3an16qZnVFTJ42wTu2juPLc3bOx0kWl23tDWY > OSw28EL8jLvgdE828cGL3tNz+8/xdag7ylhzqVv5fRsLoRBMcn3EslGMRmj/AJLb > QnRPUJjzvh1PdCMTVekz8JNIacriVpX5cAPp7SBb98it6hBbswwUw0syMiiuzlbl > mIb4wvPnPjM75rMFSEuZb07m15AT3qA/qAiPbwZXWU6K23lwZCUo6Glli0MYNW+x > ZK7hDNPN56hlGhX9uuVUVD3q3PEcr8buQsOwIjEDE85lOjDPXQGdOIx5nC6qKq0= > =YyOr > -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to write native (i.e. C/C++) plugin for gdb? 2013-12-24 13:16 ` Hui Zhu @ 2013-12-24 14:13 ` Dmitry Samersoff 2013-12-24 14:47 ` Joel Brobecker 0 siblings, 1 reply; 8+ messages in thread From: Dmitry Samersoff @ 2013-12-24 14:13 UTC (permalink / raw) To: Hui Zhu; +Cc: gdb -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hui, Thank you for the pointer. It useful information but not exactly what I need. I need to implement scenario like one below: (gdb) load-plugin libgdbjvm.so (gdb) attach PID (gdb) jvm show loaded-classes (gdb) jvm show java-threads (gdb) jvm show code-cache etc. - -Dmitry On 2013-12-24 17:15, Hui Zhu wrote: > https://sourceware.org/gdb/current/onlinedocs/gdb/JIT-Interface.html > > Maybe this is helpful. > > On Tue, Dec 24, 2013 at 8:31 PM, Dmitry Samersoff > <dms@samersoff.net> wrote: Hi Everybody, > > I'm about to write a plugin to deal with complicated data (Java VM > coredump). > > Unfortunately, python is not an option, as I plan to re-use > already existing C++ code of JVM to access internal structures. > > Is there API, documentation, examples of such plugin? > > Any advice is much appreciated. > > -Dmitry > - -- Dmitry Samersoff Saint Petersburg, Russia, http://devnull.samersoff.net * There will come soft rains ... -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSuZZrAAoJEHEy08c4gIABfj0H/0biEiP4M41rS2NgiSaVmS6k ttJFi8y3Sb3llU9m/p16CmbK+CRw9bNmLFy1BXETjL+2F2JHTnrn/CDh8Ffotpi6 ZBDDhlPsVQ2Cr+cpk8PKd4omAwj2S+2DYSl4CG9mvnxNqKG4MNVpPRSFnAUlx4WZ rBFODdj1miLUon4X8fbip9wcfpHGP4m8E0DE0uVFWjKTnYCvhBJkSjLTQOvnZOaN nA66YjPR72LvQFFHbH4Ry07Vhh6Lx7uUCQ0nV9ZFUSoHOq1IhgA5I04Z0BzUpJpD dZ3FtKy2xUz3WT+dG3c/HLS1IDJiwksrS1gQ1pUuFYlGzzO5Zru27ehcuRenzg0= =96XW -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to write native (i.e. C/C++) plugin for gdb? 2013-12-24 14:13 ` Dmitry Samersoff @ 2013-12-24 14:47 ` Joel Brobecker 2013-12-25 15:32 ` Dmitry Samersoff 0 siblings, 1 reply; 8+ messages in thread From: Joel Brobecker @ 2013-12-24 14:47 UTC (permalink / raw) To: Dmitry Samersoff; +Cc: Hui Zhu, gdb > I need to implement scenario like one below: > > (gdb) load-plugin libgdbjvm.so > (gdb) attach PID > (gdb) jvm show loaded-classes > (gdb) jvm show java-threads > (gdb) jvm show code-cache Maybe you could add some routines in your program that are solely intended for debugging purposes, and then define commands that call those routines. Off hand, that's the only way I can think of. Otherwise, interface the C++ stuff you need from Python - if necessary, export some stuff to C? -- Joel ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to write native (i.e. C/C++) plugin for gdb? 2013-12-24 14:47 ` Joel Brobecker @ 2013-12-25 15:32 ` Dmitry Samersoff 2013-12-25 16:51 ` Dmitry Samersoff 0 siblings, 1 reply; 8+ messages in thread From: Dmitry Samersoff @ 2013-12-25 15:32 UTC (permalink / raw) To: Joel Brobecker; +Cc: Hui Zhu, gdb, abhijit.k.halder -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Joel, Thank you for the response. I found this patch https://sourceware.org/ml/gdb-patches/2012-05/msg00500.html - many thanks to Abhijit. 1. What is the reason to keep it off main trunk? Is there a chance to have it changed? 2. What API is available from within a plugin? i.e. how I can access coredump memory? - -Dmitry On 2013-12-24 18:47, Joel Brobecker wrote: >> I need to implement scenario like one below: >> >> (gdb) load-plugin libgdbjvm.so (gdb) attach PID (gdb) jvm show >> loaded-classes (gdb) jvm show java-threads (gdb) jvm show >> code-cache > > Maybe you could add some routines in your program that are solely > intended for debugging purposes, and then define commands that call > those routines. Off hand, that's the only way I can think of. > Otherwise, interface the C++ stuff you need from Python - if > necessary, export some stuff to C? > - -- Dmitry Samersoff Saint Petersburg, Russia, http://devnull.samersoff.net * There will come soft rains ... -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSuvqWAAoJEHEy08c4gIABMUQH/AiXTuX8BWuzG+Vm19EOSHlb 2EuBEpo633nBTgUlKIj99ePfuh5jRwZ5R0/pBmM/Ue4ytCJWTu0iQl5OU3RQ81BT U9lFccSUW9oBnrfCqAZWQLss2sX1eL+9JjCduu47rKa4mLMaiJ0kxRml7IAT42Lo h9j2QZSBcmEd5nA0VITU1meeIoU+KPhVe/UpNu1e3g/0EBgTnZbZ6iBbzqh+QhiY lzR4g3KtNpI7mz4DvJ8O7+xNbSeh5sU2zWWG/EbETQHkp/Xt/AbChnSY5udFe1oS lT87bTgh3cqWnTJVWa6UMI98K+RwIFVvxNQ3pIkuFFUh7HwEo+ubJL5xQT0Pn8Y= =Ql5e -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to write native (i.e. C/C++) plugin for gdb? 2013-12-25 15:32 ` Dmitry Samersoff @ 2013-12-25 16:51 ` Dmitry Samersoff 2013-12-26 22:55 ` Doug Evans 0 siblings, 1 reply; 8+ messages in thread From: Dmitry Samersoff @ 2013-12-25 16:51 UTC (permalink / raw) To: Joel Brobecker; +Cc: Hui Zhu, gdb, abhijit.k.halder -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Everyone, Just found a year old discussion about Abhijit proposal. So answering to upcoming question - why not a Python. Python is very good staff if your speak about source level debugging. If you have to debug optimized binary python doesn't help match for two reason - 1) you have to port all native data structure you plan to work with to python. 2) python performance is not always acceptable and you not always ever able to run a python. To get a better picture of native plugins in action, please, take a look at solaris mdb. - -Dmitry On 2013-12-25 19:32, Dmitry Samersoff wrote: > Joel, > > Thank you for the response. > > I found this patch > https://sourceware.org/ml/gdb-patches/2012-05/msg00500.html - many > thanks to Abhijit. > > 1. What is the reason to keep it off main trunk? Is there a chance > to have it changed? > > 2. What API is available from within a plugin? i.e. how I can > access coredump memory? > > -Dmitry > > On 2013-12-24 18:47, Joel Brobecker wrote: >>> I need to implement scenario like one below: >>> >>> (gdb) load-plugin libgdbjvm.so (gdb) attach PID (gdb) jvm >>> show loaded-classes (gdb) jvm show java-threads (gdb) jvm show >>> code-cache > >> Maybe you could add some routines in your program that are solely >> intended for debugging purposes, and then define commands that >> call those routines. Off hand, that's the only way I can think >> of. Otherwise, interface the C++ stuff you need from Python - if >> necessary, export some stuff to C? > > > > - -- Dmitry Samersoff Saint Petersburg, Russia, http://devnull.samersoff.net * There will come soft rains ... -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSuw0GAAoJEHEy08c4gIABbiwIAJJlEmMZ16o3JJibuY7X5sLL VOVxfJfMox78zaGERdrS/lQqFege+JN1qBcaVjg4HGbSl71aA0t11JR6W+Vv06UZ JK82axJqDkR2hOjz8oy9LeZNGOgLeE1zcjCwYVbyuj7hhENaDBZTadq94pc5dOsi aBAVqPrDe9ufgBeriHD5uym1lwYEk4EOW8jBEU4ToO5PUUtVTIG6i4WeXjwMBAxh z1ZCRR46WRXKpL1LQw6X6jOWpXL/6nnoS3A9j4zKGXG8xHiM8K8zyrZPBRsB26A8 t+FLEPeFg7pAuARnlDNLaEHX4lEjifqoGafyw7L+KbVPdC1INYQ+Ld8Q+yg/jMg= =baN/ -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to write native (i.e. C/C++) plugin for gdb? 2013-12-25 16:51 ` Dmitry Samersoff @ 2013-12-26 22:55 ` Doug Evans 2013-12-27 14:15 ` Dmitry Samersoff 0 siblings, 1 reply; 8+ messages in thread From: Doug Evans @ 2013-12-26 22:55 UTC (permalink / raw) To: Dmitry Samersoff; +Cc: Joel Brobecker, Hui Zhu, gdb, Abhijith Halder On Wed, Dec 25, 2013 at 8:51 AM, Dmitry Samersoff <dms@samersoff.net> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Everyone, > > Just found a year old discussion about Abhijit proposal. > > So answering to upcoming question - why not a Python. > > Python is very good staff if your speak about source level debugging. > If you have to debug optimized binary python doesn't help match for > two reason - > > 1) you have to port all native data structure you plan to work with > to python. Hi. This typically isn't that hard an exercise, have you looked into it? > 2) python performance is not always acceptable and you not always > ever able to run a python. I'd like to see the data that shows the performance isn't acceptable. This could just be mistaken impressions. > To get a better picture of native plugins in action, please, take a > look at solaris mdb. > > - -Dmitry > > On 2013-12-25 19:32, Dmitry Samersoff wrote: >> Joel, >> >> Thank you for the response. >> >> I found this patch >> https://sourceware.org/ml/gdb-patches/2012-05/msg00500.html - many >> thanks to Abhijit. >> >> 1. What is the reason to keep it off main trunk? Is there a chance >> to have it changed? >> >> 2. What API is available from within a plugin? i.e. how I can >> access coredump memory? >> >> -Dmitry >> >> On 2013-12-24 18:47, Joel Brobecker wrote: >>>> I need to implement scenario like one below: >>>> >>>> (gdb) load-plugin libgdbjvm.so (gdb) attach PID (gdb) jvm >>>> show loaded-classes (gdb) jvm show java-threads (gdb) jvm show >>>> code-cache >> >>> Maybe you could add some routines in your program that are solely >>> intended for debugging purposes, and then define commands that >>> call those routines. Off hand, that's the only way I can think >>> of. Otherwise, interface the C++ stuff you need from Python - if >>> necessary, export some stuff to C? >> >> >> >> > > - -- > Dmitry Samersoff > Saint Petersburg, Russia, http://devnull.samersoff.net > * There will come soft rains ... > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v2.0.20 (GNU/Linux) > Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ > > iQEcBAEBAgAGBQJSuw0GAAoJEHEy08c4gIABbiwIAJJlEmMZ16o3JJibuY7X5sLL > VOVxfJfMox78zaGERdrS/lQqFege+JN1qBcaVjg4HGbSl71aA0t11JR6W+Vv06UZ > JK82axJqDkR2hOjz8oy9LeZNGOgLeE1zcjCwYVbyuj7hhENaDBZTadq94pc5dOsi > aBAVqPrDe9ufgBeriHD5uym1lwYEk4EOW8jBEU4ToO5PUUtVTIG6i4WeXjwMBAxh > z1ZCRR46WRXKpL1LQw6X6jOWpXL/6nnoS3A9j4zKGXG8xHiM8K8zyrZPBRsB26A8 > t+FLEPeFg7pAuARnlDNLaEHX4lEjifqoGafyw7L+KbVPdC1INYQ+Ld8Q+yg/jMg= > =baN/ > -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: How to write native (i.e. C/C++) plugin for gdb? 2013-12-26 22:55 ` Doug Evans @ 2013-12-27 14:15 ` Dmitry Samersoff 0 siblings, 0 replies; 8+ messages in thread From: Dmitry Samersoff @ 2013-12-27 14:15 UTC (permalink / raw) To: Doug Evans; +Cc: Joel Brobecker, Hui Zhu, gdb, Abhijith Halder -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Doug, Unfortunately, sustaining - i.e. fixing customer side issues, - has different requirements comparing to development - you have much less control on environment and have to support more versions and configuration than usual. see also below. On 2013-12-27 02:55, Doug Evans wrote: > On Wed, Dec 25, 2013 at 8:51 AM, Dmitry Samersoff > <dms@samersoff.net> wrote: Everyone, > > Just found a year old discussion about Abhijit proposal. > > So answering to upcoming question - why not a Python. > > Python is very good staff if your speak about source level > debugging. If you have to debug optimized binary python doesn't > help match for two reason - > > 1) you have to port all native data structure you plan to work > with to python. >> This typically isn't that hard an exercise, have you looked into >> it? I really like python (e.g. here is pure python elf reader and disassemblers for arm, sparc and x86 http://www.samersoff.net/hg/pydas/ written as a part of larger project) but ... Typical deadlock case requires me to deal with 10-20 structures. Counting different versions and separate big- and little- endian representation in Python, it creates a real zoo. And it's a pain to keep this zoo in sync with C version. In some case I can invoke target process code and it gives an alleviation but it not always possible. Use appropriate c headers directly and write simple native plugin is much easy and safer approach. Both windbg and mdb supports native plugins so I had a chance to compare different options in practice. > 2) python performance is not always acceptable and you not always > ever able to run a python. > >> I'd like to see the data that shows the performance isn't >> acceptable. This could just be mistaken impressions. On many of arm or mips boards overhead of python interpreter within debugging session is not acceptable. Not mentioning the fact, that I have to install python to this board first as it typically not there. (Yes, emulation helps but it's not always an option - e.g. it doesn't help to find that the program doesn't save one of FPU register on some version of hardware) Other example - walking through java heap. Re-implementation of garbage collector code in Python to optimize the walking is rather costly but without optimization it takes a while. - -Dmitry > To get a better picture of native plugins in action, please, take > a look at solaris mdb. > > -Dmitry > > On 2013-12-25 19:32, Dmitry Samersoff wrote: >>>> Joel, >>>> >>>> Thank you for the response. >>>> >>>> I found this patch >>>> https://sourceware.org/ml/gdb-patches/2012-05/msg00500.html - >>>> many thanks to Abhijit. >>>> >>>> 1. What is the reason to keep it off main trunk? Is there a >>>> chance to have it changed? >>>> >>>> 2. What API is available from within a plugin? i.e. how I >>>> can access coredump memory? >>>> >>>> -Dmitry >>>> >>>> On 2013-12-24 18:47, Joel Brobecker wrote: >>>>>> I need to implement scenario like one below: >>>>>> >>>>>> (gdb) load-plugin libgdbjvm.so (gdb) attach PID (gdb) >>>>>> jvm show loaded-classes (gdb) jvm show java-threads (gdb) >>>>>> jvm show code-cache >>>> >>>>> Maybe you could add some routines in your program that are >>>>> solely intended for debugging purposes, and then define >>>>> commands that call those routines. Off hand, that's the >>>>> only way I can think of. Otherwise, interface the C++ stuff >>>>> you need from Python - if necessary, export some stuff to >>>>> C? >>>> >>>> >>>> >>>> > - -- Dmitry Samersoff Saint Petersburg, Russia, http://devnull.samersoff.net * There will come soft rains ... -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJSvYtxAAoJEHEy08c4gIABuNYH/RLGcE+cF1wkcALL+Jnoj3iV xHPjQ0FsTakAPzuVin+9eXXS6I+Ap3ShNO+mhklAslIuf+Cb8xdK8Ocap0LyZ6o+ j23CRcKqDLVR3IZzgdlVbopm4fh1tqiy4CbSRGi8Yd7A0Z7i0eDvWEkRCLkbm7WU IpQtcjB+ZUJXEFAqJZ4pVbg7lzUVtBx86o00BbUqbJxGtW+aFGULXCZyu5PZAans 7/5cA7u9GI94bXt2vX95SPgBJN9LSRjyMOI6InMGIVOhAtNbwsThYAqaZ577Qt5g cgw3lWO+4P3g8qcxZs6U4W1tdTOXrhIYzLlq21Tn26Rx/eg/4m9gG5LfOHHrNFU= =GZ8+ -----END PGP SIGNATURE----- ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-12-27 14:15 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2013-12-24 12:31 How to write native (i.e. C/C++) plugin for gdb? Dmitry Samersoff 2013-12-24 13:16 ` Hui Zhu 2013-12-24 14:13 ` Dmitry Samersoff 2013-12-24 14:47 ` Joel Brobecker 2013-12-25 15:32 ` Dmitry Samersoff 2013-12-25 16:51 ` Dmitry Samersoff 2013-12-26 22:55 ` Doug Evans 2013-12-27 14:15 ` Dmitry Samersoff
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox