简体   繁体   English

如何让rbenv继续调试符号?

[英]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. 我在Mac OS X rbenv上通过rbenv安装了Ruby 2的开发版本,并使用它来编译我正在处理的gem。 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: 不幸的是,每当我在rake spec的上下文中运行valgrindgdbcgdb时,我都会遇到一堆像这样的错误

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. 显然, ruby-build目录不再存在。

I get a series of likely-related errors from valgrind . 我从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 : 如果我尝试使用--dsymutil=yes选项,我会得到与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 . 根据另一个问题的答案,我尝试在gdb运行info target 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? 有没有什么方法可以指示rbenv将调试符号放在他们不会被清理的地方?

I'm using GCC 4.7.1, which I installed via homebrew. 我正在使用GCC 4.7.1,我通过自制软件安装。 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. 我确切的Ruby版本字符串是ruby 2.1.0dev (2013-04-01 trunk 40029) [x86_64-darwin12.3.0] ,我的rbenv版本是0.4.0。

According to the documentation for ruby-build : 根据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. ruby-build和rbenv install都接受-k或-keep标志,它告诉ruby-build在安装后保留下载的源代码。 This can be useful if you need to use gdb and memprof with Ruby. 如果您需要在Ruby中使用gdb和memprof,这可能很有用。

So try ruby-build install X -k , where X is the version number. 所以尝试ruby-build install X -k ,其中X是版本号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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