Last active
September 13, 2018 07:47
-
-
Save ivand58/4c9d0e63eaec4f8c17b941c62dab4bcd to your computer and use it in GitHub Desktop.
autoloaded by GDB py file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| GDB_C_INT = gdb.lookup_type("int") | |
| class Bpout (gdb.Breakpoint): | |
| def stop (self): | |
| pout = gdb.parse_and_eval ("port_out") | |
| mychar = chr(int(pout.cast(GDB_C_INT))) | |
| if mychar != '\0': | |
| sys.stdout.write(mychar) | |
| return False #Continue | |
| bpout = Bpout ("port_out", gdb.BP_WATCHPOINT, wp_class=gdb.WP_WRITE) | |
| class Bpend (gdb.Breakpoint): | |
| def stop (self): | |
| pout = gdb.parse_and_eval ("port_end") | |
| myint = int(pout.cast(GDB_C_INT)) | |
| gdb.execute ("kill inferiors " + str(gdb.selected_inferior ().num)) | |
| gdb.execute ("quit " + str(myint)) | |
| return False #Continue | |
| bpend = Bpend ("port_end", gdb.BP_WATCHPOINT, wp_class=gdb.WP_WRITE) | |
| #TODO: If MlxISS stops BEFORE read, this feature will work! | |
| class Bpin (gdb.Breakpoint): | |
| def stop (self): | |
| pout = gdb.parse_and_eval ("port_in") | |
| mychar = sys.stdin.read (1) | |
| gdb.execute ("set port_in = " + str(ord(mychar[0]))) | |
| return False #Continue | |
| bpin = Bpin ("port_in", gdb.BP_WATCHPOINT, wp_class=gdb.WP_READ) | |
| #~ class Bpmain (gdb.Breakpoint): | |
| #~ def stop (self): | |
| #~ return False | |
| #~ bpmain = Bpmain ("main") | |
| #gdb.execute("break main") # Needed to trigger the watchpoints for PC | |
| gdb.execute("run") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment