22
22
#include " asan_thread.h"
23
23
#include " sanitizer_common/sanitizer_common.h"
24
24
#include " sanitizer_common/sanitizer_dense_map.h"
25
+ #include " sanitizer_common/sanitizer_internal_defs.h"
25
26
#include " sanitizer_common/sanitizer_list.h"
26
27
#include " sanitizer_common/sanitizer_mutex.h"
27
28
#include " sanitizer_common/sanitizer_placement_new.h"
@@ -179,7 +180,7 @@ int GetGlobalsForAddress(uptr addr, Global *globals, u32 *reg_sites,
179
180
int res = 0 ;
180
181
for (const auto &l : list_of_all_globals) {
181
182
const Global &g = *l.g ;
182
- if (flags ( )->report_globals >= 2 )
183
+ if (UNLIKELY ( common_flags ( )->verbosity >= 3 ) )
183
184
ReportGlobal (g, " Search" );
184
185
if (IsAddressNearGlobal (addr, g)) {
185
186
internal_memcpy (&globals[res], &g, sizeof (g));
@@ -270,7 +271,7 @@ static inline bool UseODRIndicator(const Global *g) {
270
271
// so we store the globals in a map.
271
272
static void RegisterGlobal (const Global *g) SANITIZER_REQUIRES(mu_for_globals) {
272
273
CHECK (AsanInited ());
273
- if (flags ( )->report_globals >= 2 )
274
+ if (UNLIKELY ( common_flags ( )->verbosity >= 3 ) )
274
275
ReportGlobal (*g, " Added" );
275
276
CHECK (flags ()->report_globals );
276
277
CHECK (AddrIsInMem (g->beg ));
@@ -307,7 +308,7 @@ static void RegisterGlobal(const Global *g) SANITIZER_REQUIRES(mu_for_globals) {
307
308
static void UnregisterGlobal (const Global *g)
308
309
SANITIZER_REQUIRES(mu_for_globals) {
309
310
CHECK (AsanInited ());
310
- if (flags ( )->report_globals >= 2 )
311
+ if (UNLIKELY ( common_flags ( )->verbosity >= 3 ) )
311
312
ReportGlobal (*g, " Removed" );
312
313
CHECK (flags ()->report_globals );
313
314
CHECK (AddrIsInMem (g->beg ));
@@ -438,7 +439,7 @@ void __asan_register_globals(__asan_global *globals, uptr n) {
438
439
}
439
440
GlobalRegistrationSite site = {stack_id, &globals[0 ], &globals[n - 1 ]};
440
441
global_registration_site_vector->push_back (site);
441
- if (flags ( )->report_globals >= 2 ) {
442
+ if (UNLIKELY ( common_flags ( )->verbosity >= 3 ) ) {
442
443
PRINT_CURRENT_STACK ();
443
444
Printf (" === ID %d; %p %p\n " , stack_id, (void *)&globals[0 ],
444
445
(void *)&globals[n - 1 ]);
@@ -497,9 +498,7 @@ void __asan_before_dynamic_init(const char *module_name) {
497
498
Lock lock (&mu_for_globals);
498
499
if (current_dynamic_init_module_name == module_name)
499
500
return ;
500
- if (flags ()->report_globals >= 3 )
501
- Printf (" DynInitPoison module: %s\n " , module_name);
502
-
501
+ VPrintf (2 , " DynInitPoison module: %s\n " , module_name);
503
502
if (current_dynamic_init_module_name == nullptr ) {
504
503
// First call, poison all globals from other modules.
505
504
DynInitGlobals ().forEach ([&](auto &kv) {
@@ -545,8 +544,7 @@ static void UnpoisonBeforeMain(void) {
545
544
return ;
546
545
allow_after_dynamic_init = true ;
547
546
}
548
- if (flags ()->report_globals >= 3 )
549
- Printf (" UnpoisonBeforeMain\n " );
547
+ VPrintf (2 , " UnpoisonBeforeMain\n " );
550
548
__asan_after_dynamic_init ();
551
549
}
552
550
@@ -570,8 +568,7 @@ void __asan_after_dynamic_init() {
570
568
if (!current_dynamic_init_module_name)
571
569
return ;
572
570
573
- if (flags ()->report_globals >= 3 )
574
- Printf (" DynInitUnpoison\n " );
571
+ VPrintf (2 , " DynInitUnpoison\n " );
575
572
576
573
DynInitGlobals ().forEach ([&](auto &kv) {
577
574
UnpoisonDynamicGlobals (kv.second , /* mark_initialized=*/ false );
0 commit comments