When debugging ruby on gdb, we often want to expand some preprocessor macros, such as RSTRING_LEN
, RARRAY_PTR
. To make preprocessor macros available to gdb, we should call gcc with these debugging options: -gdwarf-2 -g3
.
To configure ruby with these options, we do,
./configure debugflags="-gdwarf-2 -g3"
Then build ruby,
make
This allows us to expand preprocessor macros in gdb like this:
$ gdb --quiet /opt/ruby/trunk/bin/ruby Reading symbols for shared libraries .... done (gdb) b ruby_yyparse Breakpoint 1 at 0x20c49ba5cd1c8b: file parse.c, line 4583. (gdb) r Starting program: /opt/ruby/trunk/bin/ruby Reading symbols for shared libraries +++... done Reading symbols for shared libraries . done Breakpoint 1, ruby_yyparse (parser=0x10060c310) at parse.c:4583 4583 { (gdb) macro expand Qfalse expands to: ((VALUE)RUBY_Qfalse) (gdb) info macro RSTRING_PTR Defined at ../include/ruby/ruby.h:619 included at /Users/muraken/src/ruby.git/build-osx/parse.c:18 #define RSTRING_PTR(str) (!(RBASIC(str)->flags & RSTRING_NOEMBED) ? RSTRING(str)->as.ary : RSTRING(str)->as.heap.ptr) (gdb)
Note that we must be in a frame where the target preprocessor macros are visible.
I thank hayeah and ujihisa for helpful discussion about this topic and proofreading my English.
See also:
Thanks, this info was exactly what I needed.
ReplyDeleteOutstanding post and wonderful blog, I really like of interesting articles keep it up.courseworkspot.co.uk
ReplyDeleteYou did good work your placement is breathtaking its augment my information. do coursework uk
ReplyDeleteI enjoy it for creating the details, keep up the truly amazing perform continuing
ReplyDeleteナイトアイボーテ
I believe working on these micros can fix lot of problems in the coding. Thanks for sharing a perfect solution. Dissertation writing services UK
ReplyDelete, thanks you for sharing with us. This is nice blogs PLease visit profile picture
ReplyDeleteNice post. I was checking constantly this blog and I am impressed! Extremely helpful information specially the last part I care for such info a lot. I was seeking this particular information for a very long time. Thank you and good luck. instagram web viewer
ReplyDeleteYour blog provided us with valuable information to work with. Each & every tips of your post are awesome. Thanks a lot for sharing. Keep blogging, tokyo olimpics 2020
ReplyDelete