This file contains 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
# Print $arg1 instructions starting at address $arg0. | |
define pi | |
set $__rip = $arg0 | |
set $__ni = $arg1 | |
python None ; \ | |
rip = str(gdb.parse_and_eval("$__rip")).lower() ; \ | |
ni = str(gdb.parse_and_eval("$__ni")).lower() ; \ | |
gdb.execute( \ | |
"x/%si %s\n" % (ni, rip), \ | |
from_tty=True, to_string=False) ; |
This file contains 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
/* Copyright 2014 Peter Goodman, all rights reserved. */ | |
#include <granary/granary.h> | |
using namespace granary; | |
// TODO(pag): Generic allocators (similar to with meta-data) but for allowing | |
// multiple tools to register descriptor info. | |
// TODO(pag): Eventually handle user space syscalls to avoid EFAULTs. | |
// TODO(pag): Eventually handle user space signals. |
This file contains 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
/* Copyright 2014 Peter Goodman, all rights reserved. */ | |
#include <granary/granary.h> | |
using namespace granary; | |
// Simple tool decoding all blocks in a function. | |
class WholeFunctionDecoder : public InstrumentationTool { | |
public: | |
virtual ~WholeFunctionDecoder(void) = default; |
This file contains 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) print-arch-instr &($12->instruction) | |
MOV_MEMv_GPRv [SLOT:0], R15 | |
(gdb) |
This file contains 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
// This source code comes from: | |
// http://stackoverflow.com/questions/8941711/is-is-possible-to-set-a-gdb-watchpoint-programatically | |
// with additional tricks from: | |
// https://code.google.com/p/google-breakpad/source/browse/trunk/src/client/linux/handler/exception_handler.cc?r=1361 | |
#include <errno.h> | |
#include <signal.h> | |
#include <stddef.h> | |
#include <stdio.h> | |
#include <stdlib.h> |
This file contains 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
;;;; Recursive Descent Parser Generator | |
;;;; Copyright 2008 Peter Goodman, all rights reserved | |
(defun concatenate* (type &rest lst) | |
"Concatenate all cars within a tree." | |
(setf lst (remove nil lst)) | |
(if (null lst) | |
"" ; nothing to concatenate, return | |
(let ((a (car lst)) (d (cdr lst))) |
This file contains 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
(defun-parser :html-attr | |
(no-capture (repeat 0 nil " ")) | |
(and (concat (repeat 0 nil (range #\a #\z)) | |
(and ":" (repeat 0 nil (concat (range #\a #\z))))) | |
(no-capture #\= #\") | |
(find-next #\") | |
(no-capture #\"))) | |
(defun-parser :html-attrs | |
(repeat 0 nil :html-attr)) |
This file contains 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
(print (parse ':html "prefix text<div class=\"post\"><a name=\"comment-{$comment.comment_ID}\" id=\"comment-{$comment.comment_ID}\"></a>{$comment.content}<ul class=\"categories\">by <cond:if var=\"comment.comment_author_url\" neq=\"\"><a href=\"{$comment.comment_author_url}\" title=\"{$comment.comment_author}\">{$comment.comment_author}</a><cond:else />{$comment.comment_author}</cond:if> on {$comment.date} </ul></div>postfix text")) | |
;; what's generated: | |
("prefix text" (:HTML-TAG "" (:HTML-TAG-NAME "div") (:HTML-ATTRS (:HTML-ATTR "class" "post")) "") "" (:HTML-TAG "" (:HTML-TAG-NAME "a") (:HTML-ATTRS (:HTML-ATTR "name" "comment-{$comment.comment_ID}") (:HTML-ATTR "id" "comment-{$comment.comment_ID}")) "") "" (:HTML-TAG "/" (:HTML-TAG-NAME "a") (:HTML-ATTRS) "") "{$comment.content}" (:HTML-TAG "" (:HTML-TAG-NAME "ul") (:HTML-ATTRS (:HTML-ATTR "class" "categories")) "") "by " (:HTML-TAG "" (:HTML-TAG-NAME "cond:if") (:HTML-ATTRS (:HTML-ATTR "var" "comment.comment_author_url") (:HTML-ATTR "neq" "")) "") "" |
This file contains 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
(defun-parser :html-attr | |
(no-capture (repeat 0 nil " ")) | |
(and (concat (repeat 0 nil (range #\a #\z)) | |
(and ":" (repeat 0 nil (concat (range #\a #\z))))) | |
(no-capture #\= #\") | |
(find-next #\") | |
(no-capture #\"))) | |
(defun-parser :html-attrs | |
(repeat 0 nil :html-attr)) |
This file contains 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
("prefix text" | |
(:HTML-TAG | |
"" | |
(:HTML-TAG-NAME "div") | |
(:HTML-ATTRS | |
(:HTML-ATTR "class" "post")) | |
"") | |
"" | |
(:HTML-TAG | |
"" |
OlderNewer