This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

debug_frame for optimized code



Hi all,


I know this is not a question directly related to GDB, but I don't know where else I could ask....

I am currently working on the debug_frame info emission in our C/C++
compiler (based on Open64).
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
		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

So my question is:
what debug_frame info should I generate around 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.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]