Skip to content

(Ubuntu's) lldb doesn't print stack variables #33062

Closed
@japaric

Description

@japaric

Note: This issue isn't Ubuntu specific as I observe the same issue on the obscure Linux distribution I use everyday.

STR

$ cat foo.rs
fn main() {
    let x = 1;
    let y = frob(x);
}

#[no_mangle]
fn frob(x: i32) -> u32 {
    let y = x as u32;
    y
}

$ rustc -g foo.rs

$ lldb ./foo
(lldb) target create "./foo"
Current executable set to './foo' (x86_64).
(lldb) b frob
Breakpoint 1: where = foo`frob + 7, address = 0x0000000000005247
(lldb) r
Process 4499 launched: './foo' (x86_64)
Process 4499 stopped
* thread #1: tid = 4499, 0x0000555555559247 foo`frob + 7 at foo.rs:8, name = 'foo', stop reason = breakpoint 1.1
    frame #0: 0x0000555555559247 foo`frob + 7 at foo.rs:8
   5
   6    #[no_mangle]
   7    fn frob(x: i32) -> u32 {
-> 8        let y = x as u32;
   9        y
   10   }
(lldb) p &x
(lldb) p &y
(lldb) p x
(lldb) frame variable
(lldb)

lldb doesn't print stack variables, but gdb does:

$ gdb ./foo
(...)
(gdb) b frob
Breakpoint 1 at 0x5247: file foo.rs, line 8.
(gdb) r
Starting program: /home/japaric/foo
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Breakpoint 1, foo::frob (x=1) at foo.rs:8
8           let y = x as u32;
(gdb) p &x
$1 = (i32 *) 0x7fffffffe3fc
(gdb) p &y
$2 = (u32 *) 0x7fffffffe3f8
(gdb) p x
$3 = 1
(gdb) info args
x = 1
(gdb) info locals
y = 4286582784

And lldb can print stack variables just fine when used with C programs:

$ cat foo.c
int frob(int);

int main() {
  int x = 1;
  int y = frob(x);

  return y;
}

int frob(int x) {
  unsigned int y = x;
  return y;
}

$ gcc -g foo.c
$ lldb ./a.out
(lldb) target create "./a.out"
Current executable set to './a.out' (x86_64).
(lldb) b frob
Breakpoint 1: where = a.out`frob + 7 at foo.c:11, address = 0x000000000040051e
(lldb) r
Process 4605 launched: './a.out' (x86_64)
Process 4605 stopped
* thread #1: tid = 4605, 0x000000000040051e a.out`frob(x=1) + 7 at foo.c:11, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x000000000040051e a.out`frob(x=1) + 7 at foo.c:11
   8    }
   9
   10   int frob(int x) {
-> 11     unsigned int y = x;
   12     return y;
   13   }
(lldb) p &x
(int *) $0 = 0x00007fffffffe63c
(lldb) p &y
(unsigned int *) $1 = 0x00007fffffffe64c
(lldb) p x
(int) $2 = 1
(lldb) frame variable
(int) x = 1
(unsigned int) y = 0

I'm not sure what's going on. Do I need some extra steps to make lldb fully work with Rust programs? I tried rust-lldb but I get the same behavior.

Meta

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=15.10
DISTRIB_CODENAME=wily
DISTRIB_DESCRIPTION="Ubuntu 15.10"

$ lldb -v
lldb version 3.8.1 ( revision )

$ gdb -v
GNU gdb (Ubuntu 7.10-1ubuntu2) 7.10
(...)

$ rustc -Vv
rustc 1.10.0-nightly (2174bd97c 2016-04-14)
binary: rustc
commit-hash: 2174bd97c1458d89a87eb2b614135d7ad68d6f18
commit-date: 2016-04-14
host: x86_64-unknown-linux-gnu
release: 1.10.0-nightly

cc @michaelwoerister

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions