summaryrefslogtreecommitdiffstats
path: root/dwarflint/coverage.hh
diff options
context:
space:
mode:
Diffstat (limited to 'dwarflint/coverage.hh')
-rw-r--r--dwarflint/coverage.hh69
1 files changed, 67 insertions, 2 deletions
diff --git a/dwarflint/coverage.hh b/dwarflint/coverage.hh
index d2b418a2..e13344be 100644
--- a/dwarflint/coverage.hh
+++ b/dwarflint/coverage.hh
@@ -1,6 +1,6 @@
/* Coverage analysis, C++ support.
- Copyright (C) 2008,2009 Red Hat, Inc.
+ Copyright (C) 2008, 2009, 2010 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -29,7 +29,72 @@
#include <string>
#include <sstream>
-#include "coverage.h"
+
+/* Functions and data structures for handling of address range
+ coverage. We use that to find holes of unused bytes in DWARF
+ string table. */
+
+struct cov_range
+{
+ uint64_t start;
+ uint64_t length;
+
+#ifdef __cplusplus
+ uint64_t end () const { return start + length; }
+#endif
+};
+
+struct coverage
+{
+ struct cov_range *ranges;
+ size_t size;
+ size_t alloc;
+
+#ifdef __cplusplus
+ cov_range &back () { return ranges[size - 1]; }
+ cov_range const &back () const { return ranges[size - 1]; }
+#endif
+};
+
+char *range_fmt (char *buf, size_t buf_size,
+ uint64_t start, uint64_t end);
+
+struct coverage *coverage_clone (struct coverage const *cov)
+ __attribute__ ((malloc));
+void coverage_free (struct coverage *cov);
+
+void coverage_add (struct coverage *cov, uint64_t start, uint64_t length);
+void coverage_add_all (struct coverage *__restrict__ cov,
+ struct coverage const *__restrict__ other);
+
+/* Returns true if something was actually removed, false if whole
+ range falls into hole in coverage. */
+bool coverage_remove (struct coverage *cov, uint64_t start, uint64_t length);
+
+/* Returns true if something was actually removed, false if whole
+ range falls into hole in coverage. */
+bool coverage_remove_all (struct coverage *__restrict__ cov,
+ struct coverage const *__restrict__ other);
+
+/* Returns true if whole range ADDRESS/LENGTH is covered by COV.
+ LENGTH may not be zero. */
+bool coverage_is_covered (struct coverage const *cov,
+ uint64_t start, uint64_t length);
+
+/* Returns true if at least some of the range ADDRESS/LENGTH is
+ covered by COV. Zero-LENGTH range never overlaps. */
+bool coverage_is_overlap (struct coverage const *cov,
+ uint64_t start, uint64_t length);
+
+bool coverage_find_holes (struct coverage const *cov,
+ uint64_t start, uint64_t length,
+ bool (*cb)(uint64_t start, uint64_t length,
+ void *data),
+ void *data);
+bool coverage_find_ranges (struct coverage const *cov,
+ bool (*cb)(uint64_t start, uint64_t length,
+ void *data),
+ void *data);
namespace cov
{