Merge lp:~zorba-coders/zorba/ordpathmsgs into lp:zorba

Proposed by David Graf
Status: Superseded
Proposed branch: lp:~zorba-coders/zorba/ordpathmsgs
Merge into: lp:zorba
Diff against target: 130 lines (+49/-7)
5 files modified
src/diagnostics/assert.cpp (+8/-2)
src/diagnostics/assert.h (+23/-1)
src/diagnostics/diagnostic_en.xml (+1/-1)
src/diagnostics/pregenerated/dict_en.cpp (+1/-1)
src/store/naive/ordpath.cpp (+16/-2)
To merge this branch: bzr merge lp:~zorba-coders/zorba/ordpathmsgs
Reviewer Review Type Date Requested Status
Till Westmann Needs Information
Markos Zaharioudakis Pending
Review via email: mp+101373@code.launchpad.net

This proposal has been superseded by a proposal from 2012-04-11.

Description of the change

Introduced ZORBA_ASSERT_WITH_MSG macro to give additional debugging information in case an assertion fails. Currently used in Ordpath functions.

To post a comment you must log in.
Revision history for this message
Till Westmann (tillw) wrote :

Looks good, but it is not clear how the changes in bin/debugger/command.h and src/runtime/collections/collections_impl.cpp are related to the new macro.

review: Needs Information
lp:~zorba-coders/zorba/ordpathmsgs updated
10748. By David Graf

Removed unrelated changes from the branch.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/diagnostics/assert.cpp'
2--- src/diagnostics/assert.cpp 2012-03-28 05:19:57 +0000
3+++ src/diagnostics/assert.cpp 2012-04-11 09:42:23 +0000
4@@ -59,10 +59,16 @@
5
6 ///////////////////////////////////////////////////////////////////////////////
7
8-void assertion_failed( char const *condition, char const *file, int line ) {
9+void assertion_failed( char const *condition,
10+ char const *file,
11+ int line,
12+ char const *msg) {
13 print_stack_trace( cerr );
14 throw make_zorba_exception(
15- file, line, zerr::ZXQP0002_ASSERT_FAILED, ERROR_PARAMS( condition )
16+ file,
17+ line,
18+ zerr::ZXQP0002_ASSERT_FAILED,
19+ ( msg ? ERROR_PARAMS( condition, msg ) : ERROR_PARAMS( condition ))
20 );
21 }
22
23
24=== modified file 'src/diagnostics/assert.h'
25--- src/diagnostics/assert.h 2012-03-28 05:19:57 +0000
26+++ src/diagnostics/assert.h 2012-04-11 09:42:23 +0000
27@@ -29,12 +29,18 @@
28 * @param condition The string representation of the condition that failed.
29 * @param file The C++ source-code file name where the assertion failed.
30 * @param line The C++ source-code line number where the assertion failed.
31+ * @param msg An optional message that is output if the assertion fails.
32 * @throws ZXQP0002_ASSERT_FAILED
33 */
34-void assertion_failed( char const *condition, char const *file, int line );
35+void assertion_failed( char const *condition,
36+ char const *file,
37+ int line,
38+ char const *msg = 0);
39
40 /**
41 * Zorba version of the standard assert(3) macro.
42+ * Is checked in RELEASE mode as well. And outputs a special
43+ * error code with the failing condition.
44 */
45 #define ZORBA_ASSERT(COND) \
46 do { \
47@@ -44,6 +50,22 @@
48 } \
49 } while (0)
50
51+/**
52+ * Zorba version of the standard assert(3) macro.
53+ * Is checked in RELEASE mode as well. And outputs a special
54+ * error code with the failing condition as well as potentially
55+ * useful information for further debugging.
56+ */
57+#define ZORBA_ASSERT_WITH_MSG(COND,MSG) \
58+ do { \
59+ if ( !(COND) ) { \
60+ std::ostringstream oss; \
61+ oss << MSG; \
62+ zorba::assertion_failed( #COND, __FILE__, __LINE__, oss.str().c_str() ); \
63+ throw 0; /* never gets here but suppresses warning */ \
64+ } \
65+ } while (0)
66+
67 } // namespace zorba
68 #endif /* ZORBA_ASSERT_H */
69 /* vim:set et sw=2 ts=2: */
70
71=== modified file 'src/diagnostics/diagnostic_en.xml'
72--- src/diagnostics/diagnostic_en.xml 2012-03-28 05:19:57 +0000
73+++ src/diagnostics/diagnostic_en.xml 2012-04-11 09:42:23 +0000
74@@ -1589,7 +1589,7 @@
75 A Zorba programming assertion failed. If this error occurs, it is a bug
76 and should be reported.
77 </comment>
78- <value>"$1": assertion failed</value>
79+ <value>"$1": assertion failed.${ The following information might help: 2}</value>
80 </diagnostic>
81
82 <diagnostic code="ZXQP0003" name="INTERNAL_ERROR">
83
84=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
85--- src/diagnostics/pregenerated/dict_en.cpp 2012-03-28 05:19:57 +0000
86+++ src/diagnostics/pregenerated/dict_en.cpp 2012-04-11 09:42:23 +0000
87@@ -392,7 +392,7 @@
88 { "ZXQD0006", "\"$1\": invalid UTF-8 byte sequence" },
89 { "ZXQP0000", "no error" },
90 { "ZXQP0001", "dynamic runtime error${: 1}" },
91- { "ZXQP0002", "\"$1\": assertion failed" },
92+ { "ZXQP0002", "\"$1\": assertion failed.${ The following information might help: 2}" },
93 { "ZXQP0003", "internal error${: 1}" },
94 { "ZXQP0004", "not yet implemented: $1" },
95 { "ZXQP0005", "\"$1\": feature not enabled" },
96
97=== modified file 'src/store/naive/ordpath.cpp'
98--- src/store/naive/ordpath.cpp 2012-03-28 23:58:23 +0000
99+++ src/store/naive/ordpath.cpp 2012-04-11 09:42:23 +0000
100@@ -960,7 +960,14 @@
101 while (dewey1[compPos] == dewey2[compPos])
102 {
103 ++compPos;
104- ZORBA_ASSERT(compPos < numComps1 && compPos < numComps2);
105+ ZORBA_ASSERT_WITH_MSG(compPos < numComps1 && compPos < numComps2, \
106+ "Involved Parameters: " \
107+ << "Parent: " << parent.show().c_str() << ", " \
108+ << "Sib1: " << sib1.show().c_str() << ", " \
109+ << "Sib2: " << sib2.show().c_str() << ", " \
110+ << "compPos: " << compPos << ", " \
111+ << "numComps1: " << numComps1 << ", " \
112+ << "numComps2: " << numComps2 << ".");
113 }
114
115 int32_t comp1 = dewey1[compPos];
116@@ -968,7 +975,14 @@
117 bool odd1 = (comp1 % 2 != 0);
118 bool odd2 = (comp2 % 2 != 0);
119
120- ZORBA_ASSERT(comp1 < comp2);
121+ ZORBA_ASSERT_WITH_MSG(comp1 < comp2, \
122+ "Involved Parameters: " \
123+ << "Parent: " << parent.show().c_str() << ", " \
124+ << "Sib1: " << sib1.show().c_str() << ", " \
125+ << "Sib2: " << sib2.show().c_str() << ", " \
126+ << "comp1: " << comp1 << ", " \
127+ << "comp2: " << comp2 << ", " \
128+ << "compPos: " << compPos << ".");
129
130 ulong diff = comp2 - comp1;
131

Subscribers

People subscribed via source and target branches