MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / code_state

Function code_state

dbug/dbug.c:368–404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

366static rw_lock_t THR_LOCK_init_settings;
367
368static CODE_STATE *code_state(void)
369{
370 CODE_STATE *cs, **cs_ptr;
371
372 /*
373 _dbug_on_ is reset if we don't plan to use any debug commands at all and
374 we want to run on maximum speed
375 */
376 if (!_dbug_on_)
377 return 0;
378
379 if (!init_done)
380 {
381 init_done=TRUE;
382 pthread_mutex_init(&THR_LOCK_dbug, NULL);
383 pthread_mutex_init(&THR_LOCK_gcov, NULL);
384 my_rwlock_init(&THR_LOCK_init_settings, NULL);
385 memset(&init_settings, 0, sizeof(init_settings));
386 init_settings.out_file=stderr;
387 init_settings.flags=OPEN_APPEND;
388 }
389
390 if (!(cs_ptr= (CODE_STATE**) my_thread_var_dbug()))
391 return 0; /* Thread not initialised */
392 if (!(cs= *cs_ptr))
393 {
394 cs=(CODE_STATE*) DbugMalloc(sizeof(*cs));
395 memset(cs, 0, sizeof(*cs));
396 cs->process= db_process ? db_process : "dbug";
397 cs->func="?func";
398 cs->file="?file";
399 cs->stack=&init_settings;
400 cs->m_read_lock_count= 0;
401 *cs_ptr= cs;
402 }
403 return cs;
404}
405
406/**
407 Lock the stack debugging settings.

Callers 2

_db_enter_Function · 0.85
DbugExitFunction · 0.85

Calls 2

my_thread_var_dbugFunction · 0.85
DbugMallocFunction · 0.85

Tested by

no test coverage detected