LLDB  mainline
SystemRuntimeMacOSX.cpp
Go to the documentation of this file.
1 //===-- SystemRuntimeMacOSX.cpp -------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
12 #include "lldb/Core/Module.h"
13 #include "lldb/Core/ModuleSpec.h"
15 #include "lldb/Core/Section.h"
16 #include "lldb/Symbol/ObjectFile.h"
18 #include "lldb/Target/Process.h"
20 #include "lldb/Target/Queue.h"
21 #include "lldb/Target/QueueList.h"
22 #include "lldb/Target/Target.h"
23 #include "lldb/Target/Thread.h"
26 #include "lldb/Utility/FileSpec.h"
27 #include "lldb/Utility/LLDBLog.h"
28 #include "lldb/Utility/Log.h"
30 
31 #include "SystemRuntimeMacOSX.h"
32 
33 #include <memory>
34 
35 using namespace lldb;
36 using namespace lldb_private;
37 
39 
40 // Create an instance of this class. This function is filled into the plugin
41 // info class that gets handed out by the plugin factory and allows the lldb to
42 // instantiate an instance of this class.
43 SystemRuntime *SystemRuntimeMacOSX::CreateInstance(Process *process) {
44  bool create = false;
45  if (!create) {
46  create = true;
47  Module *exe_module = process->GetTarget().GetExecutableModulePointer();
48  if (exe_module) {
49  ObjectFile *object_file = exe_module->GetObjectFile();
50  if (object_file) {
51  create = (object_file->GetStrata() == ObjectFile::eStrataUser);
52  }
53  }
54 
55  if (create) {
56  const llvm::Triple &triple_ref =
57  process->GetTarget().GetArchitecture().GetTriple();
58  switch (triple_ref.getOS()) {
59  case llvm::Triple::Darwin:
60  case llvm::Triple::MacOSX:
61  case llvm::Triple::IOS:
62  case llvm::Triple::TvOS:
63  case llvm::Triple::WatchOS:
64  // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
65  create = triple_ref.getVendor() == llvm::Triple::Apple;
66  break;
67  default:
68  create = false;
69  break;
70  }
71  }
72  }
73 
74  if (create)
75  return new SystemRuntimeMacOSX(process);
76  return nullptr;
77 }
78 
79 // Constructor
81  : SystemRuntime(process), m_break_id(LLDB_INVALID_BREAK_ID), m_mutex(),
82  m_get_queues_handler(process), m_get_pending_items_handler(process),
83  m_get_item_info_handler(process), m_get_thread_item_info_handler(process),
84  m_page_to_free(LLDB_INVALID_ADDRESS), m_page_to_free_size(0),
85  m_lib_backtrace_recording_info(),
86  m_dispatch_queue_offsets_addr(LLDB_INVALID_ADDRESS),
87  m_libdispatch_offsets(),
88  m_libpthread_layout_offsets_addr(LLDB_INVALID_ADDRESS),
89  m_libpthread_offsets(), m_dispatch_tsd_indexes_addr(LLDB_INVALID_ADDRESS),
90  m_libdispatch_tsd_indexes(),
91  m_dispatch_voucher_offsets_addr(LLDB_INVALID_ADDRESS),
92  m_libdispatch_voucher_offsets() {}
93 
94 // Destructor
96 
102 }
103 
104 // Clear out the state of this class.
105 void SystemRuntimeMacOSX::Clear(bool clear_process) {
106  std::lock_guard<std::recursive_mutex> guard(m_mutex);
107 
110 
111  if (clear_process)
112  m_process = nullptr;
114 }
115 
118  std::string dispatch_queue_name;
119  if (dispatch_qaddr == LLDB_INVALID_ADDRESS || dispatch_qaddr == 0)
120  return "";
121 
124  // dispatch_qaddr is from a thread_info(THREAD_IDENTIFIER_INFO) call for a
125  // thread - deref it to get the address of the dispatch_queue_t structure
126  // for this thread's queue.
127  Status error;
128  addr_t dispatch_queue_addr =
129  m_process->ReadPointerFromMemory(dispatch_qaddr, error);
130  if (error.Success()) {
132  // libdispatch versions 4+, pointer to dispatch name is in the queue
133  // structure.
134  addr_t pointer_to_label_address =
135  dispatch_queue_addr + m_libdispatch_offsets.dqo_label;
136  addr_t label_addr =
137  m_process->ReadPointerFromMemory(pointer_to_label_address, error);
138  if (error.Success()) {
139  m_process->ReadCStringFromMemory(label_addr, dispatch_queue_name,
140  error);
141  }
142  } else {
143  // libdispatch versions 1-3, dispatch name is a fixed width char array
144  // in the queue structure.
145  addr_t label_addr =
146  dispatch_queue_addr + m_libdispatch_offsets.dqo_label;
147  dispatch_queue_name.resize(m_libdispatch_offsets.dqo_label_size, '\0');
148  size_t bytes_read =
149  m_process->ReadMemory(label_addr, &dispatch_queue_name[0],
151  if (bytes_read < m_libdispatch_offsets.dqo_label_size)
152  dispatch_queue_name.erase(bytes_read);
153  }
154  }
155  }
156  return dispatch_queue_name;
157 }
158 
160  addr_t dispatch_qaddr) {
161  addr_t libdispatch_queue_t_address = LLDB_INVALID_ADDRESS;
162  Status error;
163  libdispatch_queue_t_address =
164  m_process->ReadPointerFromMemory(dispatch_qaddr, error);
165  if (!error.Success()) {
166  libdispatch_queue_t_address = LLDB_INVALID_ADDRESS;
167  }
168  return libdispatch_queue_t_address;
169 }
170 
172  if (dispatch_queue_addr == LLDB_INVALID_ADDRESS || dispatch_queue_addr == 0)
173  return eQueueKindUnknown;
174 
179  Status error;
180  uint64_t width = m_process->ReadUnsignedIntegerFromMemory(
181  dispatch_queue_addr + m_libdispatch_offsets.dqo_width,
183  if (error.Success()) {
184  if (width == 1) {
185  kind = eQueueKindSerial;
186  }
187  if (width > 1) {
188  kind = eQueueKindConcurrent;
189  }
190  }
191  }
192  return kind;
193 }
194 
197  StructuredData::Dictionary *dict = dict_sp->GetAsDictionary();
198  if (dict) {
201  dict->AddIntegerItem("plo_pthread_tsd_base_offset",
203  dict->AddIntegerItem(
204  "plo_pthread_tsd_base_address_offset",
206  dict->AddIntegerItem("plo_pthread_tsd_entry_size",
208  }
209 
212  dict->AddIntegerItem("dti_queue_index",
214  dict->AddIntegerItem("dti_voucher_index",
216  dict->AddIntegerItem("dti_qos_class_index",
218  }
219  }
220 }
221 
223  if (thread_sp && thread_sp->GetStackFrameCount() > 0 &&
224  thread_sp->GetFrameWithConcreteFrameIndex(0)) {
225  const SymbolContext sym_ctx(
226  thread_sp->GetFrameWithConcreteFrameIndex(0)->GetSymbolContext(
227  eSymbolContextSymbol));
228  static ConstString g_select_symbol("__select");
229  if (sym_ctx.GetFunctionName() == g_select_symbol) {
230  return false;
231  }
232  }
233  return true;
234 }
235 
239 
240  if (dispatch_qaddr == LLDB_INVALID_ADDRESS || dispatch_qaddr == 0)
241  return queue_id;
242 
245  // dispatch_qaddr is from a thread_info(THREAD_IDENTIFIER_INFO) call for a
246  // thread - deref it to get the address of the dispatch_queue_t structure
247  // for this thread's queue.
248  Status error;
249  uint64_t dispatch_queue_addr =
250  m_process->ReadPointerFromMemory(dispatch_qaddr, error);
251  if (error.Success()) {
252  addr_t serialnum_address =
253  dispatch_queue_addr + m_libdispatch_offsets.dqo_serialnum;
255  serialnum_address, m_libdispatch_offsets.dqo_serialnum_size,
257  if (error.Success()) {
258  queue_id = serialnum;
259  }
260  }
261  }
262 
263  return queue_id;
264 }
265 
268  return;
269 
270  static ConstString g_dispatch_queue_offsets_symbol_name(
271  "dispatch_queue_offsets");
272  const Symbol *dispatch_queue_offsets_symbol = nullptr;
273 
274  // libdispatch symbols were in libSystem.B.dylib up through Mac OS X 10.6
275  // ("Snow Leopard")
276  ModuleSpec libSystem_module_spec(FileSpec("libSystem.B.dylib"));
277  ModuleSP module_sp(m_process->GetTarget().GetImages().FindFirstModule(
278  libSystem_module_spec));
279  if (module_sp)
280  dispatch_queue_offsets_symbol = module_sp->FindFirstSymbolWithNameAndType(
281  g_dispatch_queue_offsets_symbol_name, eSymbolTypeData);
282 
283  // libdispatch symbols are in their own dylib as of Mac OS X 10.7 ("Lion")
284  // and later
285  if (dispatch_queue_offsets_symbol == nullptr) {
286  ModuleSpec libdispatch_module_spec(FileSpec("libdispatch.dylib"));
287  module_sp = m_process->GetTarget().GetImages().FindFirstModule(
288  libdispatch_module_spec);
289  if (module_sp)
290  dispatch_queue_offsets_symbol = module_sp->FindFirstSymbolWithNameAndType(
291  g_dispatch_queue_offsets_symbol_name, eSymbolTypeData);
292  }
293  if (dispatch_queue_offsets_symbol)
295  dispatch_queue_offsets_symbol->GetLoadAddress(&m_process->GetTarget());
296 }
297 
300  return;
301 
303 
304  uint8_t memory_buffer[sizeof(struct LibdispatchOffsets)];
305  DataExtractor data(memory_buffer, sizeof(memory_buffer),
308 
309  Status error;
311  sizeof(memory_buffer),
312  error) == sizeof(memory_buffer)) {
313  lldb::offset_t data_offset = 0;
314 
315  // The struct LibdispatchOffsets is a series of uint16_t's - extract them
316  // all in one big go.
317  data.GetU16(&data_offset, &m_libdispatch_offsets.dqo_version,
318  sizeof(struct LibdispatchOffsets) / sizeof(uint16_t));
319  }
320 }
321 
324  return;
325 
326  static ConstString g_libpthread_layout_offsets_symbol_name(
327  "pthread_layout_offsets");
328  const Symbol *libpthread_layout_offsets_symbol = nullptr;
329 
330  ModuleSpec libpthread_module_spec(FileSpec("libsystem_pthread.dylib"));
331  ModuleSP module_sp(m_process->GetTarget().GetImages().FindFirstModule(
332  libpthread_module_spec));
333  if (module_sp) {
334  libpthread_layout_offsets_symbol =
335  module_sp->FindFirstSymbolWithNameAndType(
336  g_libpthread_layout_offsets_symbol_name, eSymbolTypeData);
337  if (libpthread_layout_offsets_symbol) {
339  libpthread_layout_offsets_symbol->GetLoadAddress(
340  &m_process->GetTarget());
341  }
342  }
343 }
344 
347  return;
348 
350 
352  uint8_t memory_buffer[sizeof(struct LibpthreadOffsets)];
353  DataExtractor data(memory_buffer, sizeof(memory_buffer),
356  Status error;
358  sizeof(memory_buffer),
359  error) == sizeof(memory_buffer)) {
360  lldb::offset_t data_offset = 0;
361 
362  // The struct LibpthreadOffsets is a series of uint16_t's - extract them
363  // all in one big go.
364  data.GetU16(&data_offset, &m_libpthread_offsets.plo_version,
365  sizeof(struct LibpthreadOffsets) / sizeof(uint16_t));
366  }
367  }
368 }
369 
372  return;
373 
374  static ConstString g_libdispatch_tsd_indexes_symbol_name(
375  "dispatch_tsd_indexes");
376  const Symbol *libdispatch_tsd_indexes_symbol = nullptr;
377 
378  ModuleSpec libpthread_module_spec(FileSpec("libdispatch.dylib"));
379  ModuleSP module_sp(m_process->GetTarget().GetImages().FindFirstModule(
380  libpthread_module_spec));
381  if (module_sp) {
382  libdispatch_tsd_indexes_symbol = module_sp->FindFirstSymbolWithNameAndType(
383  g_libdispatch_tsd_indexes_symbol_name, eSymbolTypeData);
384  if (libdispatch_tsd_indexes_symbol) {
386  libdispatch_tsd_indexes_symbol->GetLoadAddress(
387  &m_process->GetTarget());
388  }
389  }
390 }
391 
394  return;
395 
397 
399 
400 // We don't need to check the version number right now, it will be at least 2,
401 // but keep this code around to fetch just the version # for the future where
402 // we need to fetch alternate versions of the struct.
403 #if 0
404  uint16_t dti_version = 2;
405  Address dti_struct_addr;
407  {
408  Status error;
409  uint16_t version = m_process->GetTarget().ReadUnsignedIntegerFromMemory (dti_struct_addr, false, 2, UINT16_MAX, error);
410  if (error.Success() && dti_version != UINT16_MAX)
411  {
412  dti_version = version;
413  }
414  }
415 #endif
416 
417  TypeSystemClang *ast_ctx =
418  ScratchTypeSystemClang::GetForTarget(m_process->GetTarget());
420  CompilerType uint16 =
422  CompilerType dispatch_tsd_indexes_s = ast_ctx->CreateRecordType(
424  "__lldb_dispatch_tsd_indexes_s", clang::TTK_Struct,
426 
427  TypeSystemClang::StartTagDeclarationDefinition(dispatch_tsd_indexes_s);
428  TypeSystemClang::AddFieldToRecordType(dispatch_tsd_indexes_s,
429  "dti_version", uint16,
431  TypeSystemClang::AddFieldToRecordType(dispatch_tsd_indexes_s,
432  "dti_queue_index", uint16,
434  TypeSystemClang::AddFieldToRecordType(dispatch_tsd_indexes_s,
435  "dti_voucher_index", uint16,
437  TypeSystemClang::AddFieldToRecordType(dispatch_tsd_indexes_s,
438  "dti_qos_class_index", uint16,
440  TypeSystemClang::CompleteTagDeclarationDefinition(dispatch_tsd_indexes_s);
441 
443  dispatch_tsd_indexes_s);
444 
446  struct_reader.GetField<uint16_t>(ConstString("dti_version"));
448  struct_reader.GetField<uint16_t>(ConstString("dti_queue_index"));
450  struct_reader.GetField<uint16_t>(ConstString("dti_voucher_index"));
452  struct_reader.GetField<uint16_t>(ConstString("dti_qos_class_index"));
453  }
454  }
455 }
456 
458  ConstString type) {
459  ThreadSP originating_thread_sp;
460  if (BacktraceRecordingHeadersInitialized() && type == "libdispatch") {
461  Status error;
462 
463  // real_thread is either an actual, live thread (in which case we need to
464  // call into libBacktraceRecording to find its originator) or it is an
465  // extended backtrace itself, in which case we get the token from it and
466  // call into libBacktraceRecording to find the originator of that token.
467 
468  if (real_thread->GetExtendedBacktraceToken() != LLDB_INVALID_ADDRESS) {
469  originating_thread_sp = GetExtendedBacktraceFromItemRef(
470  real_thread->GetExtendedBacktraceToken());
471  } else {
472  ThreadSP cur_thread_sp(
476  *cur_thread_sp.get(), real_thread->GetID(), m_page_to_free,
480  if (ret.item_buffer_ptr != 0 &&
482  ret.item_buffer_size > 0) {
483  DataBufferHeap data(ret.item_buffer_size, 0);
484  if (m_process->ReadMemory(ret.item_buffer_ptr, data.GetBytes(),
485  ret.item_buffer_size, error) &&
486  error.Success()) {
487  DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
490  ItemInfo item = ExtractItemInfoFromBuffer(extractor);
491  originating_thread_sp = std::make_shared<HistoryThread>(
493  originating_thread_sp->SetExtendedBacktraceToken(
495  originating_thread_sp->SetQueueName(
496  item.enqueuing_queue_label.c_str());
497  originating_thread_sp->SetQueueID(item.enqueuing_queue_serialnum);
498  // originating_thread_sp->SetThreadName
499  // (item.enqueuing_thread_label.c_str());
500  }
503  }
504  }
505  }
506  return originating_thread_sp;
507 }
508 
509 ThreadSP
511  ThreadSP return_thread_sp;
512 
514  ThreadSP cur_thread_sp(
516  Status error;
517  ret = m_get_item_info_handler.GetItemInfo(*cur_thread_sp.get(), item_ref,
519  error);
522  if (ret.item_buffer_ptr != 0 && ret.item_buffer_ptr != LLDB_INVALID_ADDRESS &&
523  ret.item_buffer_size > 0) {
524  DataBufferHeap data(ret.item_buffer_size, 0);
525  if (m_process->ReadMemory(ret.item_buffer_ptr, data.GetBytes(),
526  ret.item_buffer_size, error) &&
527  error.Success()) {
528  DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
531  ItemInfo item = ExtractItemInfoFromBuffer(extractor);
532  return_thread_sp = std::make_shared<HistoryThread>(
534  return_thread_sp->SetExtendedBacktraceToken(item.item_that_enqueued_this);
535  return_thread_sp->SetQueueName(item.enqueuing_queue_label.c_str());
536  return_thread_sp->SetQueueID(item.enqueuing_queue_serialnum);
537  // return_thread_sp->SetThreadName
538  // (item.enqueuing_thread_label.c_str());
539 
542  }
543  }
544  return return_thread_sp;
545 }
546 
547 ThreadSP
549  ConstString type) {
550  ThreadSP extended_thread_sp;
551  if (type != "libdispatch")
552  return extended_thread_sp;
553 
554  extended_thread_sp = std::make_shared<HistoryThread>(
555  *m_process, queue_item_sp->GetEnqueueingThreadID(),
556  queue_item_sp->GetEnqueueingBacktrace());
557  extended_thread_sp->SetExtendedBacktraceToken(
558  queue_item_sp->GetItemThatEnqueuedThis());
559  extended_thread_sp->SetQueueName(queue_item_sp->GetQueueLabel().c_str());
560  extended_thread_sp->SetQueueID(queue_item_sp->GetEnqueueingQueueID());
561  // extended_thread_sp->SetThreadName
562  // (queue_item_sp->GetThreadLabel().c_str());
563 
564  return extended_thread_sp;
565 }
566 
567 /* Returns true if we were able to get the version / offset information
568  * out of libBacktraceRecording. false means we were unable to retrieve
569  * this; the queue_info_version field will be 0.
570  */
571 
574  return true;
575 
576  addr_t queue_info_version_address = LLDB_INVALID_ADDRESS;
577  addr_t queue_info_data_offset_address = LLDB_INVALID_ADDRESS;
578  addr_t item_info_version_address = LLDB_INVALID_ADDRESS;
579  addr_t item_info_data_offset_address = LLDB_INVALID_ADDRESS;
580  Target &target = m_process->GetTarget();
581 
582  static ConstString introspection_dispatch_queue_info_version(
583  "__introspection_dispatch_queue_info_version");
584  SymbolContextList sc_list;
586  introspection_dispatch_queue_info_version, eSymbolTypeData, sc_list);
587  if (!sc_list.IsEmpty()) {
588  SymbolContext sc;
589  sc_list.GetContextAtIndex(0, sc);
590  AddressRange addr_range;
591  sc.GetAddressRange(eSymbolContextSymbol, 0, false, addr_range);
592  queue_info_version_address =
593  addr_range.GetBaseAddress().GetLoadAddress(&target);
594  }
595  sc_list.Clear();
596 
597  static ConstString introspection_dispatch_queue_info_data_offset(
598  "__introspection_dispatch_queue_info_data_offset");
600  introspection_dispatch_queue_info_data_offset, eSymbolTypeData, sc_list);
601  if (!sc_list.IsEmpty()) {
602  SymbolContext sc;
603  sc_list.GetContextAtIndex(0, sc);
604  AddressRange addr_range;
605  sc.GetAddressRange(eSymbolContextSymbol, 0, false, addr_range);
606  queue_info_data_offset_address =
607  addr_range.GetBaseAddress().GetLoadAddress(&target);
608  }
609  sc_list.Clear();
610 
611  static ConstString introspection_dispatch_item_info_version(
612  "__introspection_dispatch_item_info_version");
614  introspection_dispatch_item_info_version, eSymbolTypeData, sc_list);
615  if (!sc_list.IsEmpty()) {
616  SymbolContext sc;
617  sc_list.GetContextAtIndex(0, sc);
618  AddressRange addr_range;
619  sc.GetAddressRange(eSymbolContextSymbol, 0, false, addr_range);
620  item_info_version_address =
621  addr_range.GetBaseAddress().GetLoadAddress(&target);
622  }
623  sc_list.Clear();
624 
625  static ConstString introspection_dispatch_item_info_data_offset(
626  "__introspection_dispatch_item_info_data_offset");
628  introspection_dispatch_item_info_data_offset, eSymbolTypeData, sc_list);
629  if (!sc_list.IsEmpty()) {
630  SymbolContext sc;
631  sc_list.GetContextAtIndex(0, sc);
632  AddressRange addr_range;
633  sc.GetAddressRange(eSymbolContextSymbol, 0, false, addr_range);
634  item_info_data_offset_address =
635  addr_range.GetBaseAddress().GetLoadAddress(&target);
636  }
637 
638  if (queue_info_version_address != LLDB_INVALID_ADDRESS &&
639  queue_info_data_offset_address != LLDB_INVALID_ADDRESS &&
640  item_info_version_address != LLDB_INVALID_ADDRESS &&
641  item_info_data_offset_address != LLDB_INVALID_ADDRESS) {
642  Status error;
644  m_process->ReadUnsignedIntegerFromMemory(queue_info_version_address, 2,
645  0, error);
646  if (error.Success()) {
649  queue_info_data_offset_address, 2, 0, error);
650  if (error.Success()) {
652  m_process->ReadUnsignedIntegerFromMemory(item_info_version_address,
653  2, 0, error);
654  if (error.Success()) {
657  item_info_data_offset_address, 2, 0, error);
658  if (!error.Success()) {
660  }
661  } else {
663  }
664  } else {
666  }
667  }
668  }
669 
671 }
672 
673 const std::vector<ConstString> &
675  if (m_types.size() == 0) {
676  m_types.push_back(ConstString("libdispatch"));
677  // We could have pthread as another type in the future if we have a way of
678  // gathering that information & it's useful to distinguish between them.
679  }
680  return m_types;
681 }
682 
684  lldb_private::QueueList &queue_list) {
687  ThreadSP cur_thread_sp(
689  if (cur_thread_sp) {
690  Status error;
691  queue_info_pointer = m_get_queues_handler.GetCurrentQueues(
692  *cur_thread_sp.get(), m_page_to_free, m_page_to_free_size, error);
695  if (error.Success()) {
696 
697  if (queue_info_pointer.count > 0 &&
698  queue_info_pointer.queues_buffer_size > 0 &&
699  queue_info_pointer.queues_buffer_ptr != 0 &&
700  queue_info_pointer.queues_buffer_ptr != LLDB_INVALID_ADDRESS) {
701  PopulateQueuesUsingLibBTR(queue_info_pointer.queues_buffer_ptr,
702  queue_info_pointer.queues_buffer_size,
703  queue_info_pointer.count, queue_list);
704  }
705  }
706  }
707  }
708 
709  // We either didn't have libBacktraceRecording (and need to create the queues
710  // list based on threads) or we did get the queues list from
711  // libBacktraceRecording but some special queues may not be included in its
712  // information. This is needed because libBacktraceRecording will only list
713  // queues with pending or running items by default - but the magic com.apple
714  // .main-thread queue on thread 1 is always around.
715 
716  for (ThreadSP thread_sp : m_process->Threads()) {
717  if (thread_sp->GetAssociatedWithLibdispatchQueue() != eLazyBoolNo) {
718  if (thread_sp->GetQueueID() != LLDB_INVALID_QUEUE_ID) {
719  if (queue_list.FindQueueByID(thread_sp->GetQueueID()).get() ==
720  nullptr) {
721  QueueSP queue_sp(new Queue(m_process->shared_from_this(),
722  thread_sp->GetQueueID(),
723  thread_sp->GetQueueName()));
724  if (thread_sp->ThreadHasQueueInformation()) {
725  queue_sp->SetKind(thread_sp->GetQueueKind());
726  queue_sp->SetLibdispatchQueueAddress(
727  thread_sp->GetQueueLibdispatchQueueAddress());
728  queue_list.AddQueue(queue_sp);
729  } else {
730  queue_sp->SetKind(
731  GetQueueKind(thread_sp->GetQueueLibdispatchQueueAddress()));
732  queue_sp->SetLibdispatchQueueAddress(
733  thread_sp->GetQueueLibdispatchQueueAddress());
734  queue_list.AddQueue(queue_sp);
735  }
736  }
737  }
738  }
739  }
740 }
741 
742 // Returns either an array of introspection_dispatch_item_info_ref's for the
743 // pending items on a queue or an array introspection_dispatch_item_info_ref's
744 // and code addresses for the pending items on a queue. The information about
745 // each of these pending items then needs to be fetched individually by passing
746 // the ref to libBacktraceRecording.
747 
750  PendingItemsForQueue pending_item_refs;
752  ThreadSP cur_thread_sp(
754  if (cur_thread_sp) {
755  Status error;
756  pending_items_pointer = m_get_pending_items_handler.GetPendingItems(
757  *cur_thread_sp.get(), queue, m_page_to_free, m_page_to_free_size,
758  error);
761  if (error.Success()) {
762  if (pending_items_pointer.count > 0 &&
763  pending_items_pointer.items_buffer_size > 0 &&
764  pending_items_pointer.items_buffer_ptr != 0 &&
765  pending_items_pointer.items_buffer_ptr != LLDB_INVALID_ADDRESS) {
766  DataBufferHeap data(pending_items_pointer.items_buffer_size, 0);
767  if (m_process->ReadMemory(
768  pending_items_pointer.items_buffer_ptr, data.GetBytes(),
769  pending_items_pointer.items_buffer_size, error)) {
770  DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
773 
774  // We either have an array of
775  // void* item_ref
776  // (old style) or we have a structure returned which looks like
777  //
778  // struct introspection_dispatch_pending_item_info_s {
779  // void *item_ref;
780  // void *function_or_block;
781  // };
782  //
783  // struct introspection_dispatch_pending_items_array_s {
784  // uint32_t version;
785  // uint32_t size_of_item_info;
786  // introspection_dispatch_pending_item_info_s items[];
787  // }
788 
789  offset_t offset = 0;
790  int i = 0;
791  uint32_t version = extractor.GetU32(&offset);
792  if (version == 1) {
793  pending_item_refs.new_style = true;
794  uint32_t item_size = extractor.GetU32(&offset);
795  uint32_t start_of_array_offset = offset;
796  while (offset < pending_items_pointer.items_buffer_size &&
797  static_cast<size_t>(i) < pending_items_pointer.count) {
798  offset = start_of_array_offset + (i * item_size);
800  item.item_ref = extractor.GetAddress(&offset);
801  item.code_address = extractor.GetAddress(&offset);
802  pending_item_refs.item_refs_and_code_addresses.push_back(item);
803  i++;
804  }
805  } else {
806  offset = 0;
807  pending_item_refs.new_style = false;
808  while (offset < pending_items_pointer.items_buffer_size &&
809  static_cast<size_t>(i) < pending_items_pointer.count) {
811  item.item_ref = extractor.GetAddress(&offset);
813  pending_item_refs.item_refs_and_code_addresses.push_back(item);
814  i++;
815  }
816  }
817  }
818  m_page_to_free = pending_items_pointer.items_buffer_ptr;
819  m_page_to_free_size = pending_items_pointer.items_buffer_size;
820  }
821  }
822  }
823  return pending_item_refs;
824 }
825 
828  PendingItemsForQueue pending_item_refs =
830  for (ItemRefAndCodeAddress pending_item :
831  pending_item_refs.item_refs_and_code_addresses) {
832  Address addr;
834  addr);
835  QueueItemSP queue_item_sp(new QueueItem(queue->shared_from_this(),
836  m_process->shared_from_this(),
837  pending_item.item_ref, addr));
838  queue->PushPendingQueueItem(queue_item_sp);
839  }
840  }
841 }
842 
844  addr_t item_ref) {
846 
847  ThreadSP cur_thread_sp(
849  Status error;
850  ret = m_get_item_info_handler.GetItemInfo(*cur_thread_sp.get(), item_ref,
852  error);
855  if (ret.item_buffer_ptr != 0 && ret.item_buffer_ptr != LLDB_INVALID_ADDRESS &&
856  ret.item_buffer_size > 0) {
857  DataBufferHeap data(ret.item_buffer_size, 0);
858  if (m_process->ReadMemory(ret.item_buffer_ptr, data.GetBytes(),
859  ret.item_buffer_size, error) &&
860  error.Success()) {
861  DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
864  ItemInfo item = ExtractItemInfoFromBuffer(extractor);
866  queue_item->SetEnqueueingThreadID(item.enqueuing_thread_id);
868  queue_item->SetStopID(item.stop_id);
870  queue_item->SetThreadLabel(item.enqueuing_thread_label);
871  queue_item->SetQueueLabel(item.enqueuing_queue_label);
872  queue_item->SetTargetQueueLabel(item.target_queue_label);
873  }
876  }
877 }
878 
880  lldb::addr_t queues_buffer, uint64_t queues_buffer_size, uint64_t count,
881  lldb_private::QueueList &queue_list) {
882  Status error;
883  DataBufferHeap data(queues_buffer_size, 0);
884  Log *log = GetLog(LLDBLog::SystemRuntime);
885  if (m_process->ReadMemory(queues_buffer, data.GetBytes(), queues_buffer_size,
886  error) == queues_buffer_size &&
887  error.Success()) {
888  // We've read the information out of inferior memory; free it on the next
889  // call we make
890  m_page_to_free = queues_buffer;
891  m_page_to_free_size = queues_buffer_size;
892 
893  DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
896  offset_t offset = 0;
897  uint64_t queues_read = 0;
898 
899  // The information about the queues is stored in this format (v1): typedef
900  // struct introspection_dispatch_queue_info_s {
901  // uint32_t offset_to_next;
902  // dispatch_queue_t queue;
903  // uint64_t serialnum; // queue's serialnum in the process, as
904  // provided by libdispatch
905  // uint32_t running_work_items_count;
906  // uint32_t pending_work_items_count;
907  //
908  // char data[]; // Starting here, we have variable-length data:
909  // // char queue_label[];
910  // } introspection_dispatch_queue_info_s;
911 
912  while (queues_read < count && offset < queues_buffer_size) {
913  offset_t start_of_this_item = offset;
914 
915  uint32_t offset_to_next = extractor.GetU32(&offset);
916 
917  offset += 4; // Skip over the 4 bytes of reserved space
918  addr_t queue = extractor.GetAddress(&offset);
919  uint64_t serialnum = extractor.GetU64(&offset);
920  uint32_t running_work_items_count = extractor.GetU32(&offset);
921  uint32_t pending_work_items_count = extractor.GetU32(&offset);
922 
923  // Read the first field of the variable length data
924  offset = start_of_this_item +
926  const char *queue_label = extractor.GetCStr(&offset);
927  if (queue_label == nullptr)
928  queue_label = "";
929 
930  offset_t start_of_next_item = start_of_this_item + offset_to_next;
931  offset = start_of_next_item;
932 
933  LLDB_LOGF(log,
934  "SystemRuntimeMacOSX::PopulateQueuesUsingLibBTR added "
935  "queue with dispatch_queue_t 0x%" PRIx64
936  ", serial number 0x%" PRIx64
937  ", running items %d, pending items %d, name '%s'",
938  queue, serialnum, running_work_items_count,
939  pending_work_items_count, queue_label);
940 
941  QueueSP queue_sp(
942  new Queue(m_process->shared_from_this(), serialnum, queue_label));
943  queue_sp->SetNumRunningWorkItems(running_work_items_count);
944  queue_sp->SetNumPendingWorkItems(pending_work_items_count);
945  queue_sp->SetLibdispatchQueueAddress(queue);
946  queue_sp->SetKind(GetQueueKind(queue));
947  queue_list.AddQueue(queue_sp);
948  queues_read++;
949  }
950  }
951 }
952 
954  lldb_private::DataExtractor &extractor) {
955  ItemInfo item;
956 
957  offset_t offset = 0;
958 
959  item.item_that_enqueued_this = extractor.GetAddress(&offset);
960  item.function_or_block = extractor.GetAddress(&offset);
961  item.enqueuing_thread_id = extractor.GetU64(&offset);
962  item.enqueuing_queue_serialnum = extractor.GetU64(&offset);
963  item.target_queue_serialnum = extractor.GetU64(&offset);
964  item.enqueuing_callstack_frame_count = extractor.GetU32(&offset);
965  item.stop_id = extractor.GetU32(&offset);
966 
968 
969  for (uint32_t i = 0; i < item.enqueuing_callstack_frame_count; i++) {
970  item.enqueuing_callstack.push_back(extractor.GetAddress(&offset));
971  }
972  item.enqueuing_thread_label = extractor.GetCStr(&offset);
973  item.enqueuing_queue_label = extractor.GetCStr(&offset);
974  item.target_queue_label = extractor.GetCStr(&offset);
975 
976  return item;
977 }
978 
980  PluginManager::RegisterPlugin(
982  "System runtime plugin for Mac OS X native libraries.", CreateInstance);
983 }
984 
986  PluginManager::UnregisterPlugin(CreateInstance);
987 }
SystemRuntimeMacOSX::LibdispatchOffsets::IsValid
bool IsValid()
Definition: SystemRuntimeMacOSX.h:179
lldb_private::AddressRange::GetBaseAddress
Address & GetBaseAddress()
Get accessor for the base address of the range.
Definition: AddressRange.h:209
lldb_private::ObjectFile::GetArchitecture
virtual ArchSpec GetArchitecture()=0
Get the ArchSpec for this object file.
lldb_private::Module::GetObjectFile
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
Definition: Module.cpp:1273
LLDB_BREAK_ID_IS_VALID
#define LLDB_BREAK_ID_IS_VALID(bid)
Definition: lldb-defines.h:39
SystemRuntimeMacOSX::LibdispatchTSDIndexes::dti_qos_class_index
uint64_t dti_qos_class_index
Definition: SystemRuntimeMacOSX.h:200
lldb_private::DataBufferHeap::GetByteSize
lldb::offset_t GetByteSize() const override
Definition: DataBufferHeap.cpp:43
lldb_private::QueueItem::SetEnqueueingQueueID
void SetEnqueueingQueueID(lldb::queue_id_t qid)
Definition: QueueItem.h:104
lldb_private::StructuredData::Dictionary
Definition: StructuredData.h:352
SystemRuntimeMacOSX::m_dispatch_queue_offsets_addr
lldb::addr_t m_dispatch_queue_offsets_addr
Definition: SystemRuntimeMacOSX.h:264
SystemRuntimeMacOSX::Clear
void Clear(bool clear_process)
Definition: SystemRuntimeMacOSX.cpp:105
lldb_private::DataExtractor::GetAddress
uint64_t GetAddress(lldb::offset_t *offset_ptr) const
Extract an address from *offset_ptr.
Definition: DataExtractor.cpp:649
SystemRuntimeMacOSX::LibdispatchOffsets::dqo_label
uint16_t dqo_label
Definition: SystemRuntimeMacOSX.h:142
lldb_private::Queue::PushPendingQueueItem
void PushPendingQueueItem(lldb::QueueItemSP item)
Definition: Queue.h:125
lldb_private::Process::ReadMemory
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
Definition: Process.cpp:1921
lldb_private::AppleGetQueuesHandler::GetCurrentQueues
GetQueuesReturnInfo GetCurrentQueues(Thread &thread, lldb::addr_t page_to_free, uint64_t page_to_free_size, lldb_private::Status &error)
Get the list of queues that exist (with any active or pending items) via a call to introspection_get_...
Definition: AppleGetQueuesHandler.cpp:218
SystemRuntimeMacOSX::m_libdispatch_offsets
struct LibdispatchOffsets m_libdispatch_offsets
Definition: SystemRuntimeMacOSX.h:265
SystemRuntimeMacOSX::m_dispatch_tsd_indexes_addr
lldb::addr_t m_dispatch_tsd_indexes_addr
Definition: SystemRuntimeMacOSX.h:270
ModuleSpec.h
SystemRuntimeMacOSX::GetQueueNameFromThreadQAddress
std::string GetQueueNameFromThreadQAddress(lldb::addr_t dispatch_qaddr) override
Get the queue name for a thread given a thread's dispatch_qaddr.
Definition: SystemRuntimeMacOSX.cpp:117
SystemRuntimeMacOSX::GetExtendedBacktraceThread
lldb::ThreadSP GetExtendedBacktraceThread(lldb::ThreadSP thread, lldb_private::ConstString type) override
Return a Thread which shows the origin of this thread's creation.
Definition: SystemRuntimeMacOSX.cpp:457
lldb_private::Symbol
Definition: Symbol.h:20
SystemRuntimeMacOSX::ItemInfo::enqueuing_queue_serialnum
uint64_t enqueuing_queue_serialnum
Definition: SystemRuntimeMacOSX.h:123
lldb_private::QueueItem::SetEnqueueingBacktrace
void SetEnqueueingBacktrace(std::vector< lldb::addr_t > backtrace)
Definition: QueueItem.h:116
lldb_private::SymbolContext::GetAddressRange
bool GetAddressRange(uint32_t scope, uint32_t range_idx, bool use_inline_block_range, AddressRange &range) const
Get the address range contained within a symbol context.
Definition: SymbolContext.cpp:379
SystemRuntimeMacOSX::LibdispatchTSDIndexes::IsValid
bool IsValid()
Definition: SystemRuntimeMacOSX.h:204
SystemRuntimeMacOSX::m_get_thread_item_info_handler
lldb_private::AppleGetThreadItemInfoHandler m_get_thread_item_info_handler
Definition: SystemRuntimeMacOSX.h:258
SystemRuntimeMacOSX::ReadLibpthreadOffsets
void ReadLibpthreadOffsets()
Definition: SystemRuntimeMacOSX.cpp:345
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:270
lldb_private::Process
Definition: Process.h:338
lldb_private::TypeSystemClang::GetBuiltinTypeForEncodingAndBitSize
CompilerType GetBuiltinTypeForEncodingAndBitSize(lldb::Encoding encoding, size_t bit_size) override
Definition: TypeSystemClang.cpp:795
lldb_private::Process::ClearBreakpointSiteByID
Status ClearBreakpointSiteByID(lldb::user_id_t break_id)
Definition: Process.cpp:1576
Module.h
lldb_private::Process::GetThreadList
ThreadList & GetThreadList()
Definition: Process.h:2073
lldb_private::Process::GetTarget
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1206
StoppointCallbackContext.h
lldb_private::QueueList::AddQueue
void AddQueue(lldb::QueueSP queue)
Add a Queue to the QueueList.
Definition: QueueList.cpp:40
SystemRuntimeMacOSX::LibdispatchTSDIndexes::dti_version
uint16_t dti_version
Definition: SystemRuntimeMacOSX.h:197
lldb::eSymbolTypeData
@ eSymbolTypeData
Definition: lldb-enumerations.h:618
lldb_private::SymbolContextList
Definition: SymbolContext.h:379
lldb_private::SymbolContextList::GetContextAtIndex
bool GetContextAtIndex(size_t idx, SymbolContext &sc) const
Get accessor for a symbol context at index idx.
Definition: SymbolContext.cpp:1263
lldb_private::Module
Definition: Module.h:85
lldb_private::SystemRuntime
Definition: SystemRuntime.h:43
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
SystemRuntimeMacOSX::ItemRefAndCodeAddress
Definition: SystemRuntimeMacOSX.h:226
lldb_private::Process::IsAlive
virtual bool IsAlive()
Check if a process is still alive.
Definition: Process.cpp:1084
SystemRuntimeMacOSX::SystemRuntimeMacOSX
SystemRuntimeMacOSX(lldb_private::Process *process)
Definition: SystemRuntimeMacOSX.cpp:80
SystemRuntimeMacOSX::ItemInfo::enqueuing_callstack_frame_count
uint32_t enqueuing_callstack_frame_count
Definition: SystemRuntimeMacOSX.h:125
HistoryThread.h
SystemRuntimeMacOSX::PendingItemsForQueue::new_style
bool new_style
Definition: SystemRuntimeMacOSX.h:232
lldb_private::Process::ReadCStringFromMemory
size_t ReadCStringFromMemory(lldb::addr_t vm_addr, char *cstr, size_t cstr_max_len, Status &error)
Read a NULL terminated C string from memory.
Definition: Process.cpp:1984
lldb_private::ArchSpec::GetTriple
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:455
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
SystemRuntimeMacOSX::Initialize
static void Initialize()
Definition: SystemRuntimeMacOSX.cpp:979
SystemRuntimeMacOSX::m_get_pending_items_handler
lldb_private::AppleGetPendingItemsHandler m_get_pending_items_handler
Definition: SystemRuntimeMacOSX.h:256
lldb_private::AppleGetPendingItemsHandler::GetPendingItemsReturnInfo::count
uint64_t count
Definition: AppleGetPendingItemsHandler.h:56
lldb_private::ProcessStructReader
Definition: ProcessStructReader.h:27
SystemRuntimeMacOSX::ItemInfo::enqueuing_thread_id
uint64_t enqueuing_thread_id
Definition: SystemRuntimeMacOSX.h:122
lldb_private::AppleGetThreadItemInfoHandler::GetThreadItemInfoReturnInfo::item_buffer_size
lldb::addr_t item_buffer_size
Definition: AppleGetThreadItemInfoHandler.h:52
lldb_private::Target::ResolveLoadAddress
bool ResolveLoadAddress(lldb::addr_t load_addr, Address &so_addr, uint32_t stop_id=SectionLoadHistory::eStopIDNow)
Definition: Target.cpp:2893
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::Target
Definition: Target.h:464
Section.h
lldb_private::SymbolContextList::Clear
void Clear()
Clear the object's state.
Definition: SymbolContext.cpp:1245
SystemRuntimeMacOSX::LibpthreadOffsets::IsValid
bool IsValid()
Definition: SystemRuntimeMacOSX.h:215
lldb_private::DataExtractor::GetU64
uint64_t GetU64(lldb::offset_t *offset_ptr) const
Extract a uint64_t value from *offset_ptr.
Definition: DataExtractor.cpp:474
lldb_private::Target::GetImages
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition: Target.h:938
lldb_private::QueueItem::SetTargetQueueLabel
void SetTargetQueueLabel(std::string queue_name)
Definition: QueueItem.h:130
lldb_private::AppleGetThreadItemInfoHandler::GetThreadItemInfoReturnInfo
Definition: AppleGetThreadItemInfoHandler.h:49
SystemRuntimeMacOSX::ItemInfo::item_that_enqueued_this
lldb::addr_t item_that_enqueued_this
Definition: SystemRuntimeMacOSX.h:120
Process.h
SystemRuntimeMacOSX::BacktraceRecordingHeadersInitialized
bool BacktraceRecordingHeadersInitialized()
Definition: SystemRuntimeMacOSX.cpp:572
SystemRuntimeMacOSX::GetExtendedBacktraceTypes
const std::vector< lldb_private::ConstString > & GetExtendedBacktraceTypes() override
Return a list of thread origin extended backtraces that may be available.
Definition: SystemRuntimeMacOSX.cpp:674
lldb_private::ModuleList::FindSymbolsWithNameAndType
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
Definition: ModuleList.cpp:504
SystemRuntimeMacOSX
Definition: SystemRuntimeMacOSX.h:31
Target.h
lldb::eQueueKindSerial
@ eQueueKindSerial
Definition: lldb-enumerations.h:947
SystemRuntimeMacOSX::ExtractItemInfoFromBuffer
ItemInfo ExtractItemInfoFromBuffer(lldb_private::DataExtractor &extractor)
Definition: SystemRuntimeMacOSX.cpp:953
lldb::queue_id_t
uint64_t queue_id_t
Definition: lldb-types.h:91
SystemRuntimeMacOSX::PopulatePendingItemsForQueue
void PopulatePendingItemsForQueue(lldb_private::Queue *queue) override
Get the pending work items for a libdispatch Queue.
Definition: SystemRuntimeMacOSX.cpp:826
lldb_private::FileSpec
Definition: FileSpec.h:56
lldb_private::AppleGetThreadItemInfoHandler::GetThreadItemInfoReturnInfo::item_buffer_ptr
lldb::addr_t item_buffer_ptr
Definition: AppleGetThreadItemInfoHandler.h:50
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
SystemRuntimeMacOSX::ItemInfo::target_queue_serialnum
uint64_t target_queue_serialnum
Definition: SystemRuntimeMacOSX.h:124
lldb_private::Target::ReadUnsignedIntegerFromMemory
uint64_t ReadUnsignedIntegerFromMemory(const Address &addr, size_t integer_byte_size, uint64_t fail_value, Status &error, bool force_live_memory=false)
Definition: Target.cpp:2011
SystemRuntimeMacOSX::ItemInfo::enqueuing_queue_label
std::string enqueuing_queue_label
Definition: SystemRuntimeMacOSX.h:129
lldb_private::QueueItem::SetEnqueueingThreadID
void SetEnqueueingThreadID(lldb::tid_t tid)
Definition: QueueItem.h:100
lldb_private::QueueItem::SetThreadLabel
void SetThreadLabel(std::string thread_name)
Definition: QueueItem.h:122
SystemRuntimeMacOSX::m_mutex
std::recursive_mutex m_mutex
Definition: SystemRuntimeMacOSX.h:105
lldb_private::AppleGetItemInfoHandler::Detach
void Detach()
Definition: AppleGetItemInfoHandler.cpp:104
SystemRuntimeMacOSX::PendingItemsForQueue
Definition: SystemRuntimeMacOSX.h:231
lldb_private::Process::Threads
ThreadList::ThreadIterable Threads()
Definition: Process.h:2081
SystemRuntimeMacOSX::libBacktraceRecording_info::item_info_data_offset
uint16_t item_info_data_offset
Definition: SystemRuntimeMacOSX.h:112
lldb_private::DataExtractor
Definition: DataExtractor.h:48
SystemRuntimeMacOSX::m_page_to_free_size
uint64_t m_page_to_free_size
Definition: SystemRuntimeMacOSX.h:261
Log.h
TypeSystemClang.h
SystemRuntimeMacOSX::ReadLibdispatchOffsetsAddress
void ReadLibdispatchOffsetsAddress()
Definition: SystemRuntimeMacOSX.cpp:266
SystemRuntimeMacOSX::m_break_id
lldb::user_id_t m_break_id
Definition: SystemRuntimeMacOSX.h:104
lldb_private::Runtime::m_process
Process * m_process
Definition: Runtime.h:29
SystemRuntimeMacOSX::LibdispatchTSDIndexes::dti_voucher_index
uint64_t dti_voucher_index
Definition: SystemRuntimeMacOSX.h:199
lldb_private::StructuredData::ObjectSP
std::shared_ptr< Object > ObjectSP
Definition: StructuredData.h:59
SystemRuntimeMacOSX::LibdispatchOffsets::dqo_width_size
uint16_t dqo_width_size
Definition: SystemRuntimeMacOSX.h:149
SystemRuntimeMacOSX::GetPluginNameStatic
static llvm::StringRef GetPluginNameStatic()
Definition: SystemRuntimeMacOSX.h:42
SystemRuntimeMacOSX::PopulateQueuesUsingLibBTR
void PopulateQueuesUsingLibBTR(lldb::addr_t queues_buffer, uint64_t queues_buffer_size, uint64_t count, lldb_private::QueueList &queue_list)
Definition: SystemRuntimeMacOSX.cpp:879
StreamString.h
lldb_private::QueueItem::SetItemThatEnqueuedThis
void SetItemThatEnqueuedThis(lldb::addr_t address_of_item)
Definition: QueueItem.h:94
SystemRuntimeMacOSX::LibpthreadOffsets::plo_pthread_tsd_base_address_offset
uint16_t plo_pthread_tsd_base_address_offset
Definition: SystemRuntimeMacOSX.h:210
SystemRuntimeMacOSX::ReadLibdispatchOffsets
void ReadLibdispatchOffsets()
Definition: SystemRuntimeMacOSX.cpp:298
lldb_private::Process::GetAddressByteSize
uint32_t GetAddressByteSize() const
Definition: Process.cpp:3323
lldb::eEncodingUint
@ eEncodingUint
unsigned integer
Definition: lldb-enumerations.h:148
lldb_private::ConstString
Definition: ConstString.h:40
lldb::eQueueKindUnknown
@ eQueueKindUnknown
Definition: lldb-enumerations.h:946
lldb_private::AddressRange
Definition: AddressRange.h:25
lldb_private::SymbolContext::GetFunctionName
ConstString GetFunctionName(Mangled::NamePreference preference=Mangled::ePreferDemangled) const
Find a name of the innermost function for the symbol context.
Definition: SymbolContext.cpp:653
SystemRuntimeMacOSX::m_libpthread_offsets
struct LibpthreadOffsets m_libpthread_offsets
Definition: SystemRuntimeMacOSX.h:268
lldb_private::ModuleList::FindFirstModule
lldb::ModuleSP FindFirstModule(const ModuleSpec &module_spec) const
Definition: ModuleList.cpp:618
SystemRuntimeMacOSX::LibdispatchOffsets
Definition: SystemRuntimeMacOSX.h:140
lldb_private::AppleGetItemInfoHandler::GetItemInfoReturnInfo::item_buffer_size
lldb::addr_t item_buffer_size
Definition: AppleGetItemInfoHandler.h:51
lldb_private::AppleGetThreadItemInfoHandler::GetThreadItemInfo
GetThreadItemInfoReturnInfo GetThreadItemInfo(Thread &thread, lldb::tid_t thread_id, lldb::addr_t page_to_free, uint64_t page_to_free_size, lldb_private::Status &error)
Get the information about a work item by calling __introspection_dispatch_thread_get_item_info.
Definition: AppleGetThreadItemInfoHandler.cpp:218
lldb_private::AppleGetThreadItemInfoHandler::Detach
void Detach()
Definition: AppleGetThreadItemInfoHandler.cpp:113
lldb_private::AppleGetQueuesHandler::Detach
void Detach()
Definition: AppleGetQueuesHandler.cpp:105
SystemRuntimeMacOSX::CompleteQueueItem
void CompleteQueueItem(lldb_private::QueueItem *queue_item, lldb::addr_t item_ref) override
Complete the fields in a QueueItem.
Definition: SystemRuntimeMacOSX.cpp:843
SystemRuntimeMacOSX::LibpthreadOffsets::plo_version
uint16_t plo_version
Definition: SystemRuntimeMacOSX.h:208
SystemRuntimeMacOSX::m_get_item_info_handler
lldb_private::AppleGetItemInfoHandler m_get_item_info_handler
Definition: SystemRuntimeMacOSX.h:257
SystemRuntimeMacOSX::~SystemRuntimeMacOSX
~SystemRuntimeMacOSX() override
Definition: SystemRuntimeMacOSX.cpp:95
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::AppleGetPendingItemsHandler::Detach
void Detach()
Definition: AppleGetPendingItemsHandler.cpp:108
LLDB_INVALID_QUEUE_ID
#define LLDB_INVALID_QUEUE_ID
Definition: lldb-defines.h:88
lldb_private::AppleGetPendingItemsHandler::GetPendingItemsReturnInfo::items_buffer_size
lldb::addr_t items_buffer_size
Definition: AppleGetPendingItemsHandler.h:54
Thread.h
Queue.h
lldb_private::AppleGetQueuesHandler::GetQueuesReturnInfo::queues_buffer_ptr
lldb::addr_t queues_buffer_ptr
Definition: AppleGetQueuesHandler.h:48
ObjectFile.h
lldb_private::AppleGetPendingItemsHandler::GetPendingItemsReturnInfo
Definition: AppleGetPendingItemsHandler.h:50
SystemRuntimeMacOSX::Detach
void Detach() override
Called before detaching from a process.
Definition: SystemRuntimeMacOSX.cpp:97
SystemRuntimeMacOSX::ItemRefAndCodeAddress::item_ref
lldb::addr_t item_ref
Definition: SystemRuntimeMacOSX.h:227
SystemRuntimeMacOSX::LibdispatchOffsets::dqo_serialnum_size
uint16_t dqo_serialnum_size
Definition: SystemRuntimeMacOSX.h:147
LLDB_INVALID_BREAK_ID
#define LLDB_INVALID_BREAK_ID
Definition: lldb-defines.h:37
SystemRuntimeMacOSX::libBacktraceRecording_info::queue_info_data_offset
uint16_t queue_info_data_offset
Definition: SystemRuntimeMacOSX.h:110
SystemRuntimeMacOSX::ItemRefAndCodeAddress::code_address
lldb::addr_t code_address
Definition: SystemRuntimeMacOSX.h:228
lldb::eAccessPublic
@ eAccessPublic
Definition: lldb-enumerations.h:509
lldb_private::QueueList::FindQueueByID
lldb::QueueSP FindQueueByID(lldb::queue_id_t qid)
Find a queue in the QueueList by QueueID.
Definition: QueueList.cpp:47
SystemRuntimeMacOSX::LibdispatchOffsets::dqo_width
uint16_t dqo_width
Definition: SystemRuntimeMacOSX.h:148
SystemRuntimeMacOSX::ReadLibdispatchTSDIndexes
void ReadLibdispatchTSDIndexes()
Definition: SystemRuntimeMacOSX.cpp:392
SystemRuntimeMacOSX::ItemInfo::enqueuing_callstack
std::vector< lldb::addr_t > enqueuing_callstack
Definition: SystemRuntimeMacOSX.h:127
ProcessStructReader.h
lldb_private::ModuleSpec
Definition: ModuleSpec.h:27
SystemRuntimeMacOSX::LibdispatchTSDIndexes::dti_queue_index
uint64_t dti_queue_index
Definition: SystemRuntimeMacOSX.h:198
SystemRuntimeMacOSX::m_page_to_free
lldb::addr_t m_page_to_free
Definition: SystemRuntimeMacOSX.h:260
lldb_private::AppleGetItemInfoHandler::GetItemInfo
GetItemInfoReturnInfo GetItemInfo(Thread &thread, lldb::addr_t item, lldb::addr_t page_to_free, uint64_t page_to_free_size, lldb_private::Status &error)
Get the information about a work item by calling __introspection_dispatch_queue_item_get_info.
Definition: AppleGetItemInfoHandler.cpp:213
lldb_private::Queue
Definition: Queue.h:32
SystemRuntimeMacOSX::Terminate
static void Terminate()
Definition: SystemRuntimeMacOSX.cpp:985
lldb_private::Status
Definition: Status.h:44
SystemRuntimeMacOSX::PopulateQueueList
void PopulateQueueList(lldb_private::QueueList &queue_list) override
Populate the Process' QueueList with libdispatch / GCD queues that exist.
Definition: SystemRuntimeMacOSX.cpp:683
lldb_private::OptionalClangModuleID
A Clang module ID.
Definition: TypeSystemClang.h:56
SystemRuntimeMacOSX::CreateInstance
static lldb_private::SystemRuntime * CreateInstance(lldb_private::Process *process)
Definition: SystemRuntimeMacOSX.cpp:43
SystemRuntimeMacOSX::LibdispatchOffsets::dqo_version
uint16_t dqo_version
Definition: SystemRuntimeMacOSX.h:141
uint32_t
lldb_private::eLazyBoolNo
@ eLazyBoolNo
Definition: lldb-private-enumerations.h:115
SystemRuntimeMacOSX::SafeToCallFunctionsOnThisThread
bool SafeToCallFunctionsOnThisThread(lldb::ThreadSP thread_sp) override
Determine whether it is safe to run an expression on a given thread.
Definition: SystemRuntimeMacOSX.cpp:222
lldb_private::AppleGetQueuesHandler::GetQueuesReturnInfo::queues_buffer_size
lldb::addr_t queues_buffer_size
Definition: AppleGetQueuesHandler.h:51
SystemRuntimeMacOSX::LibdispatchOffsets::dqo_serialnum
uint16_t dqo_serialnum
Definition: SystemRuntimeMacOSX.h:146
lldb_private::Address
Definition: Address.h:59
lldb_private::AppleGetItemInfoHandler::GetItemInfoReturnInfo::item_buffer_ptr
lldb::addr_t item_buffer_ptr
Definition: AppleGetItemInfoHandler.h:49
lldb_private::ObjectFile::GetStrata
Strata GetStrata()
Definition: ObjectFile.h:643
lldb_private::StructuredData::Object::GetAsDictionary
Dictionary * GetAsDictionary()
Definition: StructuredData.h:91
SystemRuntimeMacOSX::LibpthreadOffsets::plo_pthread_tsd_base_offset
uint16_t plo_pthread_tsd_base_offset
Definition: SystemRuntimeMacOSX.h:209
lldb_private::Address::GetLoadAddress
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition: Address.cpp:311
SystemRuntimeMacOSX::GetExtendedBacktraceForQueueItem
lldb::ThreadSP GetExtendedBacktraceForQueueItem(lldb::QueueItemSP queue_item_sp, lldb_private::ConstString type) override
Get the extended backtrace thread for a QueueItem.
Definition: SystemRuntimeMacOSX.cpp:548
SystemRuntimeMacOSX::GetQueueKind
lldb::QueueKind GetQueueKind(lldb::addr_t dispatch_queue_addr) override
Retrieve the Queue kind for the queue at a thread's dispatch_qaddr.
Definition: SystemRuntimeMacOSX.cpp:171
SystemRuntimeMacOSX::m_get_queues_handler
lldb_private::AppleGetQueuesHandler m_get_queues_handler
Definition: SystemRuntimeMacOSX.h:255
uint16_t
lldb_private::SystemRuntime::m_types
std::vector< ConstString > m_types
Definition: SystemRuntime.h:298
lldb_private::DataExtractor::GetU32
uint32_t GetU32(lldb::offset_t *offset_ptr) const
Extract a uint32_t value from *offset_ptr.
Definition: DataExtractor.cpp:425
PluginManager.h
lldb_private::AppleGetItemInfoHandler::GetItemInfoReturnInfo
Definition: AppleGetItemInfoHandler.h:48
SystemRuntimeMacOSX::libBacktraceRecording_info::item_info_version
uint16_t item_info_version
Definition: SystemRuntimeMacOSX.h:111
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
SystemRuntimeMacOSX::libBacktraceRecording_info::queue_info_version
uint16_t queue_info_version
Definition: SystemRuntimeMacOSX.h:109
SystemRuntimeMacOSX::ItemInfo
Definition: SystemRuntimeMacOSX.h:119
lldb_private::TypeSystemClang::CreateRecordType
CompilerType CreateRecordType(clang::DeclContext *decl_ctx, OptionalClangModuleID owning_module, lldb::AccessType access_type, llvm::StringRef name, int kind, lldb::LanguageType language, ClangASTMetadata *metadata=nullptr, bool exports_symbols=false)
Definition: TypeSystemClang.cpp:1270
DataExtractor.h
lldb_private::CompilerType
Generic representation of a type in a programming language.
Definition: CompilerType.h:33
lldb_private::SymbolContextList::IsEmpty
bool IsEmpty() const
Definition: SymbolContext.cpp:1281
lldb_private::AppleGetQueuesHandler::GetQueuesReturnInfo
Definition: AppleGetQueuesHandler.h:47
SymbolContext.h
SystemRuntimeMacOSX::m_libdispatch_tsd_indexes
struct LibdispatchTSDIndexes m_libdispatch_tsd_indexes
Definition: SystemRuntimeMacOSX.h:271
lldb::eQueueKindConcurrent
@ eQueueKindConcurrent
Definition: lldb-enumerations.h:948
lldb_private::AppleGetPendingItemsHandler::GetPendingItemsReturnInfo::items_buffer_ptr
lldb::addr_t items_buffer_ptr
Definition: AppleGetPendingItemsHandler.h:51
SystemRuntimeMacOSX::ItemInfo::target_queue_label
std::string target_queue_label
Definition: SystemRuntimeMacOSX.h:130
lldb::eLanguageTypeC
@ eLanguageTypeC
Non-standardized C, such as K&R.
Definition: lldb-enumerations.h:439
lldb_private::QueueItem::SetStopID
void SetStopID(uint32_t stop_id)
Definition: QueueItem.h:112
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
SystemRuntimeMacOSX::LibdispatchOffsets::dqo_label_size
uint16_t dqo_label_size
Definition: SystemRuntimeMacOSX.h:143
lldb_private::DataExtractor::GetCStr
const char * GetCStr(lldb::offset_t *offset_ptr) const
Extract a C string from *offset_ptr.
Definition: DataExtractor.cpp:784
SystemRuntimeMacOSX::PendingItemsForQueue::item_refs_and_code_addresses
std::vector< ItemRefAndCodeAddress > item_refs_and_code_addresses
Definition: SystemRuntimeMacOSX.h:234
lldb_private::StructuredData::Dictionary::AddIntegerItem
void AddIntegerItem(llvm::StringRef key, uint64_t value)
Definition: StructuredData.h:509
FileSpec.h
lldb_private::TypeSystemClang
A TypeSystem implementation based on Clang.
Definition: TypeSystemClang.h:105
SystemRuntimeMacOSX::ItemInfo::function_or_block
lldb::addr_t function_or_block
Definition: SystemRuntimeMacOSX.h:121
SystemRuntimeMacOSX::GetPendingItemRefsForQueue
PendingItemsForQueue GetPendingItemRefsForQueue(lldb::addr_t queue)
Definition: SystemRuntimeMacOSX.cpp:749
lldb_private::QueueItem
Definition: QueueItem.h:32
SystemRuntimeMacOSX::GetQueueIDFromThreadQAddress
lldb::queue_id_t GetQueueIDFromThreadQAddress(lldb::addr_t dispatch_qaddr) override
Get the QueueID for the libdispatch queue given the thread's dispatch_qaddr.
Definition: SystemRuntimeMacOSX.cpp:237
lldb_private::ProcessStructReader::GetField
RetType GetField(ConstString name, RetType fail_value=RetType())
Definition: ProcessStructReader.h:82
lldb_private::QueueList
Definition: QueueList.h:28
SystemRuntimeMacOSX::GetExtendedBacktraceFromItemRef
lldb::ThreadSP GetExtendedBacktraceFromItemRef(lldb::addr_t item_ref)
Definition: SystemRuntimeMacOSX.cpp:510
lldb_private::Process::ReadUnsignedIntegerFromMemory
uint64_t ReadUnsignedIntegerFromMemory(lldb::addr_t load_addr, size_t byte_size, uint64_t fail_value, Status &error)
Reads an unsigned integer of the specified byte size from process memory.
Definition: Process.cpp:2056
lldb_private::Process::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Definition: Process.cpp:3319
LLDB_PLUGIN_DEFINE
#define LLDB_PLUGIN_DEFINE(PluginName)
Definition: PluginManager.h:31
lldb_private::Log
Definition: Log.h:48
lldb_private::Queue::GetLibdispatchQueueAddress
lldb::addr_t GetLibdispatchQueueAddress() const
Get the dispatch_queue_t structure address for this Queue.
Definition: Queue.cpp:73
lldb_private::Process::ReadPointerFromMemory
lldb::addr_t ReadPointerFromMemory(lldb::addr_t vm_addr, Status &error)
Definition: Process.cpp:2078
SystemRuntimeMacOSX.h
SystemRuntimeMacOSX::ReadLibdispatchTSDIndexesAddress
void ReadLibdispatchTSDIndexesAddress()
Definition: SystemRuntimeMacOSX.cpp:370
lldb_private::Symbol::GetLoadAddress
lldb::addr_t GetLoadAddress(Target *target) const
Definition: Symbol.cpp:494
SystemRuntimeMacOSX::LibpthreadOffsets
Definition: SystemRuntimeMacOSX.h:207
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:235
SystemRuntimeMacOSX::ItemInfo::stop_id
uint32_t stop_id
Definition: SystemRuntimeMacOSX.h:126
lldb_private::DataBufferHeap
Definition: DataBufferHeap.h:30
SystemRuntimeMacOSX::m_lib_backtrace_recording_info
libBacktraceRecording_info m_lib_backtrace_recording_info
Definition: SystemRuntimeMacOSX.h:262
lldb_private::AppleGetQueuesHandler::GetQueuesReturnInfo::count
uint64_t count
Definition: AppleGetQueuesHandler.h:53
SystemRuntimeMacOSX::ItemInfo::enqueuing_thread_label
std::string enqueuing_thread_label
Definition: SystemRuntimeMacOSX.h:128
lldb
Definition: SBAddress.h:15
lldb_private::ThreadList::GetExpressionExecutionThread
lldb::ThreadSP GetExpressionExecutionThread()
Definition: ThreadList.cpp:60
SystemRuntimeMacOSX::AddThreadExtendedInfoPacketHints
void AddThreadExtendedInfoPacketHints(lldb_private::StructuredData::ObjectSP dict) override
Add key-value pairs to the StructuredData dictionary object with information debugserver may need whe...
Definition: SystemRuntimeMacOSX.cpp:195
QueueList.h
lldb::QueueKind
QueueKind
Queue type.
Definition: lldb-enumerations.h:945
lldb_private::QueueItem::SetQueueLabel
void SetQueueLabel(std::string queue_name)
Definition: QueueItem.h:126
LLDBLog.h
SystemRuntimeMacOSX::ReadLibpthreadOffsetsAddress
void ReadLibpthreadOffsetsAddress()
Definition: SystemRuntimeMacOSX.cpp:322
lldb_private::ObjectFile
Definition: ObjectFile.h:60
SystemRuntimeMacOSX::GetLibdispatchQueueAddressFromThreadQAddress
lldb::addr_t GetLibdispatchQueueAddressFromThreadQAddress(lldb::addr_t dispatch_qaddr) override
Get the libdispatch_queue_t address for the queue given the thread's dispatch_qaddr.
Definition: SystemRuntimeMacOSX.cpp:159
lldb_private::AppleGetPendingItemsHandler::GetPendingItems
GetPendingItemsReturnInfo GetPendingItems(Thread &thread, lldb::addr_t queue, lldb::addr_t page_to_free, uint64_t page_to_free_size, lldb_private::Status &error)
Get the list of pending items for a given queue via a call to __introspection_dispatch_queue_get_pend...
Definition: AppleGetPendingItemsHandler.cpp:212
DataBufferHeap.h
SystemRuntimeMacOSX::LibpthreadOffsets::plo_pthread_tsd_entry_size
uint16_t plo_pthread_tsd_entry_size
Definition: SystemRuntimeMacOSX.h:211
SystemRuntimeMacOSX::m_libpthread_layout_offsets_addr
lldb::addr_t m_libpthread_layout_offsets_addr
Definition: SystemRuntimeMacOSX.h:267