Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get rbenv to keep debugging symbols?

I installed the development version of Ruby 2 via rbenv on Mac OS X v10.8.3, and am using it to compile a gem I'm working on. I have a memory problem I want to debug. Unfortunately, whenever I run valgrind, gdb, or cgdb in the context of a rake spec, I get a whole bunch of errors like this one:

warning: Could not find object file "/private/var/folders/5f/h1s00nhn0rv4ckkpg4k_bwhr0000gn/T/ruby-build.20130331232604.54521/ruby-2.0.0-dev/main.o" - no debug information available for "main.c".

Obviously, that ruby-build directory no longer exists.

I get a series of likely-related errors from valgrind. Here are examples:

--2564-- /Users/jwoods/.rbenv/versions/2.0.0-dev/lib/libyaml-0.2.dylib:
--2564-- dSYM directory is missing; consider using --dsymutil=yes

If I try to use that --dsymutil=yes option, I get errors which are basically the same as those from gdb:

warning: (x86_64) /private/var/folders/5f/h1s00nhn0rv4ckkpg4k_bwhr0000gn/T/ruby-build.20130331232604.54521/ruby-2.0.0-dev/ext/openssl/ossl_bn.o unable to open object file

Per an answer to another question, I tried running info target inside gdb. Here is the output.

Is there some way I can instruct rbenv to put the debugging symbols somewhere that they won't get cleaned up?

I'm using GCC 4.7.1, which I installed via homebrew. My exact Ruby version string is ruby 2.1.0dev (2013-04-01 trunk 40029) [x86_64-darwin12.3.0], and my rbenv version is 0.4.0.

like image 632
Translunar Avatar asked May 07 '13 19:05

Translunar


People also ask

How do I update my Rbenv?

Since you installed rbenv manually using Git, you can upgrade your installation to the most recent version at any time by using the git pull command in the ~/. rbenv directory: cd ~/. rbenv.

What does Rbenv mean?

rbenv is a tool that lets you install and run multiple versions of Ruby side-by-side.

What does Rbenv shell do?

rbenv provides support for specifying application-specific versions of Ruby, lets you change the global Ruby for each user, and allows you to use an environment variable to override the Ruby version. In this tutorial, you will use rbenv to install and set up Ruby on Rails on your local macOS machine.

Where does Rbenv store Ruby?

Ruby itself is installed in ~/. rbenv/versions/2.7. 1 but you usually don't want to specify that explicitly.


1 Answers

According to the documentation for ruby-build:

Both ruby-build and rbenv install accept the -k or --keep flag, which tells ruby-build to keep the downloaded source after installation. This can be useful if you need to use gdb and memprof with Ruby.

So try ruby-build install X -k, where X is the version number.

like image 138
David Weiser Avatar answered Oct 16 '22 06:10

David Weiser