Re: Link Instruction & tt command
- From: ReneeTeunissen <member1134@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 23 Jun 2006 07:56:13 +0000
Hi *;
I would like to get better knowledge on tt command and what I read
about
it is:
In order to do the trace, some assumptions are made. In general, the
trace
will work for all C language routines and for assembly language
routines
that start with a LINK instruction. Some C compilers require specific
flags
to generate the LINK first. Most VxWorks assembly language routines
include
LINK instructions for this reason. The trace facility may produce
inaccurate
results or fail completely if the routine is written in a language
other
than C, the routine's entry point is non-standard, or the task's stack
is
corrupted. Also, all parameters are assumed to be 32-bit quantities,
so
structures passed as parameters will be displayed as long integers.
So who can help me to better understand what is a "Link Intruction"
and how
I can Identify
using a Programm Counter register and task ID if I can apply on a task
a tt
coomand ?
Thanks in advance for your supports.
Patrick
Hi Patrick,
Why dont you do it like all embedded developers do it....
create something like:
int f_c(int a1, int a2, int a3)
{
return taskSuspend(taskIdSelf());
}
int f_b(int a1, int a2, int a3)
{
return f_c(a1+2, a2+2, a3+2);
}
int f_a(int a1, int a2, int a3)
{
return f_b(a1+7, a2+8, a3+9);
}
and do a sp f_a,1,2,3 from the shell
-do a tt on the spawned task
-do a l (list asm) on the functions
-do examine the stack contents
-check on gcc for your cpu to see how it builds the stackframes.
-consider that there is always a register that point to the current
stack and to the frame pointer (start of stackframe)
Btw, by anychance, you didnt compile with -fomit-frame-pointer, did you?
If you do this, you're lost, since the compiler removes use of the the
framepointer, and you can not make any stacktraces.
normally if you call a function, this happens (more or less, possisble
in different order on different CPU's)
push arguments on stack in reverse order
create room for return value on stack
push current framepointer on stack
push return address on stack
create room on stack for local (non static) variables
goto function (set pc to subroutine)
You chould be able to figure this out using a debugger and some
creative thinking.
Using this information you can trackback all calling functions, if you
get the current framepointer, you know where the framepointer of calling
stackframe is stored, keep repeating this until you'll find a null
pointer, which says there is nog "higher" framepointer.
btw, if you know the return address, you also know that thr instruction
before this addres should be a 'jump_subsroutine <address>' where
address is the location of the funtion that is getting called there. Do
a lookup in the symbol table on this one, and you know the name of the
function (wont work for static functions).
Anyway, the story above descibes more or less how stacks work and how
they can me traced back. Look at the sample in John Borkhuis' excelent
VxWorks FAQ, and port it to your CPU. stack traces cant be that
difficult, if you are willing to do some reverse engineering.
Have fun, and hope this helps.
Cheers,
Renee
- - www.pts.nl / reneeteunissen.nl - - embedded software is my trade
--
.
- Prev by Date: Re: Link Instruction & tt command
- Next by Date: Security Library API (cciCipher() and cciCtxCipher() functions)
- Previous by thread: Re: Link Instruction & tt command
- Next by thread: data tranfer through VME backplane
- Index(es):
Relevant Pages
|