Quantcast
Channel: Python extension for WinDbg
Viewing all articles
Browse latest Browse all 1625

New Post: Named breakpoint, global breakpoint list and stuff

$
0
0
Hey!

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:
        try:
            getBp(0).remove()
        except IndexError:
            # Done
            pass
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")

    breakpoints[name].remove()
    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"
        breakpoints[name].remove()

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

    breakpoints[name] = bp

Viewing all articles
Browse latest Browse all 1625

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>