Created
August 1, 2014 15:58
-
-
Save pgoodman/71e9dfe2a99cd089906f to your computer and use it in GitHub Desktop.
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; | |
virtual void InstrumentControlFlow(BlockFactory *factory, | |
LocalControlFlowGraph *cfg) { | |
for (auto block : cfg->NewBlocks()) { | |
for (auto succ : block->Successors()) { | |
if (succ.cfi->IsSystemCall() || succ.cfi->IsInterruptCall()) { | |
break; // System calls don't always return to the next instruction. | |
} else if (!succ.cfi->IsFunctionCall()) { | |
factory->RequestBlock(succ.block); | |
} | |
} | |
} | |
} | |
}; | |
// Initialize the `whole_func` tool. | |
GRANARY_CLIENT_INIT({ | |
RegisterInstrumentationTool<WholeFunctionDecoder>("whole_func"); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment