Closed Bug 779173 Opened 12 years ago Closed 2 years ago

Add MOZ_ASSERT_PRINTF macro

Categories

(Core :: MFBT, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1338574

People

(Reporter: vlad, Unassigned)

Details

It's often very helpful to be able to print some additional info in an assertion -- for example, to assert that error == NO_ERROR, but if the assertion triggers, to actually print the error.  A new MOZ_ASSERT_PRINTF macro could handle this to avoid complicating the current assertions.  (Alternatively, the current ones could be extended.)
Extending the current ones seems like the right thing to do.
An Android implementation of MOZ_ASSERT_PRINTF can use __android_log_vprint() to print va_list parameters to logcat.

MOZ_ASSERT cannot take nsPrintfCString("%s", foo) because of:

      MOZ_REPORT_ASSERTION_FAILURE(#expr " (" explain ")", __FILE__, \
                                   __LINE__);                        \
      MOZ_CRASH_ANNOTATE(kind "(" #expr ") (" explain ")");          \

https://searchfox.org/mozilla-central/rev/3d94f040d68627d07fb06be04a05cad33cda10d4/mfbt/Assertions.h#399-401

So, I'd be really happy if we have it.

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.