Commit 736903c1 authored by Russ Cox's avatar Russ Cox

libmach:

	* heuristic to go farther during stack traces.
	* significantly improved Linux thread handing.

acid:
	* update to new libmach interface.

prof:
	* use new libmach interface.
	* multiple thread support (derived from Rob's copy).
	* first steps toward pprof-like graphs:
	  keep counters indexed by pc,callerpc pairs.

R=r
DELTA=909  (576 added, 123 deleted, 210 changed)
OCL=24240
CL=24259
parent 9aa28f92
......@@ -415,7 +415,7 @@ int ctlproc(int pid, char *msg);
void detachproc(Map *m);
int procnotes(int pid, char ***pnotes);
char* proctextfile(int pid);
int procthreadpids(int pid, int **thread);
int procthreadpids(int pid, int *tid, int ntid);
char* procstatus(int);
Maprw fdrw;
This diff is collapsed.
......@@ -145,7 +145,7 @@ static int
i386trace(Map *map, uvlong pc, uvlong sp, uvlong link, Tracer trace)
{
int i;
uvlong osp;
uvlong osp, pc1;
Symbol s, f, s1;
extern Mach mamd64;
int isamd64;
......@@ -189,19 +189,30 @@ i386trace(Map *map, uvlong pc, uvlong sp, uvlong link, Tracer trace)
break;
}
s1 = s;
pc1 = 0;
if(pc != s.value) { /* not at first instruction */
if(findlocal(&s, FRAMENAME, &f) == 0)
break;
geta(map, sp, &pc1);
sp += f.value-mach->szaddr;
}
if (geta(map, sp, &pc) < 0)
if(geta(map, sp, &pc) < 0)
break;
// If PC is not valid, assume we caught the function
// before it moved the stack pointer down or perhaps
// after it moved the stack pointer back up.
// Try the PC we'd have gotten without the stack
// pointer adjustment above (pc != s.value).
// This only matters for the first frame, and it is only
// a heuristic, but it does help.
if(!findsym(pc, CTEXT, &s) || strcmp(s.name, "etext") == 0)
pc = pc1;
if(pc == 0)
break;
if (pc != retfromnewstack)
if(pc != retfromnewstack)
(*trace)(map, pc, sp, &s1);
sp += mach->szaddr;
......
......@@ -341,11 +341,10 @@ attachproc(int id, Fhdr *fp)
// Return list of ids for threads in id.
int
procthreadpids(int id, int **thread)
procthreadpids(int id, int *out, int nout)
{
Thread *t;
int i, n, pid;
int *out;
t = idtotable(id);
if(t == nil)
......@@ -353,17 +352,13 @@ procthreadpids(int id, int **thread)
pid = t->pid;
addpid(pid, 1); // force refresh of thread list
n = 0;
for(i=0; i<nthr; i++)
if(thr[i].pid == pid)
for(i=0; i<nthr; i++) {
if(thr[i].pid == pid) {
if(n < nout)
out[n] = -(i+1);
n++;
out = malloc(n*sizeof out[0]);
if(out == nil)
return -1;
n = 0;
for(i=0; i<nthr; i++)
if(thr[i].pid == pid)
out[n++] = -(i+1);
*thread = out;
}
}
return n;
}
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment