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
=== modified file 'src/diagnostics/assert.cpp'
--- src/diagnostics/assert.cpp 2012-03-28 05:19:57 +0000
+++ src/diagnostics/assert.cpp 2012-04-11 09:42:23 +0000
@@ -59,10 +59,16 @@
5959
60///////////////////////////////////////////////////////////////////////////////60///////////////////////////////////////////////////////////////////////////////
6161
62void assertion_failed( char const *condition, char const *file, int line ) {62void assertion_failed( char const *condition,
63 char const *file,
64 int line,
65 char const *msg) {
63 print_stack_trace( cerr );66 print_stack_trace( cerr );
64 throw make_zorba_exception(67 throw make_zorba_exception(
65 file, line, zerr::ZXQP0002_ASSERT_FAILED, ERROR_PARAMS( condition )68 file,
69 line,
70 zerr::ZXQP0002_ASSERT_FAILED,
71 ( msg ? ERROR_PARAMS( condition, msg ) : ERROR_PARAMS( condition ))
66 );72 );
67}73}
6874
6975
=== modified file 'src/diagnostics/assert.h'
--- src/diagnostics/assert.h 2012-03-28 05:19:57 +0000
+++ src/diagnostics/assert.h 2012-04-11 09:42:23 +0000
@@ -29,12 +29,18 @@
29 * @param condition The string representation of the condition that failed.29 * @param condition The string representation of the condition that failed.
30 * @param file The C++ source-code file name where the assertion failed.30 * @param file The C++ source-code file name where the assertion failed.
31 * @param line The C++ source-code line number where the assertion failed.31 * @param line The C++ source-code line number where the assertion failed.
32 * @param msg An optional message that is output if the assertion fails.
32 * @throws ZXQP0002_ASSERT_FAILED33 * @throws ZXQP0002_ASSERT_FAILED
33 */34 */
34void assertion_failed( char const *condition, char const *file, int line );35void assertion_failed( char const *condition,
36 char const *file,
37 int line,
38 char const *msg = 0);
3539
36/**40/**
37 * Zorba version of the standard assert(3) macro.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.
38 */44 */
39#define ZORBA_ASSERT(COND) \45#define ZORBA_ASSERT(COND) \
40 do { \46 do { \
@@ -44,6 +50,22 @@
44 } \50 } \
45 } while (0)51 } while (0)
4652
53/**
54 * Zorba version of the standard assert(3) macro.
55 * Is checked in RELEASE mode as well. And outputs a special
56 * error code with the failing condition as well as potentially
57 * useful information for further debugging.
58 */
59#define ZORBA_ASSERT_WITH_MSG(COND,MSG) \
60 do { \
61 if ( !(COND) ) { \
62 std::ostringstream oss; \
63 oss << MSG; \
64 zorba::assertion_failed( #COND, __FILE__, __LINE__, oss.str().c_str() ); \
65 throw 0; /* never gets here but suppresses warning */ \
66 } \
67 } while (0)
68
47} // namespace zorba69} // namespace zorba
48#endif /* ZORBA_ASSERT_H */70#endif /* ZORBA_ASSERT_H */
49/* vim:set et sw=2 ts=2: */71/* vim:set et sw=2 ts=2: */
5072
=== modified file 'src/diagnostics/diagnostic_en.xml'
--- src/diagnostics/diagnostic_en.xml 2012-03-28 05:19:57 +0000
+++ src/diagnostics/diagnostic_en.xml 2012-04-11 09:42:23 +0000
@@ -1589,7 +1589,7 @@
1589 A Zorba programming assertion failed. If this error occurs, it is a bug1589 A Zorba programming assertion failed. If this error occurs, it is a bug
1590 and should be reported.1590 and should be reported.
1591 </comment>1591 </comment>
1592 <value>"$1": assertion failed</value>1592 <value>"$1": assertion failed.${ The following information might help: 2}</value>
1593 </diagnostic>1593 </diagnostic>
15941594
1595 <diagnostic code="ZXQP0003" name="INTERNAL_ERROR">1595 <diagnostic code="ZXQP0003" name="INTERNAL_ERROR">
15961596
=== modified file 'src/diagnostics/pregenerated/dict_en.cpp'
--- src/diagnostics/pregenerated/dict_en.cpp 2012-03-28 05:19:57 +0000
+++ src/diagnostics/pregenerated/dict_en.cpp 2012-04-11 09:42:23 +0000
@@ -392,7 +392,7 @@
392 { "ZXQD0006", "\"$1\": invalid UTF-8 byte sequence" },392 { "ZXQD0006", "\"$1\": invalid UTF-8 byte sequence" },
393 { "ZXQP0000", "no error" },393 { "ZXQP0000", "no error" },
394 { "ZXQP0001", "dynamic runtime error${: 1}" },394 { "ZXQP0001", "dynamic runtime error${: 1}" },
395 { "ZXQP0002", "\"$1\": assertion failed" },395 { "ZXQP0002", "\"$1\": assertion failed.${ The following information might help: 2}" },
396 { "ZXQP0003", "internal error${: 1}" },396 { "ZXQP0003", "internal error${: 1}" },
397 { "ZXQP0004", "not yet implemented: $1" },397 { "ZXQP0004", "not yet implemented: $1" },
398 { "ZXQP0005", "\"$1\": feature not enabled" },398 { "ZXQP0005", "\"$1\": feature not enabled" },
399399
=== modified file 'src/store/naive/ordpath.cpp'
--- src/store/naive/ordpath.cpp 2012-03-28 23:58:23 +0000
+++ src/store/naive/ordpath.cpp 2012-04-11 09:42:23 +0000
@@ -960,7 +960,14 @@
960 while (dewey1[compPos] == dewey2[compPos])960 while (dewey1[compPos] == dewey2[compPos])
961 {961 {
962 ++compPos;962 ++compPos;
963 ZORBA_ASSERT(compPos < numComps1 && compPos < numComps2);963 ZORBA_ASSERT_WITH_MSG(compPos < numComps1 && compPos < numComps2, \
964 "Involved Parameters: " \
965 << "Parent: " << parent.show().c_str() << ", " \
966 << "Sib1: " << sib1.show().c_str() << ", " \
967 << "Sib2: " << sib2.show().c_str() << ", " \
968 << "compPos: " << compPos << ", " \
969 << "numComps1: " << numComps1 << ", " \
970 << "numComps2: " << numComps2 << ".");
964 }971 }
965972
966 int32_t comp1 = dewey1[compPos];973 int32_t comp1 = dewey1[compPos];
@@ -968,7 +975,14 @@
968 bool odd1 = (comp1 % 2 != 0);975 bool odd1 = (comp1 % 2 != 0);
969 bool odd2 = (comp2 % 2 != 0);976 bool odd2 = (comp2 % 2 != 0);
970977
971 ZORBA_ASSERT(comp1 < comp2);978 ZORBA_ASSERT_WITH_MSG(comp1 < comp2, \
979 "Involved Parameters: " \
980 << "Parent: " << parent.show().c_str() << ", " \
981 << "Sib1: " << sib1.show().c_str() << ", " \
982 << "Sib2: " << sib2.show().c_str() << ", " \
983 << "comp1: " << comp1 << ", " \
984 << "comp2: " << comp2 << ", " \
985 << "compPos: " << compPos << ".");
972986
973 ulong diff = comp2 - comp1;987 ulong diff = comp2 - comp1;
974988

Subscribers

People subscribed via source and target branches