Skip to content

Inconsistent DWARF operation evaluation error message across LLVM versions when using -Oz #111041

@edumoot

Description

@edumoot

Inconsistent debug information error messages have been observed when evaluating certain DWARF operations. Specifically, when attempting to print the value of p_31 at line 17 in a reduced C code sample, different error messages are produced depending on the LLVM version used. Godblot link

In LLVM 19.1.0, a more detailed error message is generated: Could not evaluate DW_OP_entry_value: no matching call site param found

In contrast, older LLVM versions (18.1.8, 17.0.6, and 16.0.3) show a shorter error message: Could not evaluate DW_OP_entry_value

These discrepancies can be replicated by following certain steps when compiling and debugging the reduced C code sample. In LLVM19.1.0:

clang -g -Oz -o d1_Oz.out d1.c
(lldb) file d1_Oz.out
(lldb) b 17
(lldb) r
[...]
* thread #1, name = 'd1_Oz.out', stop reason = breakpoint 1.1
    frame #0: 0x0000555555555162 d1_Oz.out`func_28(p_31=<unavailable>) at d1.c:17:1
   14  	}
   15  	int32_t *func_28(uint32_t p_31) {
   16  	    *g_105 = p_31 * g_9;
-> 17  	}
   18  	int16_t func_33() {
   19  	}
   20  	void main() {
(lldb) fr v
(uint32_t) p_31 = <could not evaluate DW_OP_entry_value: no matching call site param found>

(lldb) p p_31
error: Couldn't materialize: couldn't get the value of variable p_31: could not evaluate DW_OP_entry_value: no matching call site param found
error: errored out in DoExecute, couldn't PrepareToExecuteJITExpression

llvm-dwarfdum --debug-info d1_Oz.out


0x000000dd:     DW_TAG_formal_parameter
                  DW_AT_location	(indexed (0x1) loclist = 0x00000022: 
                     [0x0000000000001152, 0x0000000000001159): DW_OP_reg5 RDI
                     [0x0000000000001159, 0x0000000000001163): DW_OP_entry_value(DW_OP_reg5 RDI), DW_OP_stack_value)
                  DW_AT_name	("p_31")
                  DW_AT_decl_file	("d1.c")
                  DW_AT_decl_line	(15)
                  DW_AT_type	(0x0000013c "uint32_t")

cat d1.c

#include "stdint.h"
int32_t g_9, g_106, g_38;
int32_t *g_105 = &g_106;
int8_t func_23(uint16_t);
int32_t *func_28();
int16_t func_33();
int16_t func_1() {
    uint32_t l_12;
    int32_t *l_218 = &g_38;
    *l_218 = func_23(l_12);
}
int8_t func_23(uint16_t) {
    func_28(func_33);
}
int32_t *func_28(uint32_t p_31) {
    *g_105 = p_31 * g_9;
}
int16_t func_33() {
}
void main() {
    func_1();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions