Working on better handling of multithreading in general

and core dumps in particular.  See notes:

new types: register is something that when dereferenced gives you
	the registers.  the Ureg is no longer mapped at 0.
	refconst is something that gives a constant when dereferenced.

new builtin register("AX") creates register values
new builtin refconst(0x123) creates refconst values

new builtin var("foo") is equivalent to the variable foo
	(it returns foo but can also be used as the lhs of an assignment).

new acid function getregs() returns a list of the current values of registers.
new acid function setregs() sets the current registers to those values.
	note that getregs and setregs operate on register locations, not the
		register values themselves.
new acid function resetregs() sets registers to register("AX"), etc.
new acid function clearregs() sets all registers to constant -1.
the default register settings are as in resetregs(), not small numbers.

new acid variables coretext, pids, systype, corefile, cmdline.

new behavior: local variable lookup, stk, etc., use the acid values of registers
	(*PC, *SP, and so on), so the thread support code can change the context
	completely.

unary + is applicable to more data types and prints more often.
This commit is contained in:
rsc 2005-01-23 22:48:19 +00:00
parent a5f9ff62b2
commit 4f2ac1b76b
10 changed files with 523 additions and 171 deletions

View file

@ -21,30 +21,39 @@ sproc(int xpid)
if(pid == xpid)
return;
if(xpid <= 0)
error("bad pid");
if(corhdr){
free(correg);
correg = nil;
correg = coreregs(corhdr, xpid);
if(correg == nil)
error("no such pid in core dump");
}else{
/* XXX should only change register set here if cormap already mapped */
if(xpid <= 0)
error("bad pid");
unmapproc(cormap);
unmapfile(corhdr, cormap);
free(correg);
correg = nil;
unmapproc(cormap);
unmapfile(corhdr, cormap);
free(correg);
correg = nil;
if(mapproc(xpid, cormap, &correg) < 0)
error("setproc %d: %r", xpid);
if(mapproc(xpid, cormap, &correg) < 0)
error("setproc %d: %r", xpid);
/* XXX check text file here? */
/* XXX check text file here? */
for(i=0; i<cormap->nseg; i++){
if(cormap->seg[i].file == nil){
if(strcmp(cormap->seg[i].name, "data") == 0)
cormap->seg[i].name = "*data";
if(strcmp(cormap->seg[i].name, "text") == 0)
cormap->seg[i].name = "*text";
}
}
}
pid = xpid;
s = look("pid");
s->v->store.u.ival = pid;
for(i=0; i<cormap->nseg; i++)
if(cormap->seg[i].file == nil){
if(strcmp(cormap->seg[i].name, "data") == 0)
cormap->seg[i].name = "*data";
if(strcmp(cormap->seg[i].name, "text") == 0)
cormap->seg[i].name = "*text";
}
install(pid);
}
@ -165,6 +174,7 @@ install(int pid)
s->v->set = 1;
}
/*
static int
installed(int pid)
{
@ -175,6 +185,7 @@ installed(int pid)
return 1;
return 0;
}
*/
void
deinstall(int pid)