* [9fans] acid question
@ 2010-07-17 8:33 Skip Tavakkolian
2010-07-17 8:48 ` EBo
2010-07-17 15:00 ` Philippe Anel
0 siblings, 2 replies; 14+ messages in thread
From: Skip Tavakkolian @ 2010-07-17 8:33 UTC (permalink / raw)
To: 9fans
is there a way to do in acid the equivalent to gdb 'call'?
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] acid question
2010-07-17 8:33 [9fans] acid question Skip Tavakkolian
@ 2010-07-17 8:48 ` EBo
2010-07-17 9:19 ` Skip Tavakkolian
2010-07-17 15:00 ` Philippe Anel
1 sibling, 1 reply; 14+ messages in thread
From: EBo @ 2010-07-17 8:48 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
> is there a way to do in acid the equivalent to gdb 'call'?
I have not spent any time with acid so I cannot say definitively, but if
you are referring to the trick I did to develop an embedded regression test
suite was to set break points and then test specific variables or continue
to other break points which revealed the proper behavior as a pass or fail.
I was able to put all this into a series of .gdbinit's. Looking at the
acid documentation it appears that there is an equivalent functionality.
So as long as there is a way to read a configuration file when acid starts,
then yes. If not, then it should be relatively easy to add.
I hope this answered your question, assuming I was the one you were asking
the question of.
EBo --
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] acid question
2010-07-17 8:48 ` EBo
@ 2010-07-17 9:19 ` Skip Tavakkolian
2010-07-17 12:15 ` EBo
0 siblings, 1 reply; 14+ messages in thread
From: Skip Tavakkolian @ 2010-07-17 9:19 UTC (permalink / raw)
To: 9fans
i've spent some time with acid and i think the answer is no.
i wasn't referring to your reply to my acid suggestion on gsoc -- but
my question is related to what you asked about unit testing. if there
is a way to call arbitrary functions in a program under acid's
control, then it should be easy to generate acid scripts to do unit
tests.
-Skip
>> is there a way to do in acid the equivalent to gdb 'call'?
>
> I have not spent any time with acid so I cannot say definitively, but if
> you are referring to the trick I did to develop an embedded regression test
> suite was to set break points and then test specific variables or continue
> to other break points which revealed the proper behavior as a pass or fail.
> I was able to put all this into a series of .gdbinit's. Looking at the
> acid documentation it appears that there is an equivalent functionality.
> So as long as there is a way to read a configuration file when acid starts,
> then yes. If not, then it should be relatively easy to add.
>
> I hope this answered your question, assuming I was the one you were asking
> the question of.
>
> EBo --
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] acid question
2010-07-17 9:19 ` Skip Tavakkolian
@ 2010-07-17 12:15 ` EBo
0 siblings, 0 replies; 14+ messages in thread
From: EBo @ 2010-07-17 12:15 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
> i've spent some time with acid and i think the answer is no.
What is the hold up?
> i wasn't referring to your reply to my acid suggestion on gsoc -- but
> my question is related to what you asked about unit testing. if there
> is a way to call arbitrary functions in a program under acid's
> control, then it should be easy to generate acid scripts to do unit
> tests.
I would not say arbitrary, but you can start a program and play around in
the internals. So, I think we agree. One the other hand, a mixture of
little test programs and acid scripts might be able to do the same thing.
EBo --
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] acid question
2010-07-17 8:33 [9fans] acid question Skip Tavakkolian
2010-07-17 8:48 ` EBo
@ 2010-07-17 15:00 ` Philippe Anel
2010-07-17 15:56 ` Philippe Anel
1 sibling, 1 reply; 14+ messages in thread
From: Philippe Anel @ 2010-07-17 15:00 UTC (permalink / raw)
To: 9fans
On 7/17/2010 10:33 AM, Skip Tavakkolian wrote:
> is there a way to do in acid the equivalent to gdb 'call'?
>
>
Did you try to write an acid function with something like this :
*PC=test
where 'test' is the name of the function to call such as:
void test(void)
{
print("hello from test\n");
}
?
You'll have to save SP, PC, and maybe add a breakpoint somewhere and
even push the address of this breakpoint to SP before calling 'cont()'
acid function. But I think it will do the trick.
Phil;
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] acid question
2010-07-17 15:00 ` Philippe Anel
@ 2010-07-17 15:56 ` Philippe Anel
2010-07-17 16:46 ` cinap_lenrek
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Philippe Anel @ 2010-07-17 15:56 UTC (permalink / raw)
To: 9fans
This one sounds like to work (except it does not save registers) ...
defn call(addr)
{
local pco;
// we need stack space, and thus process stopped.
if status(pid) != "Stopped" then {
print("Waiting...\n");
stop(pid);
}
// Backup orginal instruction
pco = fmt(*PC, bpfmt);
// Put a temporary breakpoint
**PC = bpinst;
// update stack pointer
*SP = *SP - 4;
// make called function returning to this point
**SP = *PC;
// set PC to function to call
*PC = addr;
// do the call
startstop(pid);
// restore original instruction
*PC = pco;
}
Phil;
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] acid question
2010-07-17 15:56 ` Philippe Anel
@ 2010-07-17 16:46 ` cinap_lenrek
2010-07-17 16:48 ` cinap_lenrek
2010-07-17 17:23 ` Skip Tavakkolian
2 siblings, 0 replies; 14+ messages in thread
From: cinap_lenrek @ 2010-07-17 16:46 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 134 bytes --]
defn call(addr)
{
local opc;
opc = *PC;
bpset(*PC);
*SP = *SP - 4;
**SP = *PC;
*PC = addr;
cont();
bpdel(*PC);
}
[-- Attachment #2: Type: message/rfc822, Size: 3537 bytes --]
From: Philippe Anel <xigh@bouyapop.org>
To: 9fans@9fans.net
Subject: Re: [9fans] acid question
Date: Sat, 17 Jul 2010 17:56:22 +0200
Message-ID: <4C41D2A6.7080402@bouyapop.org>
This one sounds like to work (except it does not save registers) ...
defn call(addr)
{
local pco;
// we need stack space, and thus process stopped.
if status(pid) != "Stopped" then {
print("Waiting...\n");
stop(pid);
}
// Backup orginal instruction
pco = fmt(*PC, bpfmt);
// Put a temporary breakpoint
**PC = bpinst;
// update stack pointer
*SP = *SP - 4;
// make called function returning to this point
**SP = *PC;
// set PC to function to call
*PC = addr;
// do the call
startstop(pid);
// restore original instruction
*PC = pco;
}
Phil;
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] acid question
2010-07-17 15:56 ` Philippe Anel
2010-07-17 16:46 ` cinap_lenrek
@ 2010-07-17 16:48 ` cinap_lenrek
2010-07-17 17:23 ` Skip Tavakkolian
2 siblings, 0 replies; 14+ messages in thread
From: cinap_lenrek @ 2010-07-17 16:48 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 86 bytes --]
accedently hit Post... ignore the previous mail. nice trick by the way.
--
cinap
[-- Attachment #2: Type: message/rfc822, Size: 3537 bytes --]
From: Philippe Anel <xigh@bouyapop.org>
To: 9fans@9fans.net
Subject: Re: [9fans] acid question
Date: Sat, 17 Jul 2010 17:56:22 +0200
Message-ID: <4C41D2A6.7080402@bouyapop.org>
This one sounds like to work (except it does not save registers) ...
defn call(addr)
{
local pco;
// we need stack space, and thus process stopped.
if status(pid) != "Stopped" then {
print("Waiting...\n");
stop(pid);
}
// Backup orginal instruction
pco = fmt(*PC, bpfmt);
// Put a temporary breakpoint
**PC = bpinst;
// update stack pointer
*SP = *SP - 4;
// make called function returning to this point
**SP = *PC;
// set PC to function to call
*PC = addr;
// do the call
startstop(pid);
// restore original instruction
*PC = pco;
}
Phil;
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] acid question
2010-07-17 15:56 ` Philippe Anel
2010-07-17 16:46 ` cinap_lenrek
2010-07-17 16:48 ` cinap_lenrek
@ 2010-07-17 17:23 ` Skip Tavakkolian
2010-07-17 17:58 ` Philippe Anel
2 siblings, 1 reply; 14+ messages in thread
From: Skip Tavakkolian @ 2010-07-17 17:23 UTC (permalink / raw)
To: 9fans
nice. i'll give it a try later.
thinking outloud here; it seems that one could extend the capability
of ?c for generating acid code to include creating call wrapper
for any function that is marked for unit testing (perhaps another
#pragma?)
> This one sounds like to work (except it does not save registers) ...
>
> defn call(addr)
> {
> local pco;
>
> // we need stack space, and thus process stopped.
> if status(pid) != "Stopped" then {
> print("Waiting...\n");
> stop(pid);
> }
>
> // Backup orginal instruction
> pco = fmt(*PC, bpfmt);
>
> // Put a temporary breakpoint
> **PC = bpinst;
>
> // update stack pointer
> *SP = *SP - 4;
>
> // make called function returning to this point
> **SP = *PC;
>
> // set PC to function to call
> *PC = addr;
>
> // do the call
> startstop(pid);
>
> // restore original instruction
> *PC = pco;
> }
>
> Phil;
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] acid question
2010-07-17 17:23 ` Skip Tavakkolian
@ 2010-07-17 17:58 ` Philippe Anel
0 siblings, 0 replies; 14+ messages in thread
From: Philippe Anel @ 2010-07-17 17:58 UTC (permalink / raw)
To: 9fans
Not needed in my opinion. Acid can also helps.
If we decide that function marked for unit testing with a known regexp
such as ending by _Test ...
defn utest()
{
sl = symbols;
while sl do {
s = head sl;
if (regexp(".*_Test", s[0])) then {
call(s[2]);
}
sl = tail sl;
}
}
This would call every function whose name is ending with _Test.
Phil;
On 7/17/2010 7:23 PM, Skip Tavakkolian wrote:
> nice. i'll give it a try later.
>
> thinking outloud here; it seems that one could extend the capability
> of ?c for generating acid code to include creating call wrapper
> for any function that is marked for unit testing (perhaps another
> #pragma?)
>
>> This one sounds like to work (except it does not save registers) ...
>>
>> defn call(addr)
>> {
>> local pco;
>>
>> // we need stack space, and thus process stopped.
>> if status(pid) != "Stopped" then {
>> print("Waiting...\n");
>> stop(pid);
>> }
>>
>> // Backup orginal instruction
>> pco = fmt(*PC, bpfmt);
>>
>> // Put a temporary breakpoint
>> **PC = bpinst;
>>
>> // update stack pointer
>> *SP = *SP - 4;
>>
>> // make called function returning to this point
>> **SP = *PC;
>>
>> // set PC to function to call
>> *PC = addr;
>>
>> // do the call
>> startstop(pid);
>>
>> // restore original instruction
>> *PC = pco;
>> }
>>
>> Phil;
>
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* [9fans] acid question
@ 2005-01-08 3:36 Tim Newsham
2005-01-08 5:41 ` Rob Pike
2005-01-08 21:46 ` Tim Newsham
0 siblings, 2 replies; 14+ messages in thread
From: Tim Newsham @ 2005-01-08 3:36 UTC (permalink / raw)
To: 9fans
I have two variables, "a" and "b". One comes from a symbol name
(ie: a = main), and the other comes from data returned from strace().
Normal stuff:
print shows
-----------------------------
a 0x800529a4
b 0x800529a4
whatis a integer variable format X
whatis b integer variable format X
a - b 0x00000000
b - a 0x00000000
now weirdness:
a == b 0
a < b 0x00000001
b < a 0x00000000
a > b 0
b > a 1
Whats going on here? Signed vs. unsigned issues?
Tim N.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] acid question
2005-01-08 3:36 Tim Newsham
@ 2005-01-08 5:41 ` Rob Pike
2005-01-08 6:34 ` Tim Newsham
2005-01-08 21:46 ` Tim Newsham
1 sibling, 1 reply; 14+ messages in thread
From: Rob Pike @ 2005-01-08 5:41 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
Acid can be surprising.
acid; c=a>b
acid; whatis c
integer variable format D
acid; c=a<b
acid; whatis c
integer variable format X
This at least can be fixed by putting
res->store.fmt = 'D';
in a number of places in src/cmd/acid/expr.c analogous
to its placement in ogt().
-rob
On Fri, 7 Jan 2005 17:36:17 -1000 (HST), Tim Newsham <newsham@lava.net> wrote:
> I have two variables, "a" and "b". One comes from a symbol name
> (ie: a = main), and the other comes from data returned from strace().
> Normal stuff:
>
> print shows
> -----------------------------
> a 0x800529a4
> b 0x800529a4
> whatis a integer variable format X
> whatis b integer variable format X
> a - b 0x00000000
> b - a 0x00000000
>
> now weirdness:
> a == b 0
> a < b 0x00000001
> b < a 0x00000000
> a > b 0
> b > a 1
>
> Whats going on here? Signed vs. unsigned issues?
>
> Tim N.
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] acid question
2005-01-08 5:41 ` Rob Pike
@ 2005-01-08 6:34 ` Tim Newsham
0 siblings, 0 replies; 14+ messages in thread
From: Tim Newsham @ 2005-01-08 6:34 UTC (permalink / raw)
To: Rob Pike, Fans of the OS Plan 9 from Bell Labs
> This at least can be fixed by putting
> res->store.fmt = 'D';
Sure, but I'm really less concerned about the format associated
with the result of the comparison than I am about the fact that
although "a" and "b" show the same value, and "a-b" shows zero,
the "==" operator says they are not the same. (Worse yet, if
I compare "a-b" with zero, it also fails).
> -rob
> > a 0x800529a4
> > b 0x800529a4
> > a - b 0x00000000
> > b - a 0x00000000
> > a == b 0
> > a < b 0x00000001
> > b < a 0x00000000
> > a > b 0
> > b > a 1
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [9fans] acid question
2005-01-08 3:36 Tim Newsham
2005-01-08 5:41 ` Rob Pike
@ 2005-01-08 21:46 ` Tim Newsham
1 sibling, 0 replies; 14+ messages in thread
From: Tim Newsham @ 2005-01-08 21:46 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
> a 0x800529a4
> b 0x800529a4
> a == b 0
>
> Whats going on here? Signed vs. unsigned issues?
Indeed a signed issue -- acid integer values are stored
as vlongs. The value of a symbol such as "main" is being
converted to a vlong by zero-extension, while the symbol
value from strace() (Symbol.value) is a signed long which
is sign-extended. One fix is to change
/sys/src/cmd/acid/list.c from
l->ival = sym->value;
to
l->ival = (ulong)sym->value;
Or perhaps the Symbol value field in <mach.h> should be a ulong?
Tim N.
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2010-07-17 17:58 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-17 8:33 [9fans] acid question Skip Tavakkolian
2010-07-17 8:48 ` EBo
2010-07-17 9:19 ` Skip Tavakkolian
2010-07-17 12:15 ` EBo
2010-07-17 15:00 ` Philippe Anel
2010-07-17 15:56 ` Philippe Anel
2010-07-17 16:46 ` cinap_lenrek
2010-07-17 16:48 ` cinap_lenrek
2010-07-17 17:23 ` Skip Tavakkolian
2010-07-17 17:58 ` Philippe Anel
-- strict thread matches above, loose matches on Subject: below --
2005-01-08 3:36 Tim Newsham
2005-01-08 5:41 ` Rob Pike
2005-01-08 6:34 ` Tim Newsham
2005-01-08 21:46 ` Tim Newsham
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).