简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM