用gdb调试Rust [英] Debugging Rust with gdb

查看:2604
本文介绍了用gdb调试Rust的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道StackOverflow上的这个调试Rust 问题,而且我还在Go之前使用过gdb。但是,我遇到一个问题,似乎gdb无法找到调试符号。

I'm aware of the debugging Rust questions here on StackOverflow and I also used gdb before with Go. However, I'm running into a problem where it seems gdb is unable to locate the debug symbols.

main.rs中考虑这个复杂的程序

pub fn main () {
    println!("run");
}

我用调试符号编译它

rustc -g main.rs

然后我运行gdb

gdb main

这给出了第一个线索,加载调试符号的东西不太正确。

This gives the first clue that something with the loading of debug symbols is not quite right.

现在,当我在gdb并键入

Now when I'm in gdb and type

list

留下一些C代码,这不是我期望的。

it leaves me with some C code which isn't what I expect.

我做错了什么?我的gdb版本是7.7,我在OS X 10.9.2(13C64)上。我的rustc版本是rustc 0.11.0-pre(3035d8dfb13077e195eb056568183911c90c1b4b 2014-07-02 21:26:40 +0000)

What am I doing wrong? My gdb version is 7.7 and I'm on OS X 10.9.2 (13C64). My rustc version is rustc 0.11.0-pre (3035d8dfb13077e195eb056568183911c90c1b4b 2014-07-02 21:26:40 +0000)

它也可能有助于看到的输出`gdb --configuration``

It may also be helpful to see the output of `gdb --configuration``

$ gdb --configuration
This GDB was configured as follows:
   configure --host=x86_64-apple-darwin13.1.0 --target=x86_64-apple-darwin13.1.0
             --with-auto-load-dir=:${prefix}/share/auto-load
             --with-auto-load-safe-path=:${prefix}/share/auto-load
             --with-expat
             --with-gdb-datadir=/usr/local/share/gdb (relocatable)
             --with-jit-reader-dir=/usr/local/lib/gdb (relocatable)
             --without-libunwind-ia64
             --without-lzma
             --with-python=/System/Library/Frameworks/Python.framework/Versions/2.7
             --with-separate-debug-dir=/usr/local/lib/debug (relocatable)
             --with-zlib
             --without-babeltrace


推荐答案

相同的问题,以后Rust版本(1.0.0-beta),完全不同答案:

Same question, later Rust version (1.0.0-beta), totally different answer:

在GDB中调试一个Rust可执行文件时, break main 在某些设置代码中设置断点Rust标准库的一部分。这不是你想要的。

In GDB, when debugging a Rust executable, break main sets a breakpoint in some setup code that is part of the Rust standard library. This isn't what you want.

而是键入: break $ YOUR_CRATE :: main ,用您的程序 $ YOUR_CRATE

Instead type: break $YOUR_CRATE::main, substituting the name of your program for $YOUR_CRATE.

这篇关于用gdb调试Rust的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆