This blog describes anything about @mrkn's thoughts, which includes computer programming (mostly Ruby, Haskell, and C++), mathematics, physics, and so on. Each article is written in English for learning it.


To use preprocessor macros on gdb

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,


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)

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:


  1. Thanks, this info was exactly what I needed.

  2. Outstanding post and wonderful blog, I really like of interesting articles keep it

  3. You did good work your placement is breathtaking its augment my information. do coursework uk

  4. I enjoy it for creating the details, keep up the truly amazing perform continuing

  5. I believe working on these micros can fix lot of problems in the coding. Thanks for sharing a perfect solution. Dissertation writing services UK

  6. , thanks you for sharing with us. This is nice blogs PLease visit profile picture

  7. Nice 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

  8. Your 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

  9. Spin Casino knows 원 엑스 벳 of} that, so it isn’t chopping any corners in banking on the experience of award-winning software producers Microgaming and Evolution Gaming. That means New Zealand gamblers win even earlier than they place a wager. While Spin Casino beckons on its website, it’s not till Kiwi gamers enter the neon concrete jungle touchdown page that they’ll start to savour the richness of what’s on supply. The on-line casino’s overall Return to Player , or payout proportion, is a handsome 96.5%. Spin Casino is a authorized, trusted and safe on-line casino that has been round since 2001 with its headquarters in Malta. Spin Casino is the rebranded model of Spin Palace, is authorized for gamers from New Zealand and holds a legitimate gambling license from the Kahnawake Gaming Commission.

  10. The second most typical category of video games gamers see on gaming web sites is 우리카지노 blackjack. Blackjack, or 21, is a well-liked table classic that has been performed for centuries of years}. Thanks to its simplistic rules, blackjack has found its method to virtually all continents, which resulted in a myriad of variants native to each continent.

  11. The software says stunning to read these sort of revealing and additionally completely unique articles or reviews upon your webpages. whoer