[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
| 
[tcf-dev] Question about the step-over logic.
 | 
Hi,
I'm trying to understand how the line-step-over logic works. Here is my 
current understanding (see below).
First, I would like someone to confirm if my understanding is good.
Then, I have a few questions when we try to step-over a function that 
has NO debug_informations.
Thanks.
First, let's consider we have debug-info / debug-frames generated.
When we start a step-over:
in runctrl.c:
            if (ext->step_cnt == 0) {
                StackFrame * info = NULL;
                ext->step_frame_fp = 0;
                if (get_frame_info(ctx, STACK_TOP_FRAME, &info) < 0) 
return -1;
==> We get the current "fp" for the current function.
Can someone confirm:
   "fp" means "frame address" aka CFA (canonical frame address)
    So the value retrieved for the ctx is the one described by the CFA 
rule matching the instruction pointer.:
   cfa = 00(r3) (for example using dwarfdump -f)
Then the stepping of the line range starts. When we are out-of the 
range, it means:
a) Either we have finish the step-over.
b) Either we are in a function called by the stepped line.
When out-of-range:
We get the "fp". If the computed fp is the same as previous, we are in 
case a). Easy, done.
If the the computed "fp" is different, we are in case b) and we retrieve 
the caller @ in step_bp_addr, resume the target.
Now my question comes when the stepped-line has a call to a function 
that has no debug info.
We end-up at the very beginning of the function.
We go into the "stack crawl" code. Either the one from open-source or a 
custom-one.
I'm currently writing a custom-one for a an architecture that works with 
way:
Let's say the stack-pointer is r3.
jarl <foo>
When in <foo>
r3 has NOT changed.
r31 acts as LR and contains the return @.
The prolog will create a "frame pointer". But we are currently stopped 
at the first instruction of the function.
So prolog has NOT been executed.
What should we return to (get_frame_info(ctx, STACK_TOP_FRAME, &info) 
for info.fp ?
Can we return 0 as "fp" in the following case ?
    - we have no debug_information.
   -  we are stopped at the beginning of the function (so prolog has 
NOT been executed).
Returning 0 as "fp" (aka cfa) will ensure that the following code in 
runctrl.c will pass.
(step_cnt > 0)
                if (get_frame_info(ctx, n, &info) < 0) return -1;
                if (ext->step_frame_fp != info->fp) {
            .... retrieve caller, set step_bp_addr ....
            }
I've taken a look at what the compiler generates at the beginning of 
function:
cfa = 0(r3).
So if I return r3, which was my first idea, that would be a problem 
because ext->step_frame_fp == info->fp.
Or is cfa = 0(r3) a compiler bug ? I have this rule as the first 
instruction of any function.
Conceptually, I have trouble understanding what CFA should be at the 
first instruction of a function.
Thanks !