aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormmentovai <mmentovai@4c0a9323-5329-0410-9bdc-e9ce6186880e>2006-11-09 17:04:56 +0000
committermmentovai <mmentovai@4c0a9323-5329-0410-9bdc-e9ce6186880e>2006-11-09 17:04:56 +0000
commit8647dde8cc03ef16b565dccc75574ee5f0d9cf72 (patch)
treedfe03649d7d6d66297ceacc0d783338c2f3a04eb
parentSuppress handler thread from appearing in MinidumpProcessor's ProcessState (diff)
downloadbreakpad-8647dde8cc03ef16b565dccc75574ee5f0d9cf72.tar.xz
Limit use of default namespace in tests and utility programs (#71). r=bryner
- main is now the only thing you'll find in the default namespace. Everything else has been moved into an unnamed namespace. http://groups.google.com/group/airbag-dev/browse_thread/thread/14130a0284a0307f git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@63 4c0a9323-5329-0410-9bdc-e9ce6186880e
-rw-r--r--src/processor/address_map_unittest.cc4
-rw-r--r--src/processor/contained_range_map_unittest.cc6
-rw-r--r--src/processor/minidump_dump.cc36
-rw-r--r--src/processor/minidump_processor_unittest.cc12
-rw-r--r--src/processor/minidump_stackwalk.cc4
-rw-r--r--src/processor/pathname_stripper_unittest.cc4
-rw-r--r--src/processor/postfix_evaluator_unittest.cc8
-rw-r--r--src/processor/range_map_unittest.cc13
-rw-r--r--src/processor/source_line_resolver_unittest.cc20
9 files changed, 78 insertions, 29 deletions
diff --git a/src/processor/address_map_unittest.cc b/src/processor/address_map_unittest.cc
index 01d52166..82c1a007 100644
--- a/src/processor/address_map_unittest.cc
+++ b/src/processor/address_map_unittest.cc
@@ -47,6 +47,8 @@
#define ASSERT_EQ(e1, e2) ASSERT_TRUE((e1) == (e2))
+namespace {
+
using google_airbag::AddressMap;
using google_airbag::linked_ptr;
@@ -185,6 +187,8 @@ static bool RunTests() {
return true;
}
+} // namespace
+
int main(int argc, char **argv) {
return RunTests() ? 0 : 1;
}
diff --git a/src/processor/contained_range_map_unittest.cc b/src/processor/contained_range_map_unittest.cc
index 99185d54..3861c9bc 100644
--- a/src/processor/contained_range_map_unittest.cc
+++ b/src/processor/contained_range_map_unittest.cc
@@ -45,6 +45,9 @@
#define ASSERT_FALSE(condition) ASSERT_TRUE(!(condition))
+namespace {
+
+
using google_airbag::ContainedRangeMap;
@@ -248,6 +251,9 @@ static bool RunTests() {
}
+} // namespace
+
+
int main(int argc, char **argv) {
return RunTests() ? 0 : 1;
}
diff --git a/src/processor/minidump_dump.cc b/src/processor/minidump_dump.cc
index 86e241e1..ea9685d7 100644
--- a/src/processor/minidump_dump.cc
+++ b/src/processor/minidump_dump.cc
@@ -36,18 +36,22 @@
#include "google_airbag/processor/minidump.h"
-using namespace google_airbag;
+namespace {
-int main(int argc, char **argv) {
- if (argc != 2) {
- fprintf(stderr, "usage: %s <file>\n", argv[0]);
- return 1;
- }
+using google_airbag::Minidump;
+using google_airbag::MinidumpThreadList;
+using google_airbag::MinidumpModuleList;
+using google_airbag::MinidumpMemoryList;
+using google_airbag::MinidumpException;
+using google_airbag::MinidumpSystemInfo;
+using google_airbag::MinidumpMiscInfo;
+using google_airbag::MinidumpAirbagInfo;
- Minidump minidump(argv[1]);
+static bool PrintMinidumpDump(const char *minidump_file) {
+ Minidump minidump(minidump_file);
if (!minidump.Read()) {
- printf("minidump.Read() failed\n");
- return 1;
+ fprintf(stderr, "minidump.Read() failed\n");
+ return false;
}
minidump.Print();
@@ -109,6 +113,16 @@ int main(int argc, char **argv) {
airbag_info->Print();
}
- // Use return instead of exit to allow destructors to run.
- return errors == 0 ? 0 : 1;
+ return errors == 0;
+}
+
+} // namespace
+
+int main(int argc, char **argv) {
+ if (argc != 2) {
+ fprintf(stderr, "usage: %s <file>\n", argv[0]);
+ return 1;
+ }
+
+ return PrintMinidumpDump(argv[1]) ? 0 : 1;
}
diff --git a/src/processor/minidump_processor_unittest.cc b/src/processor/minidump_processor_unittest.cc
index ca079a20..9166be92 100644
--- a/src/processor/minidump_processor_unittest.cc
+++ b/src/processor/minidump_processor_unittest.cc
@@ -39,11 +39,15 @@
#include "google_airbag/processor/symbol_supplier.h"
#include "processor/scoped_ptr.h"
+namespace {
+
using std::string;
using google_airbag::CallStack;
+using google_airbag::MinidumpModule;
using google_airbag::MinidumpProcessor;
using google_airbag::ProcessState;
using google_airbag::scoped_ptr;
+using google_airbag::SymbolSupplier;
#define ASSERT_TRUE(cond) \
if (!(cond)) { \
@@ -53,8 +57,6 @@ using google_airbag::scoped_ptr;
#define ASSERT_EQ(e1, e2) ASSERT_TRUE((e1) == (e2))
-namespace google_airbag {
-
class TestSymbolSupplier : public SymbolSupplier {
public:
virtual string GetSymbolFile(MinidumpModule *module);
@@ -72,10 +74,6 @@ string TestSymbolSupplier::GetSymbolFile(MinidumpModule *module) {
return "";
}
-} // namespace google_airbag
-
-using google_airbag::TestSymbolSupplier;
-
static bool RunTests() {
TestSymbolSupplier supplier;
MinidumpProcessor processor(&supplier);
@@ -129,6 +127,8 @@ static bool RunTests() {
return true;
}
+} // namespace
+
int main(int argc, char *argv[]) {
if (!RunTests()) {
return 1;
diff --git a/src/processor/minidump_stackwalk.cc b/src/processor/minidump_stackwalk.cc
index d6a228fe..4fbee425 100644
--- a/src/processor/minidump_stackwalk.cc
+++ b/src/processor/minidump_stackwalk.cc
@@ -45,6 +45,8 @@
#include "processor/scoped_ptr.h"
#include "processor/simple_symbol_supplier.h"
+namespace {
+
using std::string;
using google_airbag::CallStack;
using google_airbag::MinidumpModule;
@@ -218,6 +220,8 @@ static bool PrintMinidumpProcess(const string &minidump_file,
return true;
}
+} // namespace
+
int main(int argc, char **argv) {
if (argc < 2 || argc > 3) {
fprintf(stderr, "usage: %s <minidump-file> [symbol-path]\n", argv[0]);
diff --git a/src/processor/pathname_stripper_unittest.cc b/src/processor/pathname_stripper_unittest.cc
index eab27d54..a1d8e710 100644
--- a/src/processor/pathname_stripper_unittest.cc
+++ b/src/processor/pathname_stripper_unittest.cc
@@ -37,6 +37,8 @@
#define ASSERT_EQ(e1, e2) ASSERT_TRUE((e1) == (e2))
+namespace {
+
using google_airbag::PathnameStripper;
static bool RunTests() {
@@ -73,6 +75,8 @@ static bool RunTests() {
return true;
}
+} // namespace
+
int main(int argc, char **argv) {
return RunTests() ? 0 : 1;
}
diff --git a/src/processor/postfix_evaluator_unittest.cc b/src/processor/postfix_evaluator_unittest.cc
index 0362a7ae..9fac632d 100644
--- a/src/processor/postfix_evaluator_unittest.cc
+++ b/src/processor/postfix_evaluator_unittest.cc
@@ -26,6 +26,9 @@
#include "google_airbag/processor/memory_region.h"
+namespace {
+
+
using std::map;
using std::string;
using google_airbag::MemoryRegion;
@@ -84,7 +87,7 @@ struct EvaluateTestSet {
};
-bool RunTests() {
+static bool RunTests() {
// The first test set checks the basic operations and failure modes.
PostfixEvaluator<unsigned int>::DictionaryType dictionary_0;
const EvaluateTest evaluate_tests_0[] = {
@@ -274,6 +277,9 @@ bool RunTests() {
}
+} // namespace
+
+
int main(int argc, char **argv) {
return RunTests() ? 0 : 1;
}
diff --git a/src/processor/range_map_unittest.cc b/src/processor/range_map_unittest.cc
index 11cf48e6..cff5b0a9 100644
--- a/src/processor/range_map_unittest.cc
+++ b/src/processor/range_map_unittest.cc
@@ -41,6 +41,9 @@
#include "processor/scoped_ptr.h"
+namespace {
+
+
using google_airbag::linked_ptr;
using google_airbag::scoped_ptr;
using google_airbag::RangeMap;
@@ -99,7 +102,7 @@ struct RangeTestSet {
// StoreTest uses the data in a RangeTest and calls StoreRange on the
// test RangeMap. It returns true if the expected result occurred, and
// false if something else happened.
-bool StoreTest(TestMap *range_map, const RangeTest *range_test) {
+static bool StoreTest(TestMap *range_map, const RangeTest *range_test) {
linked_ptr<CountedObject> object(new CountedObject(range_test->id));
bool stored = range_map->StoreRange(range_test->address,
range_test->size,
@@ -123,7 +126,7 @@ bool StoreTest(TestMap *range_map, const RangeTest *range_test) {
// map entry at the specified range,) it returns true, otherwise, it returns
// false. RetrieveTest will check the values around the base address and
// the high address of a range to guard against off-by-one errors.
-bool RetrieveTest(TestMap *range_map, const RangeTest *range_test) {
+static bool RetrieveTest(TestMap *range_map, const RangeTest *range_test) {
for (unsigned int side = 0; side <= 1; ++side) {
// When side == 0, check the low side (base address) of each range.
// When side == 1, check the high side (base + size) of each range.
@@ -241,7 +244,7 @@ bool RetrieveTest(TestMap *range_map, const RangeTest *range_test) {
// RunTests runs a series of test sets.
-bool RunTests() {
+static bool RunTests() {
// These tests will be run sequentially. The first set of tests exercises
// most functions of RangeTest, and verifies all of the bounds-checking.
const RangeTest range_tests_0[] = {
@@ -402,6 +405,10 @@ bool RunTests() {
return true;
}
+
+} // namespace
+
+
int main(int argc, char **argv) {
return RunTests() ? 0 : 1;
}
diff --git a/src/processor/source_line_resolver_unittest.cc b/src/processor/source_line_resolver_unittest.cc
index abd194b1..e2ea0fee 100644
--- a/src/processor/source_line_resolver_unittest.cc
+++ b/src/processor/source_line_resolver_unittest.cc
@@ -27,7 +27,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#include <stdio.h>
+#include <cstdio>
#include <string>
#include "processor/source_line_resolver.h"
#include "google_airbag/processor/stack_frame.h"
@@ -35,13 +35,6 @@
#include "processor/scoped_ptr.h"
#include "processor/stack_frame_info.h"
-using std::string;
-using google_airbag::linked_ptr;
-using google_airbag::scoped_ptr;
-using google_airbag::SourceLineResolver;
-using google_airbag::StackFrame;
-using google_airbag::StackFrameInfo;
-
#define ASSERT_TRUE(cond) \
if (!(cond)) { \
fprintf(stderr, "FAILED: %s at %s:%d\n", #cond, __FILE__, __LINE__); \
@@ -52,6 +45,15 @@ using google_airbag::StackFrameInfo;
#define ASSERT_EQ(e1, e2) ASSERT_TRUE((e1) == (e2))
+namespace {
+
+using std::string;
+using google_airbag::linked_ptr;
+using google_airbag::scoped_ptr;
+using google_airbag::SourceLineResolver;
+using google_airbag::StackFrame;
+using google_airbag::StackFrameInfo;
+
static bool VerifyEmpty(const StackFrame &frame) {
ASSERT_TRUE(frame.function_name.empty());
ASSERT_TRUE(frame.source_file_name.empty());
@@ -146,6 +148,8 @@ static bool RunTests() {
return true;
}
+} // namespace
+
int main(int argc, char **argv) {
if (!RunTests()) {
return 1;