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/Log.h"
29 
30 #include "SystemRuntimeMacOSX.h"
31 
32 #include <memory>
33 
34 using namespace lldb;
35 using namespace lldb_private;
36 
38 
39 // Create an instance of this class. This function is filled into the plugin
40 // info class that gets handed out by the plugin factory and allows the lldb to
41 // instantiate an instance of this class.
42 SystemRuntime *SystemRuntimeMacOSX::CreateInstance(Process *process) {
43  bool create = false;
44  if (!create) {
45  create = true;
46  Module *exe_module = process->GetTarget().GetExecutableModulePointer();
47  if (exe_module) {
48  ObjectFile *object_file = exe_module->GetObjectFile();
49  if (object_file) {
50  create = (object_file->GetStrata() == ObjectFile::eStrataUser);
51  }
52  }
53 
54  if (create) {
55  const llvm::Triple &triple_ref =
56  process->GetTarget().GetArchitecture().GetTriple();
57  switch (triple_ref.getOS()) {
58  case llvm::Triple::Darwin:
59  case llvm::Triple::MacOSX:
60  case llvm::Triple::IOS:
61  case llvm::Triple::TvOS:
62  case llvm::Triple::WatchOS:
63  // NEED_BRIDGEOS_TRIPLE case llvm::Triple::BridgeOS:
64  create = triple_ref.getVendor() == llvm::Triple::Apple;
65  break;
66  default:
67  create = false;
68  break;
69  }
70  }
71  }
72 
73  if (create)
74  return new SystemRuntimeMacOSX(process);
75  return nullptr;
76 }
77 
78 // Constructor
80  : SystemRuntime(process), m_break_id(LLDB_INVALID_BREAK_ID), m_mutex(),
81  m_get_queues_handler(process), m_get_pending_items_handler(process),
82  m_get_item_info_handler(process), m_get_thread_item_info_handler(process),
83  m_page_to_free(LLDB_INVALID_ADDRESS), m_page_to_free_size(0),
84  m_lib_backtrace_recording_info(),
85  m_dispatch_queue_offsets_addr(LLDB_INVALID_ADDRESS),
86  m_libdispatch_offsets(),
87  m_libpthread_layout_offsets_addr(LLDB_INVALID_ADDRESS),
88  m_libpthread_offsets(), m_dispatch_tsd_indexes_addr(LLDB_INVALID_ADDRESS),
89  m_libdispatch_tsd_indexes(),
90  m_dispatch_voucher_offsets_addr(LLDB_INVALID_ADDRESS),
91  m_libdispatch_voucher_offsets() {}
92 
93 // Destructor
95 
101 }
102 
103 // Clear out the state of this class.
104 void SystemRuntimeMacOSX::Clear(bool clear_process) {
105  std::lock_guard<std::recursive_mutex> guard(m_mutex);
106 
109 
110  if (clear_process)
111  m_process = nullptr;
113 }
114 
117  std::string dispatch_queue_name;
118  if (dispatch_qaddr == LLDB_INVALID_ADDRESS || dispatch_qaddr == 0)
119  return "";
120 
123  // dispatch_qaddr is from a thread_info(THREAD_IDENTIFIER_INFO) call for a
124  // thread - deref it to get the address of the dispatch_queue_t structure
125  // for this thread's queue.
126  Status error;
127  addr_t dispatch_queue_addr =
128  m_process->ReadPointerFromMemory(dispatch_qaddr, error);
129  if (error.Success()) {
131  // libdispatch versions 4+, pointer to dispatch name is in the queue
132  // structure.
133  addr_t pointer_to_label_address =
134  dispatch_queue_addr + m_libdispatch_offsets.dqo_label;
135  addr_t label_addr =
136  m_process->ReadPointerFromMemory(pointer_to_label_address, error);
137  if (error.Success()) {
138  m_process->ReadCStringFromMemory(label_addr, dispatch_queue_name,
139  error);
140  }
141  } else {
142  // libdispatch versions 1-3, dispatch name is a fixed width char array
143  // in the queue structure.
144  addr_t label_addr =
145  dispatch_queue_addr + m_libdispatch_offsets.dqo_label;
146  dispatch_queue_name.resize(m_libdispatch_offsets.dqo_label_size, '\0');
147  size_t bytes_read =
148  m_process->ReadMemory(label_addr, &dispatch_queue_name[0],
150  if (bytes_read < m_libdispatch_offsets.dqo_label_size)
151  dispatch_queue_name.erase(bytes_read);
152  }
153  }
154  }
155  return dispatch_queue_name;
156 }
157 
159  addr_t dispatch_qaddr) {
160  addr_t libdispatch_queue_t_address = LLDB_INVALID_ADDRESS;
161  Status error;
162  libdispatch_queue_t_address =
163  m_process->ReadPointerFromMemory(dispatch_qaddr, error);
164  if (!error.Success()) {
165  libdispatch_queue_t_address = LLDB_INVALID_ADDRESS;
166  }
167  return libdispatch_queue_t_address;
168 }
169 
171  if (dispatch_queue_addr == LLDB_INVALID_ADDRESS || dispatch_queue_addr == 0)
172  return eQueueKindUnknown;
173 
178  Status error;
179  uint64_t width = m_process->ReadUnsignedIntegerFromMemory(
180  dispatch_queue_addr + m_libdispatch_offsets.dqo_width,
182  if (error.Success()) {
183  if (width == 1) {
184  kind = eQueueKindSerial;
185  }
186  if (width > 1) {
187  kind = eQueueKindConcurrent;
188  }
189  }
190  }
191  return kind;
192 }
193 
196  StructuredData::Dictionary *dict = dict_sp->GetAsDictionary();
197  if (dict) {
200  dict->AddIntegerItem("plo_pthread_tsd_base_offset",
202  dict->AddIntegerItem(
203  "plo_pthread_tsd_base_address_offset",
205  dict->AddIntegerItem("plo_pthread_tsd_entry_size",
207  }
208 
211  dict->AddIntegerItem("dti_queue_index",
213  dict->AddIntegerItem("dti_voucher_index",
215  dict->AddIntegerItem("dti_qos_class_index",
217  }
218  }
219 }
220 
222  if (thread_sp && thread_sp->GetStackFrameCount() > 0 &&
223  thread_sp->GetFrameWithConcreteFrameIndex(0)) {
224  const SymbolContext sym_ctx(
225  thread_sp->GetFrameWithConcreteFrameIndex(0)->GetSymbolContext(
226  eSymbolContextSymbol));
227  static ConstString g_select_symbol("__select");
228  if (sym_ctx.GetFunctionName() == g_select_symbol) {
229  return false;
230  }
231  }
232  return true;
233 }
234 
238 
239  if (dispatch_qaddr == LLDB_INVALID_ADDRESS || dispatch_qaddr == 0)
240  return queue_id;
241 
244  // dispatch_qaddr is from a thread_info(THREAD_IDENTIFIER_INFO) call for a
245  // thread - deref it to get the address of the dispatch_queue_t structure
246  // for this thread's queue.
247  Status error;
248  uint64_t dispatch_queue_addr =
249  m_process->ReadPointerFromMemory(dispatch_qaddr, error);
250  if (error.Success()) {
251  addr_t serialnum_address =
252  dispatch_queue_addr + m_libdispatch_offsets.dqo_serialnum;
254  serialnum_address, m_libdispatch_offsets.dqo_serialnum_size,
256  if (error.Success()) {
257  queue_id = serialnum;
258  }
259  }
260  }
261 
262  return queue_id;
263 }
264 
267  return;
268 
269  static ConstString g_dispatch_queue_offsets_symbol_name(
270  "dispatch_queue_offsets");
271  const Symbol *dispatch_queue_offsets_symbol = nullptr;
272 
273  // libdispatch symbols were in libSystem.B.dylib up through Mac OS X 10.6
274  // ("Snow Leopard")
275  ModuleSpec libSystem_module_spec(FileSpec("libSystem.B.dylib"));
276  ModuleSP module_sp(m_process->GetTarget().GetImages().FindFirstModule(
277  libSystem_module_spec));
278  if (module_sp)
279  dispatch_queue_offsets_symbol = module_sp->FindFirstSymbolWithNameAndType(
280  g_dispatch_queue_offsets_symbol_name, eSymbolTypeData);
281 
282  // libdispatch symbols are in their own dylib as of Mac OS X 10.7 ("Lion")
283  // and later
284  if (dispatch_queue_offsets_symbol == nullptr) {
285  ModuleSpec libdispatch_module_spec(FileSpec("libdispatch.dylib"));
286  module_sp = m_process->GetTarget().GetImages().FindFirstModule(
287  libdispatch_module_spec);
288  if (module_sp)
289  dispatch_queue_offsets_symbol = module_sp->FindFirstSymbolWithNameAndType(
290  g_dispatch_queue_offsets_symbol_name, eSymbolTypeData);
291  }
292  if (dispatch_queue_offsets_symbol)
294  dispatch_queue_offsets_symbol->GetLoadAddress(&m_process->GetTarget());
295 }
296 
299  return;
300 
302 
303  uint8_t memory_buffer[sizeof(struct LibdispatchOffsets)];
304  DataExtractor data(memory_buffer, sizeof(memory_buffer),
307 
308  Status error;
310  sizeof(memory_buffer),
311  error) == sizeof(memory_buffer)) {
312  lldb::offset_t data_offset = 0;
313 
314  // The struct LibdispatchOffsets is a series of uint16_t's - extract them
315  // all in one big go.
316  data.GetU16(&data_offset, &m_libdispatch_offsets.dqo_version,
317  sizeof(struct LibdispatchOffsets) / sizeof(uint16_t));
318  }
319 }
320 
323  return;
324 
325  static ConstString g_libpthread_layout_offsets_symbol_name(
326  "pthread_layout_offsets");
327  const Symbol *libpthread_layout_offsets_symbol = nullptr;
328 
329  ModuleSpec libpthread_module_spec(FileSpec("libsystem_pthread.dylib"));
330  ModuleSP module_sp(m_process->GetTarget().GetImages().FindFirstModule(
331  libpthread_module_spec));
332  if (module_sp) {
333  libpthread_layout_offsets_symbol =
334  module_sp->FindFirstSymbolWithNameAndType(
335  g_libpthread_layout_offsets_symbol_name, eSymbolTypeData);
336  if (libpthread_layout_offsets_symbol) {
338  libpthread_layout_offsets_symbol->GetLoadAddress(
339  &m_process->GetTarget());
340  }
341  }
342 }
343 
346  return;
347 
349 
351  uint8_t memory_buffer[sizeof(struct LibpthreadOffsets)];
352  DataExtractor data(memory_buffer, sizeof(memory_buffer),
355  Status error;
357  sizeof(memory_buffer),
358  error) == sizeof(memory_buffer)) {
359  lldb::offset_t data_offset = 0;
360 
361  // The struct LibpthreadOffsets is a series of uint16_t's - extract them
362  // all in one big go.
363  data.GetU16(&data_offset, &m_libpthread_offsets.plo_version,
364  sizeof(struct LibpthreadOffsets) / sizeof(uint16_t));
365  }
366  }
367 }
368 
371  return;
372 
373  static ConstString g_libdispatch_tsd_indexes_symbol_name(
374  "dispatch_tsd_indexes");
375  const Symbol *libdispatch_tsd_indexes_symbol = nullptr;
376 
377  ModuleSpec libpthread_module_spec(FileSpec("libdispatch.dylib"));
378  ModuleSP module_sp(m_process->GetTarget().GetImages().FindFirstModule(
379  libpthread_module_spec));
380  if (module_sp) {
381  libdispatch_tsd_indexes_symbol = module_sp->FindFirstSymbolWithNameAndType(
382  g_libdispatch_tsd_indexes_symbol_name, eSymbolTypeData);
383  if (libdispatch_tsd_indexes_symbol) {
385  libdispatch_tsd_indexes_symbol->GetLoadAddress(
386  &m_process->GetTarget());
387  }
388  }
389 }
390 
393  return;
394 
396 
398 
399 // We don't need to check the version number right now, it will be at least 2,
400 // but keep this code around to fetch just the version # for the future where
401 // we need to fetch alternate versions of the struct.
402 #if 0
403  uint16_t dti_version = 2;
404  Address dti_struct_addr;
406  {
407  Status error;
408  uint16_t version = m_process->GetTarget().ReadUnsignedIntegerFromMemory (dti_struct_addr, false, 2, UINT16_MAX, error);
409  if (error.Success() && dti_version != UINT16_MAX)
410  {
411  dti_version = version;
412  }
413  }
414 #endif
415 
416  TypeSystemClang *ast_ctx =
417  ScratchTypeSystemClang::GetForTarget(m_process->GetTarget());
419  CompilerType uint16 =
421  CompilerType dispatch_tsd_indexes_s = ast_ctx->CreateRecordType(
423  "__lldb_dispatch_tsd_indexes_s", clang::TTK_Struct,
425 
426  TypeSystemClang::StartTagDeclarationDefinition(dispatch_tsd_indexes_s);
427  TypeSystemClang::AddFieldToRecordType(dispatch_tsd_indexes_s,
428  "dti_version", uint16,
430  TypeSystemClang::AddFieldToRecordType(dispatch_tsd_indexes_s,
431  "dti_queue_index", uint16,
433  TypeSystemClang::AddFieldToRecordType(dispatch_tsd_indexes_s,
434  "dti_voucher_index", uint16,
436  TypeSystemClang::AddFieldToRecordType(dispatch_tsd_indexes_s,
437  "dti_qos_class_index", uint16,
439  TypeSystemClang::CompleteTagDeclarationDefinition(dispatch_tsd_indexes_s);
440 
442  dispatch_tsd_indexes_s);
443 
445  struct_reader.GetField<uint16_t>(ConstString("dti_version"));
447  struct_reader.GetField<uint16_t>(ConstString("dti_queue_index"));
449  struct_reader.GetField<uint16_t>(ConstString("dti_voucher_index"));
451  struct_reader.GetField<uint16_t>(ConstString("dti_qos_class_index"));
452  }
453  }
454 }
455 
457  ConstString type) {
458  ThreadSP originating_thread_sp;
459  if (BacktraceRecordingHeadersInitialized() && type == "libdispatch") {
460  Status error;
461 
462  // real_thread is either an actual, live thread (in which case we need to
463  // call into libBacktraceRecording to find its originator) or it is an
464  // extended backtrace itself, in which case we get the token from it and
465  // call into libBacktraceRecording to find the originator of that token.
466 
467  if (real_thread->GetExtendedBacktraceToken() != LLDB_INVALID_ADDRESS) {
468  originating_thread_sp = GetExtendedBacktraceFromItemRef(
469  real_thread->GetExtendedBacktraceToken());
470  } else {
471  ThreadSP cur_thread_sp(
475  *cur_thread_sp.get(), real_thread->GetID(), m_page_to_free,
479  if (ret.item_buffer_ptr != 0 &&
481  ret.item_buffer_size > 0) {
482  DataBufferHeap data(ret.item_buffer_size, 0);
483  if (m_process->ReadMemory(ret.item_buffer_ptr, data.GetBytes(),
484  ret.item_buffer_size, error) &&
485  error.Success()) {
486  DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
489  ItemInfo item = ExtractItemInfoFromBuffer(extractor);
490  originating_thread_sp = std::make_shared<HistoryThread>(
492  originating_thread_sp->SetExtendedBacktraceToken(
494  originating_thread_sp->SetQueueName(
495  item.enqueuing_queue_label.c_str());
496  originating_thread_sp->SetQueueID(item.enqueuing_queue_serialnum);
497  // originating_thread_sp->SetThreadName
498  // (item.enqueuing_thread_label.c_str());
499  }
502  }
503  }
504  }
505  return originating_thread_sp;
506 }
507 
508 ThreadSP
510  ThreadSP return_thread_sp;
511 
513  ThreadSP cur_thread_sp(
515  Status error;
516  ret = m_get_item_info_handler.GetItemInfo(*cur_thread_sp.get(), item_ref,
518  error);
521  if (ret.item_buffer_ptr != 0 && ret.item_buffer_ptr != LLDB_INVALID_ADDRESS &&
522  ret.item_buffer_size > 0) {
523  DataBufferHeap data(ret.item_buffer_size, 0);
524  if (m_process->ReadMemory(ret.item_buffer_ptr, data.GetBytes(),
525  ret.item_buffer_size, error) &&
526  error.Success()) {
527  DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
530  ItemInfo item = ExtractItemInfoFromBuffer(extractor);
531  return_thread_sp = std::make_shared<HistoryThread>(
533  return_thread_sp->SetExtendedBacktraceToken(item.item_that_enqueued_this);
534  return_thread_sp->SetQueueName(item.enqueuing_queue_label.c_str());
535  return_thread_sp->SetQueueID(item.enqueuing_queue_serialnum);
536  // return_thread_sp->SetThreadName
537  // (item.enqueuing_thread_label.c_str());
538 
541  }
542  }
543  return return_thread_sp;
544 }
545 
546 ThreadSP
548  ConstString type) {
549  ThreadSP extended_thread_sp;
550  if (type != "libdispatch")
551  return extended_thread_sp;
552 
553  extended_thread_sp = std::make_shared<HistoryThread>(
554  *m_process, queue_item_sp->GetEnqueueingThreadID(),
555  queue_item_sp->GetEnqueueingBacktrace());
556  extended_thread_sp->SetExtendedBacktraceToken(
557  queue_item_sp->GetItemThatEnqueuedThis());
558  extended_thread_sp->SetQueueName(queue_item_sp->GetQueueLabel().c_str());
559  extended_thread_sp->SetQueueID(queue_item_sp->GetEnqueueingQueueID());
560  // extended_thread_sp->SetThreadName
561  // (queue_item_sp->GetThreadLabel().c_str());
562 
563  return extended_thread_sp;
564 }
565 
566 /* Returns true if we were able to get the version / offset information
567  * out of libBacktraceRecording. false means we were unable to retrieve
568  * this; the queue_info_version field will be 0.
569  */
570 
573  return true;
574 
575  addr_t queue_info_version_address = LLDB_INVALID_ADDRESS;
576  addr_t queue_info_data_offset_address = LLDB_INVALID_ADDRESS;
577  addr_t item_info_version_address = LLDB_INVALID_ADDRESS;
578  addr_t item_info_data_offset_address = LLDB_INVALID_ADDRESS;
579  Target &target = m_process->GetTarget();
580 
581  static ConstString introspection_dispatch_queue_info_version(
582  "__introspection_dispatch_queue_info_version");
583  SymbolContextList sc_list;
585  introspection_dispatch_queue_info_version, eSymbolTypeData, sc_list);
586  if (!sc_list.IsEmpty()) {
587  SymbolContext sc;
588  sc_list.GetContextAtIndex(0, sc);
589  AddressRange addr_range;
590  sc.GetAddressRange(eSymbolContextSymbol, 0, false, addr_range);
591  queue_info_version_address =
592  addr_range.GetBaseAddress().GetLoadAddress(&target);
593  }
594  sc_list.Clear();
595 
596  static ConstString introspection_dispatch_queue_info_data_offset(
597  "__introspection_dispatch_queue_info_data_offset");
599  introspection_dispatch_queue_info_data_offset, eSymbolTypeData, sc_list);
600  if (!sc_list.IsEmpty()) {
601  SymbolContext sc;
602  sc_list.GetContextAtIndex(0, sc);
603  AddressRange addr_range;
604  sc.GetAddressRange(eSymbolContextSymbol, 0, false, addr_range);
605  queue_info_data_offset_address =
606  addr_range.GetBaseAddress().GetLoadAddress(&target);
607  }
608  sc_list.Clear();
609 
610  static ConstString introspection_dispatch_item_info_version(
611  "__introspection_dispatch_item_info_version");
613  introspection_dispatch_item_info_version, eSymbolTypeData, sc_list);
614  if (!sc_list.IsEmpty()) {
615  SymbolContext sc;
616  sc_list.GetContextAtIndex(0, sc);
617  AddressRange addr_range;
618  sc.GetAddressRange(eSymbolContextSymbol, 0, false, addr_range);
619  item_info_version_address =
620  addr_range.GetBaseAddress().GetLoadAddress(&target);
621  }
622  sc_list.Clear();
623 
624  static ConstString introspection_dispatch_item_info_data_offset(
625  "__introspection_dispatch_item_info_data_offset");
627  introspection_dispatch_item_info_data_offset, eSymbolTypeData, sc_list);
628  if (!sc_list.IsEmpty()) {
629  SymbolContext sc;
630  sc_list.GetContextAtIndex(0, sc);
631  AddressRange addr_range;
632  sc.GetAddressRange(eSymbolContextSymbol, 0, false, addr_range);
633  item_info_data_offset_address =
634  addr_range.GetBaseAddress().GetLoadAddress(&target);
635  }
636 
637  if (queue_info_version_address != LLDB_INVALID_ADDRESS &&
638  queue_info_data_offset_address != LLDB_INVALID_ADDRESS &&
639  item_info_version_address != LLDB_INVALID_ADDRESS &&
640  item_info_data_offset_address != LLDB_INVALID_ADDRESS) {
641  Status error;
643  m_process->ReadUnsignedIntegerFromMemory(queue_info_version_address, 2,
644  0, error);
645  if (error.Success()) {
648  queue_info_data_offset_address, 2, 0, error);
649  if (error.Success()) {
651  m_process->ReadUnsignedIntegerFromMemory(item_info_version_address,
652  2, 0, error);
653  if (error.Success()) {
656  item_info_data_offset_address, 2, 0, error);
657  if (!error.Success()) {
659  }
660  } else {
662  }
663  } else {
665  }
666  }
667  }
668 
670 }
671 
672 const std::vector<ConstString> &
674  if (m_types.size() == 0) {
675  m_types.push_back(ConstString("libdispatch"));
676  // We could have pthread as another type in the future if we have a way of
677  // gathering that information & it's useful to distinguish between them.
678  }
679  return m_types;
680 }
681 
683  lldb_private::QueueList &queue_list) {
686  ThreadSP cur_thread_sp(
688  if (cur_thread_sp) {
689  Status error;
690  queue_info_pointer = m_get_queues_handler.GetCurrentQueues(
691  *cur_thread_sp.get(), m_page_to_free, m_page_to_free_size, error);
694  if (error.Success()) {
695 
696  if (queue_info_pointer.count > 0 &&
697  queue_info_pointer.queues_buffer_size > 0 &&
698  queue_info_pointer.queues_buffer_ptr != 0 &&
699  queue_info_pointer.queues_buffer_ptr != LLDB_INVALID_ADDRESS) {
700  PopulateQueuesUsingLibBTR(queue_info_pointer.queues_buffer_ptr,
701  queue_info_pointer.queues_buffer_size,
702  queue_info_pointer.count, queue_list);
703  }
704  }
705  }
706  }
707 
708  // We either didn't have libBacktraceRecording (and need to create the queues
709  // list based on threads) or we did get the queues list from
710  // libBacktraceRecording but some special queues may not be included in its
711  // information. This is needed because libBacktraceRecording will only list
712  // queues with pending or running items by default - but the magic com.apple
713  // .main-thread queue on thread 1 is always around.
714 
715  for (ThreadSP thread_sp : m_process->Threads()) {
716  if (thread_sp->GetAssociatedWithLibdispatchQueue() != eLazyBoolNo) {
717  if (thread_sp->GetQueueID() != LLDB_INVALID_QUEUE_ID) {
718  if (queue_list.FindQueueByID(thread_sp->GetQueueID()).get() ==
719  nullptr) {
720  QueueSP queue_sp(new Queue(m_process->shared_from_this(),
721  thread_sp->GetQueueID(),
722  thread_sp->GetQueueName()));
723  if (thread_sp->ThreadHasQueueInformation()) {
724  queue_sp->SetKind(thread_sp->GetQueueKind());
725  queue_sp->SetLibdispatchQueueAddress(
726  thread_sp->GetQueueLibdispatchQueueAddress());
727  queue_list.AddQueue(queue_sp);
728  } else {
729  queue_sp->SetKind(
730  GetQueueKind(thread_sp->GetQueueLibdispatchQueueAddress()));
731  queue_sp->SetLibdispatchQueueAddress(
732  thread_sp->GetQueueLibdispatchQueueAddress());
733  queue_list.AddQueue(queue_sp);
734  }
735  }
736  }
737  }
738  }
739 }
740 
741 // Returns either an array of introspection_dispatch_item_info_ref's for the
742 // pending items on a queue or an array introspection_dispatch_item_info_ref's
743 // and code addresses for the pending items on a queue. The information about
744 // each of these pending items then needs to be fetched individually by passing
745 // the ref to libBacktraceRecording.
746 
749  PendingItemsForQueue pending_item_refs;
751  ThreadSP cur_thread_sp(
753  if (cur_thread_sp) {
754  Status error;
755  pending_items_pointer = m_get_pending_items_handler.GetPendingItems(
756  *cur_thread_sp.get(), queue, m_page_to_free, m_page_to_free_size,
757  error);
760  if (error.Success()) {
761  if (pending_items_pointer.count > 0 &&
762  pending_items_pointer.items_buffer_size > 0 &&
763  pending_items_pointer.items_buffer_ptr != 0 &&
764  pending_items_pointer.items_buffer_ptr != LLDB_INVALID_ADDRESS) {
765  DataBufferHeap data(pending_items_pointer.items_buffer_size, 0);
766  if (m_process->ReadMemory(
767  pending_items_pointer.items_buffer_ptr, data.GetBytes(),
768  pending_items_pointer.items_buffer_size, error)) {
769  DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
772 
773  // We either have an array of
774  // void* item_ref
775  // (old style) or we have a structure returned which looks like
776  //
777  // struct introspection_dispatch_pending_item_info_s {
778  // void *item_ref;
779  // void *function_or_block;
780  // };
781  //
782  // struct introspection_dispatch_pending_items_array_s {
783  // uint32_t version;
784  // uint32_t size_of_item_info;
785  // introspection_dispatch_pending_item_info_s items[];
786  // }
787 
788  offset_t offset = 0;
789  int i = 0;
790  uint32_t version = extractor.GetU32(&offset);
791  if (version == 1) {
792  pending_item_refs.new_style = true;
793  uint32_t item_size = extractor.GetU32(&offset);
794  uint32_t start_of_array_offset = offset;
795  while (offset < pending_items_pointer.items_buffer_size &&
796  static_cast<size_t>(i) < pending_items_pointer.count) {
797  offset = start_of_array_offset + (i * item_size);
799  item.item_ref = extractor.GetAddress(&offset);
800  item.code_address = extractor.GetAddress(&offset);
801  pending_item_refs.item_refs_and_code_addresses.push_back(item);
802  i++;
803  }
804  } else {
805  offset = 0;
806  pending_item_refs.new_style = false;
807  while (offset < pending_items_pointer.items_buffer_size &&
808  static_cast<size_t>(i) < pending_items_pointer.count) {
810  item.item_ref = extractor.GetAddress(&offset);
812  pending_item_refs.item_refs_and_code_addresses.push_back(item);
813  i++;
814  }
815  }
816  }
817  m_page_to_free = pending_items_pointer.items_buffer_ptr;
818  m_page_to_free_size = pending_items_pointer.items_buffer_size;
819  }
820  }
821  }
822  return pending_item_refs;
823 }
824 
827  PendingItemsForQueue pending_item_refs =
829  for (ItemRefAndCodeAddress pending_item :
830  pending_item_refs.item_refs_and_code_addresses) {
831  Address addr;
833  addr);
834  QueueItemSP queue_item_sp(new QueueItem(queue->shared_from_this(),
835  m_process->shared_from_this(),
836  pending_item.item_ref, addr));
837  queue->PushPendingQueueItem(queue_item_sp);
838  }
839  }
840 }
841 
843  addr_t item_ref) {
845 
846  ThreadSP cur_thread_sp(
848  Status error;
849  ret = m_get_item_info_handler.GetItemInfo(*cur_thread_sp.get(), item_ref,
851  error);
854  if (ret.item_buffer_ptr != 0 && ret.item_buffer_ptr != LLDB_INVALID_ADDRESS &&
855  ret.item_buffer_size > 0) {
856  DataBufferHeap data(ret.item_buffer_size, 0);
857  if (m_process->ReadMemory(ret.item_buffer_ptr, data.GetBytes(),
858  ret.item_buffer_size, error) &&
859  error.Success()) {
860  DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
863  ItemInfo item = ExtractItemInfoFromBuffer(extractor);
865  queue_item->SetEnqueueingThreadID(item.enqueuing_thread_id);
867  queue_item->SetStopID(item.stop_id);
869  queue_item->SetThreadLabel(item.enqueuing_thread_label);
870  queue_item->SetQueueLabel(item.enqueuing_queue_label);
871  queue_item->SetTargetQueueLabel(item.target_queue_label);
872  }
875  }
876 }
877 
879  lldb::addr_t queues_buffer, uint64_t queues_buffer_size, uint64_t count,
880  lldb_private::QueueList &queue_list) {
881  Status error;
882  DataBufferHeap data(queues_buffer_size, 0);
884  if (m_process->ReadMemory(queues_buffer, data.GetBytes(), queues_buffer_size,
885  error) == queues_buffer_size &&
886  error.Success()) {
887  // We've read the information out of inferior memory; free it on the next
888  // call we make
889  m_page_to_free = queues_buffer;
890  m_page_to_free_size = queues_buffer_size;
891 
892  DataExtractor extractor(data.GetBytes(), data.GetByteSize(),
895  offset_t offset = 0;
896  uint64_t queues_read = 0;
897 
898  // The information about the queues is stored in this format (v1): typedef
899  // struct introspection_dispatch_queue_info_s {
900  // uint32_t offset_to_next;
901  // dispatch_queue_t queue;
902  // uint64_t serialnum; // queue's serialnum in the process, as
903  // provided by libdispatch
904  // uint32_t running_work_items_count;
905  // uint32_t pending_work_items_count;
906  //
907  // char data[]; // Starting here, we have variable-length data:
908  // // char queue_label[];
909  // } introspection_dispatch_queue_info_s;
910 
911  while (queues_read < count && offset < queues_buffer_size) {
912  offset_t start_of_this_item = offset;
913 
914  uint32_t offset_to_next = extractor.GetU32(&offset);
915 
916  offset += 4; // Skip over the 4 bytes of reserved space
917  addr_t queue = extractor.GetAddress(&offset);
918  uint64_t serialnum = extractor.GetU64(&offset);
919  uint32_t running_work_items_count = extractor.GetU32(&offset);
920  uint32_t pending_work_items_count = extractor.GetU32(&offset);
921 
922  // Read the first field of the variable length data
923  offset = start_of_this_item +
925  const char *queue_label = extractor.GetCStr(&offset);
926  if (queue_label == nullptr)
927  queue_label = "";
928 
929  offset_t start_of_next_item = start_of_this_item + offset_to_next;
930  offset = start_of_next_item;
931 
932  LLDB_LOGF(log,
933  "SystemRuntimeMacOSX::PopulateQueuesUsingLibBTR added "
934  "queue with dispatch_queue_t 0x%" PRIx64
935  ", serial number 0x%" PRIx64
936  ", running items %d, pending items %d, name '%s'",
937  queue, serialnum, running_work_items_count,
938  pending_work_items_count, queue_label);
939 
940  QueueSP queue_sp(
941  new Queue(m_process->shared_from_this(), serialnum, queue_label));
942  queue_sp->SetNumRunningWorkItems(running_work_items_count);
943  queue_sp->SetNumPendingWorkItems(pending_work_items_count);
944  queue_sp->SetLibdispatchQueueAddress(queue);
945  queue_sp->SetKind(GetQueueKind(queue));
946  queue_list.AddQueue(queue_sp);
947  queues_read++;
948  }
949  }
950 }
951 
953  lldb_private::DataExtractor &extractor) {
954  ItemInfo item;
955 
956  offset_t offset = 0;
957 
958  item.item_that_enqueued_this = extractor.GetAddress(&offset);
959  item.function_or_block = extractor.GetAddress(&offset);
960  item.enqueuing_thread_id = extractor.GetU64(&offset);
961  item.enqueuing_queue_serialnum = extractor.GetU64(&offset);
962  item.target_queue_serialnum = extractor.GetU64(&offset);
963  item.enqueuing_callstack_frame_count = extractor.GetU32(&offset);
964  item.stop_id = extractor.GetU32(&offset);
965 
967 
968  for (uint32_t i = 0; i < item.enqueuing_callstack_frame_count; i++) {
969  item.enqueuing_callstack.push_back(extractor.GetAddress(&offset));
970  }
971  item.enqueuing_thread_label = extractor.GetCStr(&offset);
972  item.enqueuing_queue_label = extractor.GetCStr(&offset);
973  item.target_queue_label = extractor.GetCStr(&offset);
974 
975  return item;
976 }
977 
979  PluginManager::RegisterPlugin(
981  "System runtime plugin for Mac OS X native libraries.", CreateInstance);
982 }
983 
985  PluginManager::UnregisterPlugin(CreateInstance);
986 }
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:1238
LLDB_BREAK_ID_IS_VALID
#define LLDB_BREAK_ID_IS_VALID(bid)
Definition: lldb-defines.h:51
SystemRuntimeMacOSX::LibdispatchTSDIndexes::dti_qos_class_index
uint64_t dti_qos_class_index
Definition: SystemRuntimeMacOSX.h:200
lldb_private::DataBufferHeap::GetBytes
uint8_t * GetBytes() override
Definition: DataBufferHeap.cpp:34
lldb_private::DataBufferHeap::GetByteSize
lldb::offset_t GetByteSize() const override
Definition: DataBufferHeap.cpp:45
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:104
lldb_private::DataExtractor::GetAddress
uint64_t GetAddress(lldb::offset_t *offset_ptr) const
Extract an address from *offset_ptr.
Definition: DataExtractor.cpp:651
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:1925
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:217
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:116
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:456
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:344
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:249
lldb_private::Process
Definition: Process.h:341
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:1580
Module.h
lldb_private::Process::GetThreadList
ThreadList & GetThreadList()
Definition: Process.h:2078
lldb_private::Process::GetTarget
Target & GetTarget()
Get the target object pointer for this module.
Definition: Process.h:1209
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:1262
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
LIBLLDB_LOG_SYSTEM_RUNTIME
#define LIBLLDB_LOG_SYSTEM_RUNTIME
Definition: Logging.h:40
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:79
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:1988
lldb_private::ArchSpec::GetTriple
llvm::Triple & GetTriple()
Architecture triple accessor.
Definition: ArchSpec.h:444
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
SystemRuntimeMacOSX::Initialize
static void Initialize()
Definition: SystemRuntimeMacOSX.cpp:978
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:2883
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::Target
Definition: Target.h:451
Section.h
lldb_private::SymbolContextList::Clear
void Clear()
Clear the object's state.
Definition: SymbolContext.cpp:1244
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:476
lldb_private::Target::GetImages
const ModuleList & GetImages() const
Get accessor for the images for this process.
Definition: Target.h:925
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:571
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:673
lldb_private::ModuleList::FindSymbolsWithNameAndType
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
Definition: ModuleList.cpp:450
SystemRuntimeMacOSX
Definition: SystemRuntimeMacOSX.h:31
Target.h
lldb::eQueueKindSerial
@ eQueueKindSerial
Definition: lldb-enumerations.h:946
SystemRuntimeMacOSX::ExtractItemInfoFromBuffer
ItemInfo ExtractItemInfoFromBuffer(lldb_private::DataExtractor &extractor)
Definition: SystemRuntimeMacOSX.cpp:952
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:825
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:1998
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:103
SystemRuntimeMacOSX::PendingItemsForQueue
Definition: SystemRuntimeMacOSX.h:231
lldb_private::Process::Threads
ThreadList::ThreadIterable Threads()
Definition: Process.h:2086
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:265
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:878
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:297
lldb_private::Process::GetAddressByteSize
uint32_t GetAddressByteSize() const
Definition: Process.cpp:3306
lldb::eEncodingUint
@ eEncodingUint
unsigned integer
Definition: lldb-enumerations.h:148
lldb_private::ConstString
Definition: ConstString.h:40
lldb::eQueueKindUnknown
@ eQueueKindUnknown
Definition: lldb-enumerations.h:945
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:564
lldb_private::GetLogIfAllCategoriesSet
Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: Logging.cpp:58
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:217
lldb_private::AppleGetThreadItemInfoHandler::Detach
void Detach()
Definition: AppleGetThreadItemInfoHandler.cpp:112
lldb_private::AppleGetQueuesHandler::Detach
void Detach()
Definition: AppleGetQueuesHandler.cpp:104
SystemRuntimeMacOSX::CompleteQueueItem
void CompleteQueueItem(lldb_private::QueueItem *queue_item, lldb::addr_t item_ref) override
Complete the fields in a QueueItem.
Definition: SystemRuntimeMacOSX.cpp:842
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:94
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::AppleGetPendingItemsHandler::Detach
void Detach()
Definition: AppleGetPendingItemsHandler.cpp:107
LLDB_INVALID_QUEUE_ID
#define LLDB_INVALID_QUEUE_ID
Definition: lldb-defines.h:100
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:96
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:49
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:391
SystemRuntimeMacOSX::ItemInfo::enqueuing_callstack
std::vector< lldb::addr_t > enqueuing_callstack
Definition: SystemRuntimeMacOSX.h:127
ProcessStructReader.h
lldb_private::ModuleSpec
Definition: ModuleSpec.h:26
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:212
lldb_private::Queue
Definition: Queue.h:32
SystemRuntimeMacOSX::Terminate
static void Terminate()
Definition: SystemRuntimeMacOSX.cpp:984
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:682
lldb_private::OptionalClangModuleID
A Clang module ID.
Definition: TypeSystemClang.h:57
SystemRuntimeMacOSX::CreateInstance
static lldb_private::SystemRuntime * CreateInstance(lldb_private::Process *process)
Definition: SystemRuntimeMacOSX.cpp:42
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:221
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:636
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:310
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:547
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:170
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:427
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:86
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:1280
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:947
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:786
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:510
FileSpec.h
lldb_private::TypeSystemClang
A TypeSystem implementation based on Clang.
Definition: TypeSystemClang.h:106
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:748
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:236
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:509
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:2060
lldb_private::Process::GetByteOrder
lldb::ByteOrder GetByteOrder() const
Definition: Process.cpp:3302
LLDB_PLUGIN_DEFINE
#define LLDB_PLUGIN_DEFINE(PluginName)
Definition: PluginManager.h:31
lldb_private::Log
Definition: Log.h:49
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:2082
SystemRuntimeMacOSX.h
SystemRuntimeMacOSX::ReadLibdispatchTSDIndexesAddress
void ReadLibdispatchTSDIndexesAddress()
Definition: SystemRuntimeMacOSX.cpp:369
lldb_private::Symbol::GetLoadAddress
lldb::addr_t GetLoadAddress(Target *target) const
Definition: Symbol.cpp:494
SystemRuntimeMacOSX::LibpthreadOffsets
Definition: SystemRuntimeMacOSX.h:207
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:59
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:194
QueueList.h
lldb::QueueKind
QueueKind
Queue type.
Definition: lldb-enumerations.h:944
lldb_private::QueueItem::SetQueueLabel
void SetQueueLabel(std::string queue_name)
Definition: QueueItem.h:126
SystemRuntimeMacOSX::ReadLibpthreadOffsetsAddress
void ReadLibpthreadOffsetsAddress()
Definition: SystemRuntimeMacOSX.cpp:321
lldb_private::ObjectFile
Definition: ObjectFile.h:59
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:158
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:211
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