aboutsummaryrefslogtreecommitdiff
path: root/extract-gcov.c
diff options
context:
space:
mode:
authorStewart Smith <stewart@linux.vnet.ibm.com>2015-06-24 14:40:54 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2015-06-24 14:40:54 +1000
commit11dfb25fae9d0f92de5c10ba4ef08a7ff8e88410 (patch)
treeef4a74ed7cf005f81a186d4f3c8ac419a592cbd4 /extract-gcov.c
parent63602a3de5b5ec4d04d93068aed1af642a1ff234 (diff)
downloadskiboot-11dfb25fae9d0f92de5c10ba4ef08a7ff8e88410.zip
skiboot-11dfb25fae9d0f92de5c10ba4ef08a7ff8e88410.tar.gz
skiboot-11dfb25fae9d0f92de5c10ba4ef08a7ff8e88410.tar.bz2
fix error handling and skiboot dump size in extract-gcov.c
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'extract-gcov.c')
-rw-r--r--extract-gcov.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/extract-gcov.c b/extract-gcov.c
index f178166..17fa25a 100644
--- a/extract-gcov.c
+++ b/extract-gcov.c
@@ -27,6 +27,8 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
+#include <errno.h>
+#include <string.h>
typedef unsigned int gcov_unsigned_int;
@@ -97,10 +99,12 @@ static size_t write_u64(int fd, u64 v)
// gcc 4.7/4.8 specific
#define GCOV_TAG_FUNCTION_LENGTH 3
+size_t skiboot_dump_size = 0x240000;
+
static inline const char* SKIBOOT_ADDR(const char* addr, const void* p)
{
const char* r= (addr + (be64toh((const u64)p) - SKIBOOT_OFFSET));
- assert(r < (addr + 0x240000));
+ assert(r < (addr + skiboot_dump_size));
return r;
}
@@ -192,13 +196,22 @@ int main(int argc, char *argv[])
/* argv[1] = skiboot.dump */
fd = open(argv[1], O_RDONLY);
- assert(fd > 0);
+ if (fd < 0) {
+ fprintf(stderr, "Cannot open dump: %s (error %d %s)\n",
+ argv[1], errno, strerror(errno));
+ exit(-1);
+ }
r = fstat(fd, &sb);
- assert(r != -1);
+ if (r < 0) {
+ fprintf(stderr, "Cannot stat dump, %d %s\n",
+ errno, strerror(errno));
+ exit(-1);
+ }
addr = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
assert(addr != NULL);
+ skiboot_dump_size = sb.st_size;
printf("Skiboot memory dump %p - %p\n",
(void*)SKIBOOT_OFFSET, (void*)SKIBOOT_OFFSET+sb.st_size);