ROSE 0.11.145.147
AsmUnparser.h
1#ifndef ROSE_AsmUnparser_H
2#define ROSE_AsmUnparser_H
3
4#include <featureTests.h>
5#ifdef ROSE_ENABLE_BINARY_ANALYSIS
6
7#include <ostream>
8
9#include "callbacks.h" // Needed for Rose::Callbacks::List<>
10#include <Rose/BinaryAnalysis/BasicTypes.h>
11#include <Rose/BinaryAnalysis/ControlFlow.h>
12#include <Rose/BinaryAnalysis/Disassembler/BasicTypes.h>
13#include <Rose/BinaryAnalysis/FunctionCall.h>
14#include <Rose/BinaryAnalysis/Hexdump.h>
15#include <Rose/BinaryAnalysis/InstructionSemantics/BaseSemantics.h>
16
18class SgAsmBlock;
19class SgAsmFunction;
21
22namespace Rose {
23namespace BinaryAnalysis {
24
25namespace Disassembler {
26class Base;
27} // namespace
28
257class ROSE_DLL_API AsmUnparser {
258public:
260 ORGANIZED_BY_AST,
265 ORGANIZED_BY_ADDRESS
269 };
270
274 typedef boost::graph_traits<CFG>::vertex_descriptor CFG_Vertex;
275 typedef std::map<SgAsmBlock*, CFG_Vertex> CFG_BlockMap;
277 typedef boost::graph_traits<CG>::vertex_descriptor CG_Vertex;
278 typedef std::map<SgAsmFunction*, CG_Vertex> CG_FunctionMap;
279
281 public:
283 struct GeneralArgs {
284 GeneralArgs(AsmUnparser *unparser, std::ostream &output)
285 : unparser(unparser), output(output) {}
287 std::ostream &output;
288 };
289
291 struct InsnArgs: public GeneralArgs {
292 InsnArgs(AsmUnparser *unparser, std::ostream &output, SgAsmInstruction *insn, size_t position_in_block)
293 : GeneralArgs(unparser, output), insn(insn), position_in_block(position_in_block) {}
294 SgAsmInstruction *get_node() const { return insn; }
297 };
298
301 BasicBlockArgs(AsmUnparser *unparser, std::ostream &output, SgAsmBlock *block,
302 const std::vector<SgAsmInstruction*> &insns)
303 : GeneralArgs(unparser, output), block(block), insns(insns) {}
304 SgAsmBlock *get_node() const { return block; }
306 const std::vector<SgAsmInstruction*> &insns;
307 };
308
311 StaticDataArgs(AsmUnparser *unparser, std::ostream &output, SgAsmStaticData *data, size_t position_in_block)
312 : GeneralArgs(unparser, output), data(data), position_in_block(position_in_block) {}
313 SgAsmStaticData *get_node() const { return data; }
316 };
317
319 struct DataBlockArgs: public GeneralArgs {
320 DataBlockArgs(AsmUnparser *unparser, std::ostream &output, SgAsmBlock *block,
321 const std::vector<SgAsmStaticData*> &datalist)
322 : GeneralArgs(unparser, output), block(block), datalist(datalist) {}
323 SgAsmBlock *get_node() const { return block; }
325 const std::vector<SgAsmStaticData*> &datalist;
326 };
327
329 struct FunctionArgs: public GeneralArgs {
330 FunctionArgs(AsmUnparser *unparser, std::ostream &output, SgAsmFunction *func)
331 : GeneralArgs(unparser, output), func(func) {}
332 SgAsmFunction *get_node() const { return func; }
334 };
335
338 InterpretationArgs(AsmUnparser *unparser, std::ostream &output, SgAsmInterpretation *interp)
339 : GeneralArgs(unparser, output), interp(interp) {}
340 SgAsmInterpretation *get_node() const { return interp; }
342 };
343
344 virtual ~UnparserCallback() {}
345
356 virtual bool operator()(bool /*enabled*/, const InsnArgs&) { abort(); return false; }
357 virtual bool operator()(bool /*enabled*/, const BasicBlockArgs&) { abort(); return false; }
358 virtual bool operator()(bool /*enabled*/, const StaticDataArgs&) { abort(); return false; }
359 virtual bool operator()(bool /*enabled*/, const DataBlockArgs&) { abort(); return false; }
360 virtual bool operator()(bool /*enabled*/, const FunctionArgs&) { abort(); return false; }
361 virtual bool operator()(bool /*enabled*/, const InterpretationArgs&) { abort(); return false; }
363 };
364
365 /**************************************************************************************************************************
366 * Instruction Callbacks
367 **************************************************************************************************************************/
368
374 public:
375 virtual bool operator()(bool enabled, const InsnArgs &args);
376 };
377
381 public:
382 SgAsmBlock *prev_block;
383 InsnBlockSeparation(): prev_block(NULL) {}
384 virtual bool operator()(bool enabled, const InsnArgs &args);
385 };
386
390 public:
391 virtual bool operator()(bool enabled, const InsnArgs &args);
392 };
393
396 public:
397 virtual bool operator()(bool enabled, const InsnArgs &args);
398 };
399
404 public:
406 InsnRawBytes() {
407 fmt.width = 8; /* Max instruction bytes per line of output. */
408 fmt.pad_chars = true; /* Show ASCII characters as well as bytes. */
409 }
410 virtual bool operator()(bool enabled, const InsnArgs &args);
411 };
412
418 public:
421 InsnBlockEntry(): show_function(true), show_reasons(true) {}
422 virtual bool operator()(bool enabled, const InsnArgs &args);
423 };
424
427 public:
428 virtual bool operator()(bool enabled, const InsnArgs &args);
429 };
430
433 public:
434 virtual bool operator()(bool enabled, const InsnArgs &args);
435 };
436
440 public:
441 virtual bool operator()(bool enabled, const InsnArgs &args);
442 };
443
446 public:
447 virtual bool operator()(bool enabled, const InsnArgs &args);
448 };
449
452 public:
453 virtual bool operator()(bool enabled, const InsnArgs &args);
454 };
455
460 public:
461 virtual bool operator()(bool enabled, const InsnArgs &args);
462 };
463
464 /**************************************************************************************************************************
465 * Basic Block Callbacks
466 **************************************************************************************************************************/
467
470 public:
471 virtual bool operator()(bool enabled, const BasicBlockArgs &args);
472 };
473
477 public:
478 virtual bool operator()(bool enabled, const BasicBlockArgs &args);
479 };
480
483 public:
484 bool debug;
485 BasicBlockNoopUpdater(): debug(false) {}
486 virtual bool operator()(bool enabled, const BasicBlockArgs &args);
487 };
488
491 public:
492 virtual bool operator()(bool enabled, const BasicBlockArgs &args);
493 };
494
498 public:
499 virtual bool operator()(bool enabled, const BasicBlockArgs &args);
500 };
501
504 public:
505 virtual bool operator()(bool enabled, const BasicBlockArgs &args);
506 };
507
513 public:
514 virtual bool operator()(bool enabled, const BasicBlockArgs &args);
515 };
516
519 public:
520 virtual bool operator()(bool enabled, const BasicBlockArgs &args);
521 };
522
526 public:
527 virtual bool operator()(bool enabled/*ignored*/, const BasicBlockArgs &args);
528 };
529
530 /**************************************************************************************************************************
531 * Static Data Callbacks
532 **************************************************************************************************************************/
533
539 public:
540 virtual bool operator()(bool enabled, const StaticDataArgs &args);
541 };
542
546 public:
547 SgAsmBlock *prev_block;
548 StaticDataBlockSeparation(): prev_block(NULL) {}
549 virtual bool operator()(bool enabled, const StaticDataArgs &args);
550 };
551
554 public:
555 bool show_address; /* Should we show the address in the left margin? */
556 bool show_offset; /* If show_address is true, then should we display START+OFFSET or just an address? */
557
560 show_address = true;
561 show_offset = false;
562 fmt.prefix = ""; /* Adjusted by the callback each time called. */
563 fmt.multiline = false; /* Do not emit prefix before first line and linefeed after last line. */
564 fmt.width = 8; /* Max data bytes per line of output. */
565 fmt.pad_chars = true; /* Show ASCII characters as well as bytes. */
566 }
567 virtual bool operator()(bool enabled, const StaticDataArgs &args);
568 };
569
575 public:
578 StaticDataBlockEntry(): show_function(true), show_reasons(true) {}
579 virtual bool operator()(bool enabled, const StaticDataArgs &args);
580 };
581
584 public:
585 virtual bool operator()(bool enabled, const StaticDataArgs &args);
586 };
587
590 public:
591 virtual bool operator()(bool enabled, const StaticDataArgs &args);
592 };
593
596 public:
597 virtual bool operator()(bool enabled, const StaticDataArgs &args);
598 };
599
605 public:
607 public:
608 virtual bool operator()(bool enabled, const InsnArgs &args) {
609 if (enabled)
610 args.output <<" (data)";
611 return enabled;
612 }
613 };
614
615 DataNote data_note;
616 Disassembler::BasePtr disassembler;
617 AsmUnparser *unparser = nullptr;
618 bool unparser_allocated_here = false;
621 virtual void reset();
622 virtual void init(const Disassembler::BasePtr &disassembler, AsmUnparser *unparser=NULL);
623 virtual bool operator()(bool enabled, const StaticDataArgs &args);
624 };
625
630 public:
631 virtual bool operator()(bool enabled, const StaticDataArgs &args);
632 };
633
634 /**************************************************************************************************************************
635 * Data Block Callbacks
636 **************************************************************************************************************************/
637
640 public:
641 virtual bool operator()(bool enabled, const StaticDataArgs &args);
642 };
643
646 public:
647 virtual bool operator()(bool enabled, const DataBlockArgs &args);
648 };
649
652 public:
653 virtual bool operator()(bool enabled, const DataBlockArgs &args);
654 };
655
656 /**************************************************************************************************************************
657 * Function Callbacks
658 **************************************************************************************************************************/
659
662 public:
663 virtual bool operator()(bool enabled, const FunctionArgs &args);
664 };
665
668 public:
669 virtual bool operator()(bool enabled, const FunctionArgs &args);
670 };
671
674 public:
675 virtual bool operator()(bool enabled, const FunctionArgs &args);
676 };
677
680 public:
681 virtual bool operator()(bool enabled, const FunctionArgs &args);
682 };
683
686 public:
687 virtual bool operator()(bool enabled, const FunctionArgs &args);
688 };
689
692 public:
693 virtual bool operator()(bool enabled, const FunctionArgs &args);
694 };
695
699 public:
700 virtual bool operator()(bool enabled, const FunctionArgs &args);
701 };
702
706 public:
707 virtual bool operator()(bool enabled, const FunctionArgs &args);
708 };
709
714 public:
715 virtual bool operator()(bool enabled, const FunctionArgs &args);
716 };
717
720 public:
721 virtual bool operator()(bool enabled, const FunctionArgs &args);
722 };
723
724 /**************************************************************************************************************************
725 * Interpretation Callbacks
726 **************************************************************************************************************************/
727
730 public:
731 virtual bool operator()(bool enabled, const InterpretationArgs &args);
732 };
733
736 public:
737 virtual bool operator()(bool enabled, const InterpretationArgs &args);
738 };
739
740 /**************************************************************************************************************************
741 * Built-in Callbacks
742 * Don't forget to modify init() to actually add these to callback lists if desired.
743 **************************************************************************************************************************/
744
753 InsnSkipBackBegin insnSkipBackBegin;
754 InsnBlockSeparation insnBlockSeparation;
755 InsnFuncEntry insnFuncEntry;
756 InsnAddress insnAddress;
757 InsnRawBytes insnRawBytes;
758 InsnBlockEntry insnBlockEntry;
759 InsnStackDelta insnStackDelta;
760 InsnBody insnBody;
761 InsnNoEffect insnNoEffect;
762 InsnComment insnComment;
763 InsnLineTermination insnLineTermination;
764 InsnSkipBackEnd insnSkipBackEnd;
765
766 BasicBlockReasons basicBlockReasons;
767 BasicBlockPredecessors basicBlockPredecessors;
768 BasicBlockNoopUpdater basicBlockNoopUpdater;
769 BasicBlockNoopWarning basicBlockNoopWarning;
770 BasicBlockBody basicBlockBody;
771 BasicBlockOutgoingStackDelta basicBlockOutgoingStackDelta;
772 BasicBlockSuccessors basicBlockSuccessors;
773 BasicBlockLineTermination basicBlockLineTermination;
774 BasicBlockCleanup basicBlockCleanup;
775
776 StaticDataSkipBackBegin staticDataSkipBackBegin;
777 StaticDataBlockSeparation staticDataBlockSeparation;
778 StaticDataRawBytes staticDataRawBytes;
779 StaticDataBlockEntry staticDataBlockEntry;
780 StaticDataDetails staticDataDetails;
781 StaticDataComment staticDataComment;
782 StaticDataLineTermination staticDataLineTermination;
783 StaticDataDisassembler staticDataDisassembler;
784 StaticDataSkipBackEnd staticDataSkipBackEnd;
785
786 DataBlockBody dataBlockBody;
787 DataBlockLineTermination dataBlockLineTermination;
788
789 FunctionEntryAddress functionEntryAddress;
790 FunctionSeparator functionSeparator;
791 FunctionReasons functionReasons;
792 FunctionName functionName;
793 FunctionLineTermination functionLineTermination;
794 FunctionComment functionComment;
795 FunctionPredecessors functionPredecessors;
796 FunctionSuccessors functionSuccessors;
797 FunctionAttributes functionAttributes;
798 FunctionBody functionBody;
799
800 InterpName interpName;
801 InterpBody interpBody;
804 /**************************************************************************************************************************
805 * Public methods
806 **************************************************************************************************************************/
807
810 virtual ~AsmUnparser();
811
817 virtual Organization get_organization() const { return organization; }
818 virtual void set_organization(Organization organization) { this->organization = organization; }
826 virtual bool is_unparsable_node(SgNode *node);
827
834
839 virtual std::vector<SgNode*> find_unparsable_nodes(SgNode *ast);
840
852 virtual void set_registers(const RegisterDictionaryPtr &registers);
863 std::vector<bool> insn_is_noop;
864
875 virtual size_t unparse(std::ostream&, SgNode *ast);
876
880 std::string to_string(SgNode *ast);
881
888 virtual bool unparse_one_node(std::ostream&, SgNode*);
889
893 virtual bool unparse_insn(bool enabled, std::ostream&, SgAsmInstruction*, size_t position_in_block=(size_t)-1);
894 virtual bool unparse_basicblock(bool enabled, std::ostream&, SgAsmBlock*);
895 virtual bool unparse_staticdata(bool enabled, std::ostream&, SgAsmStaticData*, size_t position_in_block=(size_t)-1);
896 virtual bool unparse_datablock(bool enabled, std::ostream&, SgAsmBlock*);
897 virtual bool unparse_function(bool enabled, std::ostream&, SgAsmFunction*);
898 virtual bool unparse_interpretation(bool enabled, std::ostream&, SgAsmInterpretation*);
902 typedef std::map<uint64_t, std::string> LabelMap;
903
909
914
921 void set_skipback_reporting(bool b=true) { skipback.active=b; skipback.triggered=false; }
922 void clear_skipback_reporting() { set_skipback_reporting(false); }
923 bool get_skipback_reporting() const { return skipback.active; }
924 void reset_skipback() { skipback.triggered=false; skipback.va=0; }
925 void start_of_object(rose_addr_t, std::ostream&);
926 void end_of_object(rose_addr_t);
943 virtual void set_prefix_format(const std::string &format) { lineprefix.format = format; }
944 virtual const std::string& get_prefix_format() const { return lineprefix.format; }
945 virtual void set_prefix_address(rose_addr_t va) { lineprefix.address = va; }
946 virtual rose_addr_t get_prefix_address() const { return lineprefix.address; }
947 virtual std::string line_prefix() const;
948 virtual std::string blank_prefix() const { return std::string(line_prefix().size(), ' '); }
951public:
952 static void initDiagnostics();
955protected:
968
996
999
1001 RegisterDictionaryPtr user_registers; // registers set by set_registers()
1002 RegisterDictionaryPtr interp_registers; // registers obtained from the SgAsmInterpretation
1003
1005 virtual void init();
1006
1009
1012 CFG_BlockMap cfg_blockmap;
1013
1015 CG cg;
1016
1019 CG_FunctionMap cg_functionmap;
1020
1022 struct SkipBack {
1023 SkipBack(): active(true), triggered(false), va(0) {}
1024 bool active;
1026 rose_addr_t va;
1027 } skipback;
1028
1030 struct LinePrefix {
1031 LinePrefix(): format("0x%08" PRIx64 ": "), address(0) {}
1032 std::string format;
1033 rose_addr_t address;
1034 } lineprefix;
1035};
1036
1037} // namespace
1038} // namespace
1039
1040#endif
1041#endif
Functor to emit the instructions that belong to a basic block.
virtual bool operator()(bool enabled, const BasicBlockArgs &args)
Default callbacks.
Functor to clean up after basic block.
virtual bool operator()(bool enabled, const BasicBlockArgs &args)
Default callbacks.
Functor to emit a blank line after every basic block.
virtual bool operator()(bool enabled, const BasicBlockArgs &args)
Default callbacks.
Functor to update unparser's is_noop array.
virtual bool operator()(bool enabled, const BasicBlockArgs &args)
Default callbacks.
bool debug
If set, then emit information about the no-op subsequences.
Functor to emit a warning if the block contains any no-effect sequences.
virtual bool operator()(bool enabled, const BasicBlockArgs &args)
Default callbacks.
Functor to emit basic block outgoing stack delta.
virtual bool operator()(bool enabled, const BasicBlockArgs &args)
Default callbacks.
Functor to emit control flow predecessor addresses.
virtual bool operator()(bool enabled, const BasicBlockArgs &args)
Default callbacks.
Functor to emit reasons this block is part of a function.
virtual bool operator()(bool enabled, const BasicBlockArgs &args)
Default callbacks.
Functor to emit block successor list.
virtual bool operator()(bool enabled, const BasicBlockArgs &args)
Default callbacks.
Functor to emit each data statement of the block.
virtual bool operator()(bool enabled, const DataBlockArgs &args)
Default callbacks.
Functor to emit a blank line after every data block.
virtual bool operator()(bool enabled, const DataBlockArgs &args)
Default callbacks.
Functor to print some information at the beginning of a data block.
virtual bool operator()(bool enabled, const StaticDataArgs &args)
Default callbacks.
Functor to emit function attributes.
virtual bool operator()(bool enabled, const FunctionArgs &args)
Default callbacks.
Functor to unparse the function body.
virtual bool operator()(bool enabled, const FunctionArgs &args)
Default callbacks.
Functor to print function comments followed by a linefeed if necessary.
virtual bool operator()(bool enabled, const FunctionArgs &args)
Default callbacks.
Functor to emit function entry address.
virtual bool operator()(bool enabled, const FunctionArgs &args)
Default callbacks.
Functor to emit function line termination.
virtual bool operator()(bool enabled, const FunctionArgs &args)
Default callbacks.
virtual bool operator()(bool enabled, const FunctionArgs &args)
Default callbacks.
virtual bool operator()(bool enabled, const FunctionArgs &args)
Default callbacks.
virtual bool operator()(bool enabled, const FunctionArgs &args)
Default callbacks.
Functor to emit function separator.
virtual bool operator()(bool enabled, const FunctionArgs &args)
Default callbacks.
virtual bool operator()(bool enabled, const FunctionArgs &args)
Default callbacks.
Functor to emit instruction address.
virtual bool operator()(bool enabled, const InsnArgs &args)
Default callbacks.
Functor to emit info about the first instruction of a block.
virtual bool operator()(bool enabled, const InsnArgs &args)
Default callbacks.
bool show_function
If true (the default) show entry address of function owning block.
bool show_reasons
If true (the default) show block reason bits.
Functor to emit basic block separation in output organized by address.
virtual bool operator()(bool enabled, const InsnArgs &args)
Default callbacks.
Functor to emit the entire instruction.
virtual bool operator()(bool enabled, const InsnArgs &args)
Default callbacks.
Functor to emit instruction comment, if any.
virtual bool operator()(bool enabled, const InsnArgs &args)
Default callbacks.
Functor to emit function information at entry points.
virtual bool operator()(bool enabled, const InsnArgs &args)
Default callbacks.
Functor to emit instruction line termination.
virtual bool operator()(bool enabled, const InsnArgs &args)
Default callbacks.
Functor to emit a note about instructions that have no effect.
virtual bool operator()(bool enabled, const InsnArgs &args)
Default callbacks.
Functor to emit instruction bytes.
virtual bool operator()(bool enabled, const InsnArgs &args)
Default callbacks.
Functor to print skip/back information when an instruction is entered.
virtual bool operator()(bool enabled, const InsnArgs &args)
Default callbacks.
Update instruction end address for skip/back reporting.
virtual bool operator()(bool enabled, const InsnArgs &args)
Default callbacks.
Functor to emit the numeric stack delta at each instruction.
virtual bool operator()(bool enabled, const InsnArgs &args)
Default callbacks.
Functor to emit the functions in an interpretation.
virtual bool operator()(bool enabled, const InterpretationArgs &args)
Default callbacks.
Functor to emit interpretation name.
virtual bool operator()(bool enabled, const InterpretationArgs &args)
Default callbacks.
Functor to emit info about the first data node of a block.
bool show_reasons
If true (the default) show block reason bits.
bool show_function
If true (the default) show entry address of function owning block.
virtual bool operator()(bool enabled, const StaticDataArgs &args)
Default callbacks.
Functor to emit data block separation in output organized by address.
virtual bool operator()(bool enabled, const StaticDataArgs &args)
Default callbacks.
Functor to emit optional static data comment.
virtual bool operator()(bool enabled, const StaticDataArgs &args)
Default callbacks.
Functor to emit details about static data.
virtual bool operator()(bool enabled, const StaticDataArgs &args)
Default callbacks.
virtual bool operator()(bool enabled, const InsnArgs &args)
Default callbacks.
Disassembles static data as if it were code.
virtual bool operator()(bool enabled, const StaticDataArgs &args)
Default callbacks.
Functor to emit a blank line after every data block.
virtual bool operator()(bool enabled, const StaticDataArgs &args)
Default callbacks.
Functor to emit the bytes of the data block.
virtual bool operator()(bool enabled, const StaticDataArgs &args)
Default callbacks.
Functor to print skip/back information when a static data block is entered.
virtual bool operator()(bool enabled, const StaticDataArgs &args)
Default callbacks.
Update static data end address for skip/back reporting.
virtual bool operator()(bool enabled, const StaticDataArgs &args)
Default callbacks.
virtual bool operator()(bool, const BasicBlockArgs &)
Default callbacks.
virtual bool operator()(bool, const InsnArgs &)
Default callbacks.
virtual bool operator()(bool, const InterpretationArgs &)
Default callbacks.
virtual bool operator()(bool, const StaticDataArgs &)
Default callbacks.
virtual bool operator()(bool, const DataBlockArgs &)
Default callbacks.
virtual bool operator()(bool, const FunctionArgs &)
Default callbacks.
Unparses binary AST into text.
virtual rose_addr_t get_prefix_address() const
Controls printing of line prefixes.
CallbackLists insn_callbacks
Callbacks for instruction unparsing.
CallbackLists function_callbacks
Callbacks for function unparsing.
virtual void set_organization(Organization organization)
Get/set how output is organized.
virtual bool unparse_interpretation(bool enabled, std::ostream &, SgAsmInterpretation *)
Unparse an object.
virtual SgNode * find_unparsable_node(SgNode *ast)
Finds first unparsable node.
Organization organization
How output will be organized.
void reset_skipback()
Controls printing of skip/back messages during linear output.
virtual void set_prefix_format(const std::string &format)
Controls printing of line prefixes.
AsmUnparser()
Constructor that intializes the "unparser" callback lists with some useful functors.
void clear_skipback_reporting()
Controls printing of skip/back messages during linear output.
CG_FunctionMap cg_functionmap
A mapping from SgAsmFunction to call graph vertex.
Rose::BinaryAnalysis::ControlFlow::Graph CFG
Control Flow Graph type.
virtual bool unparse_insn(bool enabled, std::ostream &, SgAsmInstruction *, size_t position_in_block=(size_t) -1)
Unparse an object.
void end_of_object(rose_addr_t)
Controls printing of skip/back messages during linear output.
LabelMap labels
This map is consulted whenever a constant is encountered.
void add_control_flow_graph(const Rose::BinaryAnalysis::ControlFlow::Graph &cfg)
Associates a control flow graph with this unparser.
void add_function_labels(SgNode *ast)
Adds function labels to the label map.
virtual bool unparse_datablock(bool enabled, std::ostream &, SgAsmBlock *)
Unparse an object.
virtual std::vector< SgNode * > find_unparsable_nodes(SgNode *ast)
Finds top unparsable nodes.
virtual bool unparse_one_node(std::ostream &, SgNode *)
Unparse a single node if possible.
std::vector< bool > insn_is_noop
Optional information about no-op sequences.
virtual size_t unparse(std::ostream &, SgNode *ast)
Unparse part of the AST.
std::string to_string(SgNode *ast)
Unparse part of the AST into a string.
virtual void set_registers(const RegisterDictionaryPtr &registers)
Register dictionaries.
void set_skipback_reporting(bool b=true)
Controls printing of skip/back messages during linear output.
virtual Organization get_organization() const
Get/set how output is organized.
virtual bool unparse_function(bool enabled, std::ostream &, SgAsmFunction *)
Unparse an object.
void start_of_object(rose_addr_t, std::ostream &)
Controls printing of skip/back messages during linear output.
CallbackLists datablock_callbacks
Callbacks for data block unparsing.
static Sawyer::Message::Facility mlog
Diagnostic messages.
virtual void init()
Initializes the callback lists.
bool get_skipback_reporting() const
Controls printing of skip/back messages during linear output.
virtual void set_prefix_address(rose_addr_t va)
Controls printing of line prefixes.
std::map< uint64_t, std::string > LabelMap
Maps integers to labels.
virtual RegisterDictionaryPtr get_registers() const
Register dictionaries.
static void initDiagnostics()
Initialize diagnostic messages subsystem.
CFG_BlockMap cfg_blockmap
A mapping from SgAsmBlock to control flow graph vertex.
RegisterDictionaryPtr user_registers
Dictionaries used to convert register descriptors to register names.
CallbackLists staticdata_callbacks
Callbacks for static data unparsing.
virtual const std::string & get_prefix_format() const
Controls printing of line prefixes.
CallbackLists basicblock_callbacks
Callbacks for basic block unparsing.
virtual std::string line_prefix() const
Controls printing of line prefixes.
CallbackLists interp_callbacks
Callbacks for interpretation unparsing.
virtual bool unparse_staticdata(bool enabled, std::ostream &, SgAsmStaticData *, size_t position_in_block=(size_t) -1)
Unparse an object.
virtual std::string blank_prefix() const
Controls printing of line prefixes.
virtual bool unparse_basicblock(bool enabled, std::ostream &, SgAsmBlock *)
Unparse an object.
virtual bool is_unparsable_node(SgNode *node)
Determines if a node can be unparsed.
BlockGraph Graph
Default control flow graph.
boost::adjacency_list< boost::setS, boost::vecS, boost::bidirectionalS, boost::property< boost::vertex_name_t, SgAsmFunction * > > Graph
The default function call graph type.
List of callback functors.
Definition callbacks.h:83
List & clear()
Remove all callbacks from list without destroying them.
Definition callbacks.h:245
Collection of streams.
Definition Message.h:1606
Instruction basic block.
Represents a synthesized function.
Base class for machine instructions.
Represents an interpretation of a binary container.
Represents static data in an executable.
This class represents the base class for all IR nodes within Sage III.
The ROSE library.
Callbacks::List< UnparserCallback > unparse
The main unparsing callbacks.
void clear()
Clears all the callback lists.
Callbacks::List< UnparserCallback > pre
Callbacks invoked before 'unparse' callbacks.
Callbacks::List< UnparserCallback > post
Callbacks invoked after 'unparse' callbacks.
std::string format
Printf-style format string.
rose_addr_t address
Address to use when generating a prefix string.
Details for skip/back reporting.
bool triggered
Have we seen the first object yet? Is the 'va' member valid?
rose_addr_t va
Virtual address for previous end_of_object() call.
Arguments passed to basic block unparsing callbacks.
const std::vector< SgAsmInstruction * > & insns
The instructions contained in this basic block.
SgAsmBlock * get_node() const
Return the node being unparsed.
Arguments passed to data block unparsing callbacks.
SgAsmBlock * block
The block of data being unparsed.
SgAsmBlock * get_node() const
Return the node being unparsed.
const std::vector< SgAsmStaticData * > & datalist
The data items contained in this data block.
Arguments passed to function unparsing callbacks.
SgAsmFunction * func
The function being unparsed.
SgAsmFunction * get_node() const
Return the node being unparsed.
Arguments common to all unparser callback lists.
AsmUnparser * unparser
The object doing the unparsing, from which this callback is invoked.
std::ostream & output
Where output should be sent.
Arguments passed to instruction unparsing callbacks.
size_t position_in_block
The index position of the instruction within the basic block, or -1 if unknown.
SgAsmInstruction * get_node() const
Return the node being unparsed.
SgAsmInstruction * insn
The instruction being unparsed.
Arguments passed to interpretation unparsing callbacks.
SgAsmInterpretation * interp
The interpretation being unparsed.
SgAsmInterpretation * get_node() const
Return the node being unparsed.
Arguments passed to data unparsing callbacks.
SgAsmStaticData * get_node() const
Return the node being unparsed.
size_t position_in_block
The index position of the data within the data block, or -1 if unknown.
Settings that control how the lowest-level hexdump function behaves.
Definition Hexdump.h:19
std::string prefix
Characters to emit after internal linefeeds.
Definition Hexdump.h:25
bool pad_chars
Pad character part of output with spaces for partial final line (default true).
Definition Hexdump.h:40
size_t width
Bytes per line of output (default 16).
Definition Hexdump.h:26
bool multiline
Emit prefix at beginning and line feed at end of output.
Definition Hexdump.h:29