Skip to content

Trouble calling a function from a debugger #12868

Closed
@alexcrichton

Description

@alexcrichton

Output of a session of mine:

fn factorial(x: int) -> int {
    if x <= 0 { 1 } else { x * factorial(x - 1) }
}

fn main() {
    let x = 4;
    println!("{}", factorial(x));
}
$ rustc -g inspect.rs  
$ lldb ./inspect        
Current executable set to './inspect' (x86_64).
(lldb) b main
Breakpoint 1: 2 locations.
(lldb) r
Process 45203 launched: './inspect' (x86_64)
Process 45203 stopped
* thread #1: tid = 0x370ce1, 0x0000000100001780 inspect`main, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2
    frame #0: 0x0000000100001780 inspect`main
inspect`main:
-> 0x100001780:  cmpq   %gs:0x330, %rsp
   0x100001789:  ja     0x1000017a5               ; main + 37
   0x10000178b:  movabsq $0x18, %r10
   0x100001795:  movabsq $0x0, %r11
(lldb) c
Process 45203 resuming
Process 45203 stopped
* thread #2: tid = 0x370cf7, 0x00000001000016b4 inspect`inspect::main + 52 at inspect.rs:6, stop reason = breakpoint 1.1
    frame #0: 0x00000001000016b4 inspect`inspect::main + 52 at inspect.rs:6
   3    }
   4   
   5    fn main() {
-> 6        let x = 4;
   7        println!("{}", factorial(x));
   8    }
(lldb) print factorial(5)
Error [IRForTarget]: Size of result type 'long (long)' couldn't be determined
error: warning: function 'factorial' has internal linkage but is not defined
note: used here
error: The expression could not be prepared to run in the target
(lldb) 

cc @michaelwoerister

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-debuginfoArea: Debugging information in compiled programs (DWARF, PDB, etc.)C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions