# Debugging Ruby Core

**URL:** <https://www.ruby-forum.com/t/debugging-ruby-core/149283>\
**Category:** Ruby\
**Created:** [September 23, 2008, 9:39am UTC](https://www.ruby-forum.com/t/debugging-ruby-core/149283 "2008-09-23T09:39:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![saladinmundi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@saladinmundi](https://www.ruby-forum.com/u/saladinmundi)\
**Post date:** [September 23, 2008, 9:39am UTC](https://www.ruby-forum.com/t/debugging-ruby-core/149283/1 "2008-09-23T09:39:22Z")

</div>

Hello everyone,

is there a debugger which I could use for debugging the C-Core if I  
modify it?

Thanks so much,

sala

---

<div class="post-metadata">

**Author:** ![saladinmundi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@saladinmundi](https://www.ruby-forum.com/u/saladinmundi)\
**Post date:** [September 23, 2008, 10:10pm UTC](https://www.ruby-forum.com/t/debugging-ruby-core/149283/2 "2008-09-23T22:10:36Z")

</div>

Saladin M. wrote:

> is there a debugger which I could use for debugging the C-Core if I  
> modify it?

There’s nothing special about Ruby’s C core. You can use whatever  
debugger goes with the compiler you use, eg Microsoft’s debugging tools  
if compiled with MSVC; gdb if compiled with gcc (although I’ve found gdb  
on MingW / Windows pretty unstable).

If you want a step-through debugger for Ruby, I’d look into ruby-debug.  
It’s much faster than ruby’s stdlib pure-ruby debugger, and also has  
nice integration eg with emacs.

alex

---

<div class="post-metadata">

**Author:** ![saladinmundi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@saladinmundi](https://www.ruby-forum.com/u/saladinmundi)\
**Post date:** [September 24, 2008, 1:25pm UTC](https://www.ruby-forum.com/t/debugging-ruby-core/149283/3 "2008-09-24T13:25:46Z")

</div>

Thank you,  
I’ll have a look!

---

<div class="post-metadata">

**Author:** ![saladinmundi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@saladinmundi](https://www.ruby-forum.com/u/saladinmundi)\
**Post date:** [September 24, 2008, 2:45pm UTC](https://www.ruby-forum.com/t/debugging-ruby-core/149283/4 "2008-09-24T14:45:22Z")

</div>

Alex F. wrote:

> Saladin M. wrote:
> 
> > is there a debugger which I could use for debugging the C-Core if I  
> > modify it?
> 
> There’s nothing special about Ruby’s C core. You can use whatever  
> debugger goes with the compiler you use, eg Microsoft’s debugging tools  
> if compiled with MSVC; gdb if compiled with gcc (although I’ve found gdb  
> on MingW / Windows pretty unstable).
> 
> If you want a step-through debugger for Ruby, I’d look into ruby-debug.  
> It’s much faster than ruby’s stdlib pure-ruby debugger, and also has  
> nice integration eg with emacs.
> 
> alex

But , in order to do this ( with gdb ) , shouldn’t ruby be recompiled  
with -g ? Or that option is already set ?

---

<div class="post-metadata">

**Author:** ![saladinmundi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@saladinmundi](https://www.ruby-forum.com/u/saladinmundi)\
**Post date:** [September 24, 2008, 3:50pm UTC](https://www.ruby-forum.com/t/debugging-ruby-core/149283/5 "2008-09-24T15:50:30Z")

</div>

Lex W. wrote:

> But , in order to do this ( with gdb ) , shouldn’t ruby be recompiled  
> with -g ? Or that option is already set ?

-g flag to gcc is needed, but recompilation isn’t always going to be  
necessary.

The last time I built ruby (MingW, 1.9.0-4) gcc got the options “-g -O2”  
without having to do anything special, just “./configure; make”

Distro / vendor supplied rubies will vary in how they’re compiled.

a

---

<div class="post-metadata">

**Author:** ![saladinmundi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@saladinmundi](https://www.ruby-forum.com/u/saladinmundi)\
**Post date:** [September 24, 2008, 4:01pm UTC](https://www.ruby-forum.com/t/debugging-ruby-core/149283/6 "2008-09-24T16:01:54Z")

</div>

> The last time I built ruby (MingW, 1.9.0-4) gcc got the options “-g -O2”  
> without having to do anything special, just “./configure; make”

I also use MingGW.  
Do I have to put -g 02 in the config “string” ?

(Now I only use:  
/configure --with-baseruby=/home/MYUSERNAME/ruby-1.8.6/bin/ruby.exe  
–prefix=/rubytest --program-suffix=test  
)

How would it look like with the gnu debugger?

---

<div class="post-metadata">

**Author:** ![saladinmundi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@saladinmundi](https://www.ruby-forum.com/u/saladinmundi)\
**Post date:** [October 2, 2008, 8:23am UTC](https://www.ruby-forum.com/t/debugging-ruby-core/149283/7 "2008-10-02T08:23:08Z")

</div>

Saladin, did you succeed in debugging the MinGW Ruby? I’m interested  
in this, too.

Regards,  
Pit

---

<div class="post-metadata">

**Author:** ![saladinmundi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@saladinmundi](https://www.ruby-forum.com/u/saladinmundi)\
**Post date:** [September 24, 2008, 4:12pm UTC](https://www.ruby-forum.com/t/debugging-ruby-core/149283/8 "2008-09-24T16:12:22Z")

</div>

Saladin M. wrote:

> > The last time I built ruby (MingW, 1.9.0-4) gcc got the options “-g -O2”  
> > without having to do anything special, just “./configure; make”
> 
> I also use MingGW.  
> Do I have to put -g 02 in the config “string” ?
> 
> (Now I only use:  
> /configure --with-baseruby=/home/MYUSERNAME/ruby-1.8.6/bin/ruby.exe  
> –prefix=/rubytest --program-suffix=test  
> )
> 
> How would it look like with the gnu debugger?

Typically you specify additional/overriding gcc flags with the CFLAGS  
environment variable, so you could say

export CFLAGS=-g  
./configure …whatever…

I’m surprised that Alex got “-g -O2” automatically. I would not expect  
Ruby to compile with debugging information by default.

---

<div class="post-metadata">

**Author:** ![saladinmundi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@saladinmundi](https://www.ruby-forum.com/u/saladinmundi)\
**Post date:** [October 2, 2008, 4:50pm UTC](https://www.ruby-forum.com/t/debugging-ruby-core/149283/9 "2008-10-02T16:50:13Z")

</div>

Pit C. wrote:

> Saladin, did you succeed in debugging the MinGW Ruby? I’m interested  
> in this, too.

Hey Pit,  
well not really. I used this tutorial  
[http://www.ruby-mine.de/2007/5/7/ruby-1-9-aus-neuen-snapshots-auf-windows-erstellen](http://www.ruby-mine.de/2007/5/7/ruby-1-9-aus-neuen-snapshots-auf-windows-erstellen)  
from [Ruby-Mine.de](http://Ruby-Mine.de) (unless its in german)

Additionally I installed the gnu debugger into msys. But I have no real  
clue how to really use the debugger. For my actual tasks it is enough to  
look into the msys console when compiling Ruby.

I had a closer look into the compiling dialog from msys and there it  
shows me the line “gcc -g -02 …” (like Alex mentioned).

If this is equivalent to the gnu debugger than I have it. I’m a little  
bit overstrained with it because I don’t really now what I could really  
do with it.
