summaryrefslogtreecommitdiffstats
path: root/tester/covoar/ObjdumpProcessor.h
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2014-05-09 21:50:37 +1000
committerChris Johns <chrisj@rtems.org>2014-06-18 16:48:08 +1200
commit100f517ab37265acdf067e36b6860020ec8b2184 (patch)
tree2316c8b888e11dcbcfbfc66a0c1e31991ea20656 /tester/covoar/ObjdumpProcessor.h
parent4.11: Add ntp patch. (diff)
downloadrtems-tools-100f517ab37265acdf067e36b6860020ec8b2184.tar.bz2
covoar: Merger the covoar source from rtems-testing.git.
Use waf to build covoar.
Diffstat (limited to 'tester/covoar/ObjdumpProcessor.h')
-rw-r--r--tester/covoar/ObjdumpProcessor.h165
1 files changed, 165 insertions, 0 deletions
diff --git a/tester/covoar/ObjdumpProcessor.h b/tester/covoar/ObjdumpProcessor.h
new file mode 100644
index 0000000..283ac73
--- /dev/null
+++ b/tester/covoar/ObjdumpProcessor.h
@@ -0,0 +1,165 @@
+/*! @file ObjdumpProcessor.h
+ * @brief ObjdumpProcessor Specification
+ *
+ * This file contains the specification of the ObjdumpProcessor class.
+ */
+
+#ifndef __OBJDUMP_PROCESSOR_H__
+#define __OBJDUMP_PROCESSOR_H__
+
+#include <list>
+#include <string>
+
+#include "ExecutableInfo.h"
+#include "TargetBase.h"
+
+namespace Coverage {
+
+ /*! @class ObjdumpProcessor
+ *
+ * This class implements the functionality which reads the output of
+ * an objdump. Various information is extracted from the objdump line
+ * to support analysis and report writing. Analysis of the objdump line
+ * also allows for identification of "nops". For the purpose of coverage
+ * analysis, nops in the executable may be ignored. Compilers often
+ * produce nops to align functions on particular alignment boundaries
+ * and the nop between functions can not possibly be executed.
+ */
+ class ObjdumpProcessor {
+
+ public:
+
+ /*!
+ * This type defines the elements of an objdump line.
+ */
+ typedef struct {
+ /*!
+ * This member variable contains the actual line from the object dump.
+ */
+ std::string line;
+
+ /*!
+ * This member variable contains the address from the object dump line.
+ */
+ uint32_t address;
+
+ /*!
+ * This member variable contains an indication of whether the line
+ * is an instruction.
+ */
+ bool isInstruction;
+
+ /*!
+ * This member variable contains an indication of whether the line
+ * is a nop instruction.
+ */
+ bool isNop;
+
+ /*!
+ * This member variable contains the size of the nop instruction.
+ */
+ int nopSize;
+
+ /*!
+ * This member variable contains an indication of whether the line
+ * is a branch instruction.
+ */
+ bool isBranch;
+
+ } objdumpLine_t;
+
+ /*!
+ * This object defines a list of object dump lines
+ * for a file.
+ */
+ typedef std::list<objdumpLine_t> objdumpLines_t;
+
+
+ /*!
+ * This object defines a list of instruction addresses
+ * that will be extracted from the objdump file.
+ */
+ typedef std::list<uint32_t> objdumpFile_t;
+
+ /*!
+ * This method constructs an ObjdumpProcessor instance.
+ */
+ ObjdumpProcessor();
+
+ /*!
+ * This method destructs an ObjdumpProcessor instance.
+ */
+ virtual ~ObjdumpProcessor();
+
+ uint32_t determineLoadAddress(
+ ExecutableInfo* theExecutable
+ );
+
+ /*!
+ * This method returns a file pointer to the objdump file
+ * for the given file name.
+ */
+ FILE* getFile( std::string fileName );
+
+ /*!
+ * This method fills the objdumpList list with all the
+ * instruction addresses in the object dump file.
+ */
+ void loadAddressTable (
+ ExecutableInfo* const executableInformation
+ );
+
+ /*!
+ * This method generates and processes an object dump for
+ * the specified executable.
+ */
+ void load(
+ ExecutableInfo* const executableInformation
+ );
+
+ /*!
+ * This method returns the next address in othe objdumpList.
+ */
+ uint32_t getAddressAfter( uint32_t address );
+
+ /*!
+ * This method returns true if the instrucation is
+ * an instruction that results in a code branch, otherwise
+ * it returns false.
+ */
+ bool IsBranch( const char *instruction );
+
+ /*!
+ * This method returns true if the instruction from
+ * the given line in the objdmp file is a branch instruction,
+ * otherwise it returns false.
+ */
+ bool isBranchLine(
+ const char* const line
+ );
+
+ private:
+
+ /*!
+ * This variable consists of a list of all instruction addresses
+ * extracted from the obj dump file.
+ */
+ objdumpFile_t objdumpList;
+
+ /*!
+ * This method determines whether the specified line is a
+ * nop instruction.
+ *
+ * @param[in] line contains the object dump line to check
+ * @param[out] size is set to the size in bytes of the nop
+ *
+ * @return Returns TRUE if the instruction is a nop, FALSE otherwise.
+ */
+ bool isNop(
+ const char* const line,
+ int& size
+ );
+
+ };
+}
+#endif