Hi all,

I have been look at the Dwarf2 frame info generated by GCC, and how it works. From what I can see, only the register saves are recorded, and not the restores. Why?

I guess it may loose GDB if one sets a breakpoint inside a function epilogue, right?



I am currently working on the debug_frame info emission in our C/C++ compiler (based on Open64) and I have recently come across optimized code which I don't know how to handle.

Consider the following function:

foo() {
    PROLOGUE

    if (COND1) {
        SAVE_REG r1 to stack (r1 is callee save)
        compute...
        bar1()
        RESTORE r1
    }
    else if (COND2) {
        bar2()
    }

    EPILOGUE
}

Suppose that the generated code looks like:
foo:
    PROLOGUE
    COND1
    if true goto LABEL1

    COND2
    if true goto LABEL2

epilogue_label:
    EPILOGUE

LABEL1:
    SAVE register r1 to stack
    compute....
    goto CALL_BAR1

LABEL2:
    CALL bar2
    goto epilogue_label

CALL_BAR1:
    CALL bar1
    RESTORE r1
    goto epilogue_label

My question is:
what debug_frame info should I generate around epilogue, LABEL1, LABEL2, and CALL_BAR1 ?
Should I repeat all the info of the prologue before LABEL1 and LABEL2?
for CALL_BAR1, should I also add the save of register r1 ?

It's also unclear to me if I can/should use the remember_state/restore_state dwarf operators.
Indeed, what is the rule?

Use remember_state after the prologue, and use restore state at LABEL1 and LABEL2? But as states are defined as a stack, it means I would restore twice the same thing...

Any help/suggestion highly appreciated!

Thanks,

Christophe.


Reply via email to