Roxen.git / server / base_server / roxen.pike

version» Context lines:

Roxen.git/server/base_server/roxen.pike:145:   // thus is skipped here.   array(string) compat_levels = ({"2.1", "2.2", "2.4", "2.5",    "3.3", "3.4",    "4.0", "4.5",    "5.0", "5.1", "5.2", "5.4", "5.5",    "6.0",   });      #ifdef THREADS   mapping(string:string) thread_names = ([]); +  + string thread_name_from_addr(string hex_addr) + { +  // Lookup using a key like "Thread.Thread(0x...)" that matches what +  // sprint("%O") generates. +  string th_key = "Thread.Thread(" + hex_addr + ")"; +  return thread_names[th_key]; + } +    string thread_name( object thread, int|void skip_auto_name )   {    string tn;    if( thread_names[ tn=sprintf("%O",thread) ] || skip_auto_name )    return thread_names[tn];    return tn;   }      void name_thread( object thread, string name )   {
Roxen.git/server/base_server/roxen.pike:6340:    if (string th_name = thread_name(thread, 1))    thread_descr += " - " + th_name;    if (int start_hrtime = thread_task_start_times[thread])    thread_descr += sprintf (" - busy for %.3fs",    (hrnow - start_hrtime) / 1e6);    report_debug(">> ### Thread 0x%x%s:\n",    thread->id_number(),    thread_descr);    // Use master()->describe_backtrace to sidestep the background    // failure wrapper that's active in RUN_SELF_TEST. -  report_debug(">> " + -  replace (master()->describe_backtrace (thread->backtrace()), -  "\n", "\n>> ") + -  "\n"); +  string th_bt = master()->describe_backtrace (thread->backtrace()); +  +  // Expand any occurrences of: +  // Thread.Mutex(/*locked by 0x....*/) +  // to: +  // Thread.Mutex(/*locked by 0x.... - <thread name>*/) +  string bt_separator = "Thread.Mutex(/*locked by "; +  if (has_value(th_bt, bt_separator)) { +  array(string) bt_segs = th_bt / bt_separator; +  if (sizeof(bt_segs) > 1) { +  foreach (bt_segs; int idx; string bt_seg) { +  if (sscanf(bt_seg, "0x%[0-9a-fA-F]*/", string th_hex_addr)) { +  if (string th_name = thread_name_from_addr("0x" + th_hex_addr)) { +  bt_segs[idx] = +  "0x" + th_hex_addr + " - " + th_name + +  bt_seg[sizeof(th_hex_addr) + 2..];    } -  +  } +  } +  th_bt = bt_segs * bt_separator; +  } +  }    -  +  report_debug(">> " + replace (th_bt, "\n", "\n>> ") + "\n"); + } +    // Dump all threads to the debug log.   void describe_all_threads (void|int ignored, // Might be the signal number.    void|int(0..1) inhibit_threads_disabled)   {    object threads_disabled;    if (!inhibit_threads_disabled)    // Disable all threads to avoid potential locking problems while we    // have the backtraces. It also gives an atomic view of the state.    threads_disabled = _disable_threads();