I'll set up a nested structure to feed to perl's not operator, and then dump it out from within the not op.
$ gdb perl5.8.7 GNU gdb 6.3.50_2004-12-28-cvs (cygwin-special) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and y +ou are welcome to change it and/or distribute copies of it under certain cond +itions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for det +ails. This GDB was configured as "i686-pc-cygwin"... (gdb) set args -we'![a=>{b=>0,c=>1},sub{"foo"}]' (gdb) b Perl_pp_not Function "Perl_pp_not" not defined. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 1 (Perl_pp_not) pending. (gdb) r Starting program: /usr/local/bin/perl5.8.7.exe -we'![a=>{b=>0,c=>1},su +b{"foo"}]' Breakpoint 2 at 0x100bbe8f: file pp.c, line 2396. Pending breakpoint "Perl_pp_not" resolved Useless use of not in void context at -e line 1. Breakpoint 2, Perl_pp_not (my_perl=0x103c1f58) at pp.c:2396 2396 dSP; tryAMAGICunSET(not); (gdb) s 2397 *PL_stack_sp = boolSV(!SvTRUE(*PL_stack_sp)); (gdb) call Perl_do_sv_dump(Perl_get_context(),0,Perl_PerlIO_stderr(Per +l_get_con text()),*sp,0,4,0,0) SV = RV(0x103e9824) at 0x103e7588 REFCNT = 1 FLAGS = (TEMP,ROK) RV = 0x103c323c SV = PVAV(0x103e9c40) at 0x103c323c REFCNT = 2 FLAGS = () IV = 0 NV = 0 ARRAY = 0x103c9ba8 FILL = 2 MAX = 2 ARYLEN = 0x0 FLAGS = (REAL) Elt No. 0 SV = PV(0x103c3468) at 0x103e7564 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x103c4898 "a"\0 CUR = 1 LEN = 2 Elt No. 1 SV = RV(0x103e981c) at 0x103e7570 REFCNT = 1 FLAGS = (ROK) RV = 0x103c3188 SV = PVHV(0x103e2990) at 0x103c3188 REFCNT = 3 FLAGS = (SHAREKEYS) IV = 2 NV = 0 ARRAY = 0x103e8e48 (0:6, 1:2) hash quality = 125.0% KEYS = 2 FILL = 2 MAX = 7 RITER = -1 EITER = 0x0 Elt "c" HASH = 0xeeba5d59 SV = IV(0x103e9428) at 0x103e74a4 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 1 Elt No. 2 SV = RV(0x103e9820) at 0x103e757c REFCNT = 1 FLAGS = (ROK) RV = 0x103e7504 SV = PVCV(0x103e0f08) at 0x103e7504 REFCNT = 3 FLAGS = (PADBUSY,PADMY,ANON,WEAKOUTSIDE) IV = 0 NV = 0 COMP_STASH = 0x103c30b0 "main" START = 0x103e5608 ===> 1 ROOT = 0x103eaa48 XSUB = 0x0 XSUBANY = 0 GVGV::GV = 0x103e7534 "main" :: "__ANON__" FILE = "-e" DEPTH = 0 FLAGS = 0x404 OUTSIDE_SEQ = 0 PADLIST = 0x103e7510 PADNAME = 0x103e751c(0x103e7ce8) PAD = 0x103e7528(0x10 +3e7c68) OUTSIDE = 0x103c32b4 (MAIN) (gdb)
Most of the parameters can be left as zero; file needs to be a PerlIO* to where the output should go, sv is the sv to dump, and maxnest is how deep to go in complex data structures.Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 m +axnest, bool dumpops, STRLEN pvlim)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to dump perl data structures from gdb
by salva (Canon) on Apr 19, 2005 at 15:31 UTC | |
by Anonymous Monk on Apr 21, 2005 at 00:34 UTC | |
by salva (Canon) on Apr 21, 2005 at 08:40 UTC | |
|
Re: How to dump perl data structures from gdb
by RMGir (Prior) on Apr 19, 2005 at 14:44 UTC |