* running multi-process in lockstep with python
@ 2010-09-19 11:39 Matt Rice
2010-09-21 21:50 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Matt Rice @ 2010-09-19 11:39 UTC (permalink / raw)
To: Project Archer
[-- Attachment #1: Type: text/plain, Size: 606 bytes --]
this could use a fair amount of polish its probably not going to get unless
you guys are interested in including it, then i would try and clean up
the magic numbers into set/show commands, e.g. using an itset
and other stuff.
anyhow i think it shows off 2 of the newer features of gdb
in my tests lockstep1 foo increments to 10 or so
and lockstep2 foo increments to 5 then back to 0.
execution continues until reaching 6, 4.
where it hands control back to the user with both inferiors stopped.
now if it only could debug i386 + x86_64 simultaneously i'd be set
probably a twisted version comming up :/
[-- Attachment #2: lockstep.gdb --]
[-- Type: application/octet-stream, Size: 218 bytes --]
set pagination off
source lockstep.py
add-inferior -exec lockstep1
inferior 2
break foo
commands
silent
set $x1 = i
end
run
add-inferior -exec lockstep2
inferior 3
break foo
commands
silent
set $x2 = i
end
run
[-- Attachment #3: lockstep.py --]
[-- Type: application/octet-stream, Size: 1031 bytes --]
run_on_match = "continue"
run_on_dont_match = ""
def doLockStep ():
global run_on_match
global run_on_dont_match
inferiors = dict()
for inf in gdb.inferiors():
if inf.num > 1:
inferiors[inf.num] = inf
print(inferiors)
thr1 = inferiors[2].threads()[0]
thr2 = inferiors[3].threads()[0]
while thr1.is_running() == True or thr2.is_running() == True:
continue
x1 = gdb.parse_and_eval("$x1")
x2 = gdb.parse_and_eval("$x2")
if x1 == x2:
gdb.execute("inferior 2")
gdb.execute(run_on_match)
gdb.execute("inferior 3")
gdb.execute(run_on_match)
return 1
else:
gdb.execute("inferior 2")
gdb.execute(run_on_dont_match)
gdb.execute("inferior 3")
gdb.execute(run_on_dont_match)
return 0
class Lockstep (gdb.Command):
"""runs gdb continue in 2 inferiors until $x1 != $x2."""
def __init__ (self):
super (Lockstep, self).__init__ ("lockstep", gdb.COMMAND_OBSCURE)
def invoke (self, arg, from_tty):
while doLockStep() == 1:
continue
return 0
Lockstep ()
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: running multi-process in lockstep with python
2010-09-19 11:39 running multi-process in lockstep with python Matt Rice
@ 2010-09-21 21:50 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2010-09-21 21:50 UTC (permalink / raw)
To: Matt Rice; +Cc: Project Archer
>>>>> "Matt" == Matt Rice <ratmice@gmail.com> writes:
Matt> this could use a fair amount of polish its probably not going to
Matt> get unless you guys are interested in including it, then i would
Matt> try and clean up the magic numbers into set/show commands,
Matt> e.g. using an itset and other stuff.
This is very cool.
I think it would be great to ship easy way to let users do this kind of
thing.
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-09-21 21:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-19 11:39 running multi-process in lockstep with python Matt Rice
2010-09-21 21:50 ` Tom Tromey
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 read-only IMAP folder(s) and NNTP newsgroup(s).