AppleObjCRuntime.h revision 314564
176195Sbrian//===-- AppleObjCRuntime.h --------------------------------------*- C++ -*-===//
276195Sbrian//
376358Sbrian//                     The LLVM Compiler Infrastructure
476358Sbrian//
576358Sbrian// This file is distributed under the University of Illinois Open Source
676195Sbrian// License. See LICENSE.TXT for details.
776195Sbrian//
876195Sbrian//===----------------------------------------------------------------------===//
976195Sbrian
1076195Sbrian#ifndef liblldb_AppleObjCRuntime_h_
1176195Sbrian#define liblldb_AppleObjCRuntime_h_
1276195Sbrian
1376195Sbrian// C Includes
1476195Sbrian// C++ Includes
1576195Sbrian// Other libraries and framework includes
1676195Sbrian#include "llvm/ADT/Optional.h"
1776195Sbrian
1876195Sbrian// Project includes
1976195Sbrian#include "AppleObjCTrampolineHandler.h"
2076195Sbrian#include "AppleThreadPlanStepThroughObjCTrampoline.h"
2176195Sbrian#include "lldb/Target/LanguageRuntime.h"
2276195Sbrian#include "lldb/Target/ObjCLanguageRuntime.h"
2376195Sbrian#include "lldb/lldb-private.h"
2476195Sbrian
2576195Sbriannamespace lldb_private {
2676195Sbrian
2776195Sbrianclass AppleObjCRuntime : public lldb_private::ObjCLanguageRuntime {
2876195Sbrianpublic:
2976195Sbrian  ~AppleObjCRuntime() override;
3076195Sbrian
3176195Sbrian  //------------------------------------------------------------------
3276195Sbrian  // Static Functions
3376195Sbrian  //------------------------------------------------------------------
3476195Sbrian  // Note there is no CreateInstance, Initialize & Terminate functions here,
3576195Sbrian  // because
3676195Sbrian  // you can't make an instance of this generic runtime.
3776195Sbrian
3890684Sbde  static bool classof(const ObjCLanguageRuntime *runtime) {
3990684Sbde    switch (runtime->GetRuntimeVersion()) {
4076195Sbrian    case ObjCRuntimeVersions::eAppleObjC_V1:
4176195Sbrian    case ObjCRuntimeVersions::eAppleObjC_V2:
4276195Sbrian      return true;
4376195Sbrian    default:
4476195Sbrian      return false;
4576195Sbrian    }
4676195Sbrian  }
4776195Sbrian
48129879Sphk  // These are generic runtime functions:
4976195Sbrian  bool GetObjectDescription(Stream &str, Value &value,
5076195Sbrian                            ExecutionContextScope *exe_scope) override;
5176195Sbrian
52131095Sphk  bool GetObjectDescription(Stream &str, ValueObject &object) override;
5376195Sbrian
5476195Sbrian  bool CouldHaveDynamicValue(ValueObject &in_value) override;
5576195Sbrian
5676848Sbrian  bool GetDynamicTypeAndAddress(ValueObject &in_value,
5776853Sbrian                                lldb::DynamicValueType use_dynamic,
5876853Sbrian                                TypeAndOrName &class_type_or_name,
5976853Sbrian                                Address &address,
6076853Sbrian                                Value::ValueType &value_type) override;
6176195Sbrian
62136200Sphk  TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name,
63136200Sphk                                 ValueObject &static_value) override;
64136200Sphk
65136200Sphk  // These are the ObjC specific functions.
66136200Sphk
67136200Sphk  bool IsModuleObjCLibrary(const lldb::ModuleSP &module_sp) override;
6876195Sbrian
6976195Sbrian  bool ReadObjCLibrary(const lldb::ModuleSP &module_sp) override;
70131373Sphk
71131095Sphk  bool HasReadObjCLibrary() override { return m_read_objc_library; }
7276195Sbrian
7376195Sbrian  lldb::ThreadPlanSP GetStepThroughTrampolinePlan(Thread &thread,
7476195Sbrian                                                  bool stop_others) override;
7576195Sbrian
7676195Sbrian  // Get the "libobjc.A.dylib" module from the current target if we can find
77136200Sphk  // it, also cache it once it is found to ensure quick lookups.
7876195Sbrian  lldb::ModuleSP GetObjCModule();
7976195Sbrian
8076195Sbrian  // Sync up with the target
8176195Sbrian
8276195Sbrian  void ModulesDidLoad(const ModuleList &module_list) override;
8376195Sbrian
8476195Sbrian  void SetExceptionBreakpoints() override;
8576195Sbrian
8676195Sbrian  void ClearExceptionBreakpoints() override;
8776195Sbrian
8876195Sbrian  bool ExceptionBreakpointsAreSet() override;
8976195Sbrian
9076195Sbrian  bool ExceptionBreakpointsExplainStop(lldb::StopInfoSP stop_reason) override;
9176195Sbrian
9276195Sbrian  lldb::SearchFilterSP CreateExceptionSearchFilter() override;
9376195Sbrian
9489062Smsmith  uint32_t GetFoundationVersion();
9591445Speter
9676195Sbrian  virtual void GetValuesForGlobalCFBooleans(lldb::addr_t &cf_true,
9776195Sbrian                                            lldb::addr_t &cf_false);
9876195Sbrian
9976195Sbrianprotected:
10076195Sbrian  // Call CreateInstance instead.
10176195Sbrian  AppleObjCRuntime(Process *process);
10276195Sbrian
10376195Sbrian  bool CalculateHasNewLiteralsAndIndexing() override;
10476195Sbrian
10576195Sbrian  static bool AppleIsModuleObjCLibrary(const lldb::ModuleSP &module_sp);
10676195Sbrian
10776195Sbrian  static ObjCRuntimeVersions GetObjCVersion(Process *process,
10876195Sbrian                                            lldb::ModuleSP &objc_module_sp);
10976195Sbrian
11076195Sbrian  void ReadObjCLibraryIfNeeded(const ModuleList &module_list);
11176195Sbrian
11276195Sbrian  Address *GetPrintForDebuggerAddr();
11376195Sbrian
11476195Sbrian  std::unique_ptr<Address> m_PrintForDebugger_addr;
11576195Sbrian  bool m_read_objc_library;
11676195Sbrian  std::unique_ptr<lldb_private::AppleObjCTrampolineHandler>
11776195Sbrian      m_objc_trampoline_handler_ap;
11876195Sbrian  lldb::BreakpointSP m_objc_exception_bp_sp;
11976195Sbrian  lldb::ModuleWP m_objc_module_wp;
12076195Sbrian  std::unique_ptr<FunctionCaller> m_print_object_caller_up;
12176195Sbrian
12276195Sbrian  llvm::Optional<uint32_t> m_Foundation_major;
12376195Sbrian};
12476195Sbrian
12576195Sbrian} // namespace lldb_private
12676195Sbrian
12776195Sbrian#endif // liblldb_AppleObjCRuntime_h_
12876195Sbrian