RFR: 8149591 - Prepare hotspot for GTest
Kim Barrett
kim.barrett at oracle.com
Thu Feb 11 01:01:26 UTC 2016
> On Feb 10, 2016, at 7:34 PM, Jesper Wilhelmsson <jesper.wilhelmsson at oracle.com> wrote:
>
> Den 11/2/16 kl. 00:40, skrev Kim Barrett:
>>> 2. In management.cpp there is a local variable called err_msg. This variable is shadowing a global variable in debug.hpp. In the GTest work the global err_msg variable is used in the vmassert macro and this creates a conflict with the local variable in management.cpp.
>>
>> Where does this happen? The current vmassert macro doesn't use err_msg.
>>
>> A better way to address this might be to fix the problematic macro.
>> For safety, macros whose expansions refer to some namespace-scoped
>> name should qualify the reference.
>
> The vmassert macro looks like this with the GTest changes applied:
>
> #define vmassert(p, ...) \
> do { \
> if (!(p)) { \
> if (is_executing_unit_tests()) { \
> report_assert_msg(err_msg(__VA_ARGS__).buffer()); \
> } \
> report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", __VA_ARGS__); \
> BREAKPOINT; \
> } \
> } while (0)
>
> This is done so that the framework can pick up the assertion when running "death tests" - tests that are supposed to trigger an assertion.
>
> If there is a better way to implement this I'm open to any suggestions.
Why not replace
report_assert_msg(err_msg(__VA_ARGS__).buffer())
with
report_assert_msg(__VA_ARGS__)
Unless report_assert_msg is not provided by us, but is instead part of
the gtest framework. In that case, we provide a variadic wrapper
around report_assert_msg and call that wrapper in the vmassert
expansion.
Note that I think it might be good to split up debug.hpp, moving all
the FormatBuffer stuff to a separate header. (I've been intending to
submit an RFE for this.) With David's changes to use variadic macros,
the macros no longer need to refer to FormatBuffer stuff in their
expansions. Such a split would make debug.hpp standalone and not need
to include, for example, globalDefinitions.hpp. One benefit of that
would be that globalDefinitions.hpp could then include debug.hpp in
order to use vmassert, rather than using kludges.
More information about the hotspot-dev
mailing list