summaryrefslogtreecommitdiff
path: root/rtems-coverage
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2010-05-18 15:30:37 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2010-05-18 15:30:37 +0000
commit4967baae9f45fbf3e60454e86f3bb31b74900312 (patch)
tree0ace239805ba2c0ce50ae1f07334d50b68a8fbb7 /rtems-coverage
parentb75e7202b37f0d90a4211ee20186c24c126f36fb (diff)
2010-05-18 Joel Sherrill <joel.sherrill@oarcorp.com>
* ObjdumpProcessor.cc: Now read dlinfo from file.
Diffstat (limited to 'rtems-coverage')
-rw-r--r--rtems-coverage/ChangeLog4
-rw-r--r--rtems-coverage/ObjdumpProcessor.cc59
2 files changed, 56 insertions, 7 deletions
diff --git a/rtems-coverage/ChangeLog b/rtems-coverage/ChangeLog
index 77de7d2..b41f0ee 100644
--- a/rtems-coverage/ChangeLog
+++ b/rtems-coverage/ChangeLog
@@ -1,3 +1,7 @@
+2010-05-18 Joel Sherrill <joel.sherrill@oarcorp.com>
+
+ * ObjdumpProcessor.cc: Now read dlinfo from file.
+
2010-05-18 Glenn Humphrey
* TraceConverter.cc: Removed initialization of the dynamicLibrary
diff --git a/rtems-coverage/ObjdumpProcessor.cc b/rtems-coverage/ObjdumpProcessor.cc
index 03380d3..29a7502 100644
--- a/rtems-coverage/ObjdumpProcessor.cc
+++ b/rtems-coverage/ObjdumpProcessor.cc
@@ -16,6 +16,7 @@
#include <stdlib.h>
#include <string.h>
#include <algorithm>
+#include <string>
#include "app_common.h"
#include "ObjdumpProcessor.h"
@@ -129,21 +130,24 @@ namespace Coverage {
ExecutableInfo* theExecutable
)
{
-#if 0
+ #define METHOD "ERROR: ObjdumpProcessor::determineLoadAddress - "
+ FILE* loadAddressFile = NULL;
char buffer[ 512 ];
char* cStatus;
+ uint32_t offset;
+
+ // This method should only be call for a dynamic library.
+ if (!theExecutable->hasDynamicLibrary())
+ return 0;
+
+#if 0
static FILE* gdbCommands = NULL;
int items;
uint32_t loadAddress;
- FILE* loadAddressFile = NULL;
FILE* objdumpFile = NULL;
- uint32_t offset;
int status;
char terminator;
- // This method should only be call for a dynamic library.
- if (!theExecutable->hasDynamicLibrary())
- return 0;
//
// Invoke gdb to determine the physical load address
@@ -253,7 +257,48 @@ namespace Coverage {
return (loadAddress - offset);
# endif
- return 0x42084000;
+#if 1
+ std::string dlinfoName = theExecutable->getFileName();
+ uint32_t address;
+ char inLibName[128];
+ std::string Library = theExecutable->getLibraryName();
+
+ dlinfoName += ".dlinfo";
+ // Read load address.
+ loadAddressFile = fopen( dlinfoName.c_str(), "r" );
+ if (!loadAddressFile) {
+ fprintf( stderr, METHOD "unable to open %s\n", dlinfoName.c_str() );
+ exit( -1 );
+ }
+
+ // Process the dlinfo file.
+ while ( 1 ) {
+
+ // Get a line.
+ cStatus = fgets( buffer, 512, loadAddressFile );
+ if (cStatus == NULL) {
+ fprintf(
+ stderr,
+ METHOD "library %s not found in %s\n",
+ Library.c_str(),
+ dlinfoName.c_str()
+ );
+ fclose( loadAddressFile );
+ exit( -1 );
+ }
+ sscanf( buffer, "%s %x", inLibName, &offset );
+ std::string tmp = inLibName;
+ if ( tmp.find( Library ) != tmp.npos ) {
+ // fprintf( stderr, "%s - 0x%08x\n", inLibName, offset );
+ address = offset;
+ break;
+ }
+ }
+
+ fclose( loadAddressFile );
+ return address;
+#endif
+ #undef METHOD
}
bool ObjdumpProcessor::IsBranch(