summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Moore <moore@blackbox.bricoworks.com>2008-06-11 14:46:34 +0200
committerTim Moore <moore@blackbox.bricoworks.com>2008-06-11 14:49:20 +0200
commitba53ea9f51453154bca13c57988a17e009e80476 (patch)
tree32f1abdc0a53b52b61b55cba2a50a29e0f2362e9
parent86bf665eac22efa78936a3059e7bc90ee10dcf4b (diff)
downloadsystemtap-steved-ba53ea9f51453154bca13c57988a17e009e80476.tar.gz
systemtap-steved-ba53ea9f51453154bca13c57988a17e009e80476.tar.xz
systemtap-steved-ba53ea9f51453154bca13c57988a17e009e80476.zip
Fix some logic inversions with dwfl_assert.
-rw-r--r--ChangeLog7
-rw-r--r--dwarf_wrappers.cxx6
-rw-r--r--dwarf_wrappers.h6
-rw-r--r--tapsets.cxx6
4 files changed, 22 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index a5a6d3c5..cf3ef289 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2008-06-11 Tim Moore <timoore@redhat.com>
+ * dwarf_wrappers.h (dwfl_assert): Add overload with boolean value
+ for assertion test.
+ * dwarf_wrappers.cxx (dwfl_assert): Write boolean condition
+ version.
+ * tapsets.cxx (emit_address): Fix up dwfl_asserts that got negated
+ in changes to dwfl_assert.
+
PR 2608
* dwarf_wrappers.h, dwarf_wrappers.cxx: New files.
* Makefile.in: Regenerated.
diff --git a/dwarf_wrappers.cxx b/dwarf_wrappers.cxx
index ad690d78..93cb36a2 100644
--- a/dwarf_wrappers.cxx
+++ b/dwarf_wrappers.cxx
@@ -38,3 +38,9 @@ void dwarf_assert(const string& desc, int rc)
msg += std::strerror (rc);
throw semantic_error (msg);
}
+
+void dwfl_assert(const std::string& desc, bool condition)
+{
+ if (!condition)
+ dwarf_assert(desc, -1);
+}
diff --git a/dwarf_wrappers.h b/dwarf_wrappers.h
index 043c2957..c498de05 100644
--- a/dwarf_wrappers.h
+++ b/dwarf_wrappers.h
@@ -15,6 +15,7 @@
// NB: "rc == 0" means OK in this case
void dwfl_assert(const std::string& desc, int rc);
+// Throw error if pointer is NULL.
template <typename T>
void dwfl_assert(const std::string& desc, T* ptr)
{
@@ -22,6 +23,7 @@ void dwfl_assert(const std::string& desc, T* ptr)
dwfl_assert(desc, -1);
}
+// Throw error if pointer is NULL
template <typename T>
void dwfl_assert(const std::string& desc, const T* ptr)
{
@@ -29,9 +31,13 @@ void dwfl_assert(const std::string& desc, const T* ptr)
dwfl_assert(desc, -1);
}
+// Throw error if condition is false
+void dwfl_assert(const std::string& desc, bool condition);
+
// NB: "rc == 0" means OK in this case
void dwarf_assert(const std::string& desc, int rc);
+// Throw error if pointer is NULL
template <typename T>
void dwarf_assert(const std::string& desc, T* ptr)
{
diff --git a/tapsets.cxx b/tapsets.cxx
index f0809978..a571ea0d 100644
--- a/tapsets.cxx
+++ b/tapsets.cxx
@@ -1530,9 +1530,9 @@ struct dwflpp
Dwfl_Module *mod = dwfl_addrmodule (dwfl, address);
dwfl_assert ("dwfl_addrmodule", mod);
int n = dwfl_module_relocations (mod);
- dwfl_assert ("dwfl_module_relocations", n);
+ dwfl_assert ("dwfl_module_relocations", n >= 0);
int i = dwfl_module_relocate_address (mod, &address);
- dwfl_assert ("dwfl_module_relocate_address", i);
+ dwfl_assert ("dwfl_module_relocate_address", i >= 0);
const char *modname = dwfl_module_info (mod, NULL, NULL, NULL,
NULL, NULL, NULL, NULL);
dwfl_assert ("dwfl_module_info", modname);
@@ -1540,7 +1540,7 @@ struct dwflpp
if (n > 0 && !(n == 1 && secname == NULL))
{
- dwfl_assert ("dwfl_module_relocation_info", secname == NULL);
+ dwfl_assert ("dwfl_module_relocation_info", secname);
if (n > 1 || secname[0] != '\0')
{
// This gives us the module name, and section name within the