Named breakpoint, global breakpoint list and stuff

Oct 29, 2015 at 3:37 PM
Edited Oct 29, 2015 at 3:51 PM

I really love your extension, awesome thing.
I'm using it in my automation, and I think it could be better and more natural.

One of the things I notice (and maybe because of lack of knowledge), that there's
no option for create named breakpoints, or maybe set new breakpoints with my own unique.

another thing I notice that there's no breakpoints list. In order to get breakpoints details
you need either to have strong reference to that object, or use getBp (which is not mentioned in 0.3 wiki page btw) and hope for the best.

I needed to ensure that there's no breakpoints (some automatic unit tests), So I used this code
to clean up the breakpoints:
def clear_breakpoints():
    remove all global break points
    :return: None
    while True:
        except IndexError:
            # Done
which is not pretty...

for now, I wrote little wrapper (really basic one)
breakpoints = {}

def get_named_breakpoint_by_id(breakpointId):
    for key, value in breakpoints.items():
        if value.getId() == breakpointId:
            return key, value
    raise IndexError

def print_breakpoints_details():
    for name, bp in breakpoints.items():
        print "'{0}' (#{1})- {2}".format(name, bp.getId(), hex(bp.getOffset()))

def remove_breakpoint(name):
    if not type(name) is str:
        raise RuntimeError("breakpoint name must be a string")

    del breakpoints[name]

def create_named_breakpoint(name, offset, callback=None):
    if not type(name) is str:
        raise RuntimeError("breakpoint name must be a string")

    if name in breakpoints:
        print "Removing old breakpoint"

    if callback:
        bp = setBp(offset, callback)
        bp = setBp(offset)

    breakpoints[name] = bp
Oct 30, 2015 at 8:55 AM
And we really love your bug reports, very useful indeed!

About "named" breakpoints.
I think it is not necessary to make it in the pykd inside. We suppose things could be made in python must be made in python. So, your decision quite right: to have a global dict with breakpoints. Please, note after last release ( we change the behavior of the breakpoints references ( see: ). Now there are two types of breakpoints reference: strong ( breakpoints will be removed after reference is rundown ) and week ( breakpoints remain to be set ). So, you MUST now to have a global references to all breakpoints and it is a good idea to place them in a dict or list.

Clearing breakpoints now seems to be easier:
breakpoints = []
breakpoints.append(bp1) #add a 'strong' breakpoint reference to list
breakpoints.append(bp2)#add another 'strong' breakpoint reference to list
breakpoints = [] # clear all breakpoints. You should be sure there are no another references to breakpoints
I'd like to say FYI about another way to work with breakpoints. You can inherit your own breakpoint class from base class 'brekpoint':
class MyBreakpoint(pykd.breakpoint):
    def __init__(self,offset):
        super(MyBreakpoint, self).__init__(offset)

    def onHit(self):
        return True # return False, None, 0, eventResult.Proceed  to proceed execution