To troubleshoot, I would like to be able to find and print the caller's stack of the current function. I tried the following:
/******************************************************************************* * * * * xxxTracePrint - stack trace print function * * * * RETURNS: OK or ERROR * */ static void xxxTracePrint ( INSTR *caller, int func, int nargs, int *args ) { char buf [250]; int ix; int len = 0; len += sprintf (&buf [len], "%#10x: %#10x (", (int)caller, func); for (ix = 0; ix < nargs; ix++) { if (ix != 0) len += sprintf (&buf [len], ", "); len += sprintf (&buf [len], "%#x", args [ix]); } len += sprintf (&buf [len], ")\n"); printf (buf); } /******************************************************************************* * * * * xxxTrace - stack trace * * * * RETURNS: OK or ERROR * */ int xxxTrace(int tcb) { REG_SET regs; if (tcb == 0) return (ERROR); taskRegsGet (tcb, ®s); trcStack (®s, (FUNCPTR) xxxTracePrint, tcb); return (OK); } void DbgTest(void) { xxxTrace(taskIdSelf()); }
but I get:
JPAX-DP> DbgTest trcStack aborted: error in top frame value = 0 = 0x0
Is it possible? How can i do this? I saw that for taskRegsGet () they say:
This procedure only works well if the task is known to be stable, non-fulfillment. For example, introspection is impractical because the results are unpredictable.
But what other method should I apply?
diab and cpu arch powerpc compiler
source share