15ec532a9SColin Riley //===-- RenderScriptRuntime.h -----------------------------------*- C++ -*-===// 25ec532a9SColin Riley // 35ec532a9SColin Riley // The LLVM Compiler Infrastructure 45ec532a9SColin Riley // 55ec532a9SColin Riley // This file is distributed under the University of Illinois Open Source 65ec532a9SColin Riley // License. See LICENSE.TXT for details. 75ec532a9SColin Riley // 85ec532a9SColin Riley //===----------------------------------------------------------------------===// 95ec532a9SColin Riley 105ec532a9SColin Riley #ifndef liblldb_RenderScriptRuntime_h_ 115ec532a9SColin Riley #define liblldb_RenderScriptRuntime_h_ 125ec532a9SColin Riley 135ec532a9SColin Riley // C Includes 145ec532a9SColin Riley // C++ Includes 15222b937cSEugene Zelenko #include <array> 16222b937cSEugene Zelenko #include <map> 17222b937cSEugene Zelenko #include <memory> 18222b937cSEugene Zelenko #include <string> 19222b937cSEugene Zelenko #include <vector> 20222b937cSEugene Zelenko 215ec532a9SColin Riley // Other libraries and framework includes 22*7f193d69SLuke Drummond #include "llvm/ADT/SmallVector.h" 23*7f193d69SLuke Drummond #include "llvm/ADT/StringRef.h" 245ec532a9SColin Riley // Project includes 255ec532a9SColin Riley #include "lldb/Core/Module.h" 2619459580SLuke Drummond #include "lldb/Expression/LLVMUserExpression.h" 27b3f7f69dSAidan Dodds #include "lldb/Target/CPPLanguageRuntime.h" 28b3f7f69dSAidan Dodds #include "lldb/Target/LanguageRuntime.h" 29b3f7f69dSAidan Dodds #include "lldb/lldb-private.h" 305ec532a9SColin Riley 31b9c1b51eSKate Stone namespace lldb_private { 32b9c1b51eSKate Stone namespace lldb_renderscript { 3398156583SEwan Crawford 345ec532a9SColin Riley typedef uint32_t RSSlot; 355ec532a9SColin Riley class RSModuleDescriptor; 364640cde1SColin Riley struct RSGlobalDescriptor; 374640cde1SColin Riley struct RSKernelDescriptor; 38*7f193d69SLuke Drummond struct RSReductionDescriptor; 394640cde1SColin Riley 404640cde1SColin Riley typedef std::shared_ptr<RSModuleDescriptor> RSModuleDescriptorSP; 414640cde1SColin Riley typedef std::shared_ptr<RSGlobalDescriptor> RSGlobalDescriptorSP; 424640cde1SColin Riley typedef std::shared_ptr<RSKernelDescriptor> RSKernelDescriptorSP; 434f8817c2SEwan Crawford typedef std::array<uint32_t, 3> RSCoordinate; 444640cde1SColin Riley 4598156583SEwan Crawford // Breakpoint Resolvers decide where a breakpoint is placed, 4698156583SEwan Crawford // so having our own allows us to limit the search scope to RS kernel modules. 4798156583SEwan Crawford // As well as check for .expand kernels as a fallback. 48b9c1b51eSKate Stone class RSBreakpointResolver : public BreakpointResolver { 4998156583SEwan Crawford public: 50b3f7f69dSAidan Dodds RSBreakpointResolver(Breakpoint *bkpt, ConstString name) 51b9c1b51eSKate Stone : BreakpointResolver(bkpt, BreakpointResolver::NameResolver), 52b9c1b51eSKate Stone m_kernel_name(name) {} 5398156583SEwan Crawford 54b9c1b51eSKate Stone void GetDescription(Stream *strm) override { 5598156583SEwan Crawford if (strm) 56b9c1b51eSKate Stone strm->Printf("RenderScript kernel breakpoint for '%s'", 57b9c1b51eSKate Stone m_kernel_name.AsCString()); 5898156583SEwan Crawford } 5998156583SEwan Crawford 60b9c1b51eSKate Stone void Dump(Stream *s) const override {} 6198156583SEwan Crawford 62b9c1b51eSKate Stone Searcher::CallbackReturn SearchCallback(SearchFilter &filter, 63b9c1b51eSKate Stone SymbolContext &context, Address *addr, 64b9c1b51eSKate Stone bool containing) override; 6598156583SEwan Crawford 66b9c1b51eSKate Stone Searcher::Depth GetDepth() override { return Searcher::eDepthModule; } 6798156583SEwan Crawford 6898156583SEwan Crawford lldb::BreakpointResolverSP 69b9c1b51eSKate Stone CopyForBreakpoint(Breakpoint &breakpoint) override { 70b9c1b51eSKate Stone lldb::BreakpointResolverSP ret_sp( 71b9c1b51eSKate Stone new RSBreakpointResolver(&breakpoint, m_kernel_name)); 7298156583SEwan Crawford return ret_sp; 7398156583SEwan Crawford } 7498156583SEwan Crawford 7598156583SEwan Crawford protected: 7698156583SEwan Crawford ConstString m_kernel_name; 7798156583SEwan Crawford }; 785ec532a9SColin Riley 79b9c1b51eSKate Stone struct RSKernelDescriptor { 805ec532a9SColin Riley public: 81*7f193d69SLuke Drummond RSKernelDescriptor(const RSModuleDescriptor *module, llvm::StringRef name, 82b9c1b51eSKate Stone uint32_t slot) 83b9c1b51eSKate Stone : m_module(module), m_name(name), m_slot(slot) {} 845ec532a9SColin Riley 85b9c1b51eSKate Stone void Dump(Stream &strm) const; 865ec532a9SColin Riley 874640cde1SColin Riley const RSModuleDescriptor *m_module; 885ec532a9SColin Riley ConstString m_name; 895ec532a9SColin Riley RSSlot m_slot; 905ec532a9SColin Riley }; 915ec532a9SColin Riley 92b9c1b51eSKate Stone struct RSGlobalDescriptor { 935ec532a9SColin Riley public: 94*7f193d69SLuke Drummond RSGlobalDescriptor(const RSModuleDescriptor *module, llvm::StringRef name) 95b9c1b51eSKate Stone : m_module(module), m_name(name) {} 965ec532a9SColin Riley 97b9c1b51eSKate Stone void Dump(Stream &strm) const; 985ec532a9SColin Riley 994640cde1SColin Riley const RSModuleDescriptor *m_module; 1005ec532a9SColin Riley ConstString m_name; 1015ec532a9SColin Riley }; 1025ec532a9SColin Riley 103*7f193d69SLuke Drummond struct RSReductionDescriptor { 104*7f193d69SLuke Drummond RSReductionDescriptor(const RSModuleDescriptor *module, uint32_t sig, 105*7f193d69SLuke Drummond uint32_t accum_data_size, llvm::StringRef name, 106*7f193d69SLuke Drummond llvm::StringRef init_name, llvm::StringRef accum_name, 107*7f193d69SLuke Drummond llvm::StringRef comb_name, llvm::StringRef outc_name, 108*7f193d69SLuke Drummond llvm::StringRef halter_name = ".") 109*7f193d69SLuke Drummond : m_module(module), m_reduce_name(name), m_init_name(init_name), 110*7f193d69SLuke Drummond m_accum_name(accum_name), m_comb_name(comb_name), 111*7f193d69SLuke Drummond m_outc_name(outc_name), m_halter_name(halter_name) { 112*7f193d69SLuke Drummond // TODO Check whether the combiner is an autogenerated name, and track 113*7f193d69SLuke Drummond // this 114*7f193d69SLuke Drummond } 115*7f193d69SLuke Drummond 116*7f193d69SLuke Drummond void Dump(Stream &strm) const; 117*7f193d69SLuke Drummond 118*7f193d69SLuke Drummond const RSModuleDescriptor *m_module; 119*7f193d69SLuke Drummond ConstString m_reduce_name; // This is the name given to the general reduction 120*7f193d69SLuke Drummond // as a group as passed to pragma 121*7f193d69SLuke Drummond // reduce(m_reduce_name). There is no kernel function with this name 122*7f193d69SLuke Drummond ConstString m_init_name; // The name of the initializer name. "." if no 123*7f193d69SLuke Drummond // initializer given 124*7f193d69SLuke Drummond ConstString m_accum_name; // The accumulator function name. "." if not given 125*7f193d69SLuke Drummond ConstString m_comb_name; // The name of the combiner function. If this was not 126*7f193d69SLuke Drummond // given, a name is generated by the 127*7f193d69SLuke Drummond // compiler. TODO 128*7f193d69SLuke Drummond ConstString m_outc_name; // The name of the outconverter 129*7f193d69SLuke Drummond 130*7f193d69SLuke Drummond ConstString m_halter_name; // The name of the halter function. XXX This is not 131*7f193d69SLuke Drummond // yet specified by the RenderScript 132*7f193d69SLuke Drummond // compiler or runtime, and its semantics and existence is still under 133*7f193d69SLuke Drummond // discussion by the 134*7f193d69SLuke Drummond // RenderScript Contributors 135*7f193d69SLuke Drummond RSSlot m_accum_sig; // metatdata signature for this reduction (bitwise mask of 136*7f193d69SLuke Drummond // type information (see 137*7f193d69SLuke Drummond // libbcc/include/bcinfo/MetadataExtractor.h 138*7f193d69SLuke Drummond uint32_t m_accum_data_size; // Data size of the accumulator function input 139*7f193d69SLuke Drummond bool m_comb_name_generated; // Was the combiner name generated by the compiler 140*7f193d69SLuke Drummond }; 141*7f193d69SLuke Drummond 142b9c1b51eSKate Stone class RSModuleDescriptor { 143*7f193d69SLuke Drummond bool ParseExportForeachCount(llvm::StringRef *, size_t n_lines); 144*7f193d69SLuke Drummond 145*7f193d69SLuke Drummond bool ParseExportVarCount(llvm::StringRef *, size_t n_lines); 146*7f193d69SLuke Drummond 147*7f193d69SLuke Drummond bool ParseExportReduceCount(llvm::StringRef *, size_t n_lines); 148*7f193d69SLuke Drummond 149*7f193d69SLuke Drummond bool ParseBuildChecksum(llvm::StringRef *, size_t n_lines); 150*7f193d69SLuke Drummond 151*7f193d69SLuke Drummond bool ParsePragmaCount(llvm::StringRef *, size_t n_lines); 152*7f193d69SLuke Drummond 1535ec532a9SColin Riley public: 154b3f7f69dSAidan Dodds RSModuleDescriptor(const lldb::ModuleSP &module) : m_module(module) {} 1555ec532a9SColin Riley 156222b937cSEugene Zelenko ~RSModuleDescriptor() = default; 1575ec532a9SColin Riley 158b9c1b51eSKate Stone bool ParseRSInfo(); 1595ec532a9SColin Riley 160b9c1b51eSKate Stone void Dump(Stream &strm) const; 1615ec532a9SColin Riley 1625ec532a9SColin Riley const lldb::ModuleSP m_module; 1635ec532a9SColin Riley std::vector<RSKernelDescriptor> m_kernels; 1645ec532a9SColin Riley std::vector<RSGlobalDescriptor> m_globals; 165*7f193d69SLuke Drummond std::vector<RSReductionDescriptor> m_reductions; 1664640cde1SColin Riley std::map<std::string, std::string> m_pragmas; 1674640cde1SColin Riley std::string m_resname; 1685ec532a9SColin Riley }; 1695ec532a9SColin Riley 170222b937cSEugene Zelenko } // namespace lldb_renderscript 17198156583SEwan Crawford 172b9c1b51eSKate Stone class RenderScriptRuntime : public lldb_private::CPPLanguageRuntime { 1735ec532a9SColin Riley public: 174b9c1b51eSKate Stone enum ModuleKind { 175ef20b08fSColin Riley eModuleKindIgnored, 176ef20b08fSColin Riley eModuleKindLibRS, 177ef20b08fSColin Riley eModuleKindDriver, 178ef20b08fSColin Riley eModuleKindImpl, 179ef20b08fSColin Riley eModuleKindKernelObj 180ef20b08fSColin Riley }; 181ef20b08fSColin Riley 182222b937cSEugene Zelenko ~RenderScriptRuntime() override; 1835ec532a9SColin Riley 1845ec532a9SColin Riley //------------------------------------------------------------------ 1855ec532a9SColin Riley // Static Functions 1865ec532a9SColin Riley //------------------------------------------------------------------ 187b9c1b51eSKate Stone static void Initialize(); 1885ec532a9SColin Riley 189b9c1b51eSKate Stone static void Terminate(); 1905ec532a9SColin Riley 191b3f7f69dSAidan Dodds static lldb_private::LanguageRuntime * 192b3f7f69dSAidan Dodds CreateInstance(Process *process, lldb::LanguageType language); 1935ec532a9SColin Riley 194b3f7f69dSAidan Dodds static lldb::CommandObjectSP 195b3f7f69dSAidan Dodds GetCommandObject(CommandInterpreter &interpreter); 1964640cde1SColin Riley 197b9c1b51eSKate Stone static lldb_private::ConstString GetPluginNameStatic(); 1985ec532a9SColin Riley 199b9c1b51eSKate Stone static bool IsRenderScriptModule(const lldb::ModuleSP &module_sp); 200ef20b08fSColin Riley 201b9c1b51eSKate Stone static ModuleKind GetModuleKind(const lldb::ModuleSP &module_sp); 202ef20b08fSColin Riley 203b9c1b51eSKate Stone static void ModulesDidLoad(const lldb::ProcessSP &process_sp, 204b9c1b51eSKate Stone const ModuleList &module_list); 205ef20b08fSColin Riley 206b9c1b51eSKate Stone bool IsVTableName(const char *name) override; 2075ec532a9SColin Riley 208b9c1b51eSKate Stone bool GetDynamicTypeAndAddress(ValueObject &in_value, 209b9c1b51eSKate Stone lldb::DynamicValueType use_dynamic, 210b9c1b51eSKate Stone TypeAndOrName &class_type_or_name, 211b9c1b51eSKate Stone Address &address, 2125f57b6eeSEnrico Granata Value::ValueType &value_type) override; 213c74275bcSEnrico Granata 214b9c1b51eSKate Stone TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name, 215b9c1b51eSKate Stone ValueObject &static_value) override; 2165ec532a9SColin Riley 217b9c1b51eSKate Stone bool CouldHaveDynamicValue(ValueObject &in_value) override; 2185ec532a9SColin Riley 219b9c1b51eSKate Stone lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt, 220b9c1b51eSKate Stone bool catch_bp, 221b9c1b51eSKate Stone bool throw_bp) override; 2225ec532a9SColin Riley 223b9c1b51eSKate Stone bool LoadModule(const lldb::ModuleSP &module_sp); 2245ec532a9SColin Riley 225b9c1b51eSKate Stone void DumpModules(Stream &strm) const; 2265ec532a9SColin Riley 227b9c1b51eSKate Stone void DumpContexts(Stream &strm) const; 2284640cde1SColin Riley 229b9c1b51eSKate Stone void DumpKernels(Stream &strm) const; 2304640cde1SColin Riley 231b9c1b51eSKate Stone bool DumpAllocation(Stream &strm, StackFrame *frame_ptr, const uint32_t id); 232a0f08674SEwan Crawford 233b9c1b51eSKate Stone void ListAllocations(Stream &strm, StackFrame *frame_ptr, 234b9c1b51eSKate Stone const uint32_t index); 23515f2bd95SEwan Crawford 236b9c1b51eSKate Stone bool RecomputeAllAllocations(Stream &strm, StackFrame *frame_ptr); 2370d2bfcfbSEwan Crawford 238b9c1b51eSKate Stone void PlaceBreakpointOnKernel(Stream &strm, const char *name, 239b9c1b51eSKate Stone const std::array<int, 3> coords, Error &error, 240b3f7f69dSAidan Dodds lldb::TargetSP target); 2414640cde1SColin Riley 242b9c1b51eSKate Stone void SetBreakAllKernels(bool do_break, lldb::TargetSP target); 2437dc7771cSEwan Crawford 244b9c1b51eSKate Stone void Status(Stream &strm) const; 2454640cde1SColin Riley 246b9c1b51eSKate Stone void ModulesDidLoad(const ModuleList &module_list) override; 247ef20b08fSColin Riley 248b9c1b51eSKate Stone bool LoadAllocation(Stream &strm, const uint32_t alloc_id, 249b9c1b51eSKate Stone const char *filename, StackFrame *frame_ptr); 25055232f09SEwan Crawford 251b9c1b51eSKate Stone bool SaveAllocation(Stream &strm, const uint32_t alloc_id, 252b9c1b51eSKate Stone const char *filename, StackFrame *frame_ptr); 25355232f09SEwan Crawford 254b9c1b51eSKate Stone void Update(); 255ef20b08fSColin Riley 256b9c1b51eSKate Stone void Initiate(); 257ef20b08fSColin Riley 258222b937cSEugene Zelenko //------------------------------------------------------------------ 259222b937cSEugene Zelenko // PluginInterface protocol 260222b937cSEugene Zelenko //------------------------------------------------------------------ 261b9c1b51eSKate Stone lldb_private::ConstString GetPluginName() override; 2624640cde1SColin Riley 263b9c1b51eSKate Stone uint32_t GetPluginVersion() override; 264222b937cSEugene Zelenko 265b9c1b51eSKate Stone static bool GetKernelCoordinate(lldb_renderscript::RSCoordinate &coord, 266b9c1b51eSKate Stone Thread *thread_ptr); 2674f8817c2SEwan Crawford 268222b937cSEugene Zelenko protected: 26915f2bd95SEwan Crawford struct ScriptDetails; 27015f2bd95SEwan Crawford struct AllocationDetails; 2718b244e21SEwan Crawford struct Element; 27215f2bd95SEwan Crawford 273b9c1b51eSKate Stone void InitSearchFilter(lldb::TargetSP target) { 2747dc7771cSEwan Crawford if (!m_filtersp) 2757dc7771cSEwan Crawford m_filtersp.reset(new SearchFilterForUnconstrainedSearches(target)); 2767dc7771cSEwan Crawford } 2777dc7771cSEwan Crawford 278b9c1b51eSKate Stone void FixupScriptDetails(lldb_renderscript::RSModuleDescriptorSP rsmodule_sp); 2794640cde1SColin Riley 280b9c1b51eSKate Stone void LoadRuntimeHooks(lldb::ModuleSP module, ModuleKind kind); 2814640cde1SColin Riley 282b9c1b51eSKate Stone bool RefreshAllocation(AllocationDetails *allocation, StackFrame *frame_ptr); 28315f2bd95SEwan Crawford 284b9c1b51eSKate Stone bool EvalRSExpression(const char *expression, StackFrame *frame_ptr, 285b9c1b51eSKate Stone uint64_t *result); 28615f2bd95SEwan Crawford 287b9c1b51eSKate Stone lldb::BreakpointSP CreateKernelBreakpoint(const ConstString &name); 2887dc7771cSEwan Crawford 289b9c1b51eSKate Stone void BreakOnModuleKernels( 290b9c1b51eSKate Stone const lldb_renderscript::RSModuleDescriptorSP rsmodule_sp); 2917dc7771cSEwan Crawford 2924640cde1SColin Riley struct RuntimeHook; 293b9c1b51eSKate Stone typedef void (RenderScriptRuntime::*CaptureStateFn)( 294b9c1b51eSKate Stone RuntimeHook *hook_info, 295b3f7f69dSAidan Dodds ExecutionContext &context); // Please do this! 2964640cde1SColin Riley 297b9c1b51eSKate Stone struct HookDefn { 2984640cde1SColin Riley const char *name; 29982780287SAidan Dodds const char *symbol_name_m32; // mangled name for the 32 bit architectures 30082780287SAidan Dodds const char *symbol_name_m64; // mangled name for the 64 bit archs 3014640cde1SColin Riley uint32_t version; 3024640cde1SColin Riley ModuleKind kind; 3034640cde1SColin Riley CaptureStateFn grabber; 3044640cde1SColin Riley }; 3054640cde1SColin Riley 306b9c1b51eSKate Stone struct RuntimeHook { 3074640cde1SColin Riley lldb::addr_t address; 3084640cde1SColin Riley const HookDefn *defn; 3094640cde1SColin Riley lldb::BreakpointSP bp_sp; 3104640cde1SColin Riley }; 3114640cde1SColin Riley 3124640cde1SColin Riley typedef std::shared_ptr<RuntimeHook> RuntimeHookSP; 3134640cde1SColin Riley 3144640cde1SColin Riley lldb::ModuleSP m_libRS; 3154640cde1SColin Riley lldb::ModuleSP m_libRSDriver; 3164640cde1SColin Riley lldb::ModuleSP m_libRSCpuRef; 31798156583SEwan Crawford std::vector<lldb_renderscript::RSModuleDescriptorSP> m_rsmodules; 31878f339d1SEwan Crawford 31978f339d1SEwan Crawford std::vector<std::unique_ptr<ScriptDetails>> m_scripts; 32078f339d1SEwan Crawford std::vector<std::unique_ptr<AllocationDetails>> m_allocations; 3214640cde1SColin Riley 322b9c1b51eSKate Stone std::map<lldb::addr_t, lldb_renderscript::RSModuleDescriptorSP> 323b9c1b51eSKate Stone m_scriptMappings; 3244640cde1SColin Riley std::map<lldb::addr_t, RuntimeHookSP> m_runtimeHooks; 3254f8817c2SEwan Crawford std::map<lldb::user_id_t, std::shared_ptr<uint32_t>> m_conditional_breaks; 3264640cde1SColin Riley 327b9c1b51eSKate Stone lldb::SearchFilterSP 328b9c1b51eSKate Stone m_filtersp; // Needed to create breakpoints through Target API 3297dc7771cSEwan Crawford 330ef20b08fSColin Riley bool m_initiated; 3314640cde1SColin Riley bool m_debuggerPresentFlagged; 3327dc7771cSEwan Crawford bool m_breakAllKernels; 3334640cde1SColin Riley static const HookDefn s_runtimeHookDefns[]; 3344640cde1SColin Riley static const size_t s_runtimeHookCount; 33519459580SLuke Drummond LLVMUserExpression::IRPasses *m_ir_passes; 3364640cde1SColin Riley 3375ec532a9SColin Riley private: 3385ec532a9SColin Riley RenderScriptRuntime(Process *process); // Call CreateInstance instead. 3394640cde1SColin Riley 340b9c1b51eSKate Stone static bool HookCallback(void *baton, StoppointCallbackContext *ctx, 341b9c1b51eSKate Stone lldb::user_id_t break_id, 3424640cde1SColin Riley lldb::user_id_t break_loc_id); 3434640cde1SColin Riley 344b9c1b51eSKate Stone static bool KernelBreakpointHit(void *baton, StoppointCallbackContext *ctx, 345b9c1b51eSKate Stone lldb::user_id_t break_id, 346b9c1b51eSKate Stone lldb::user_id_t break_loc_id); 347018f5a7eSEwan Crawford 348b9c1b51eSKate Stone void HookCallback(RuntimeHook *hook_info, ExecutionContext &context); 3494640cde1SColin Riley 350b9c1b51eSKate Stone void CaptureScriptInit(RuntimeHook *hook_info, ExecutionContext &context); 3514640cde1SColin Riley 352b9c1b51eSKate Stone void CaptureAllocationInit(RuntimeHook *hook_info, ExecutionContext &context); 353a0f08674SEwan Crawford 354b9c1b51eSKate Stone void CaptureAllocationDestroy(RuntimeHook *hook_info, 355b9c1b51eSKate Stone ExecutionContext &context); 356b3f7f69dSAidan Dodds 357b9c1b51eSKate Stone void CaptureSetGlobalVar(RuntimeHook *hook_info, ExecutionContext &context); 358b3f7f69dSAidan Dodds 359b9c1b51eSKate Stone void CaptureScriptInvokeForEachMulti(RuntimeHook *hook_info, 360b9c1b51eSKate Stone ExecutionContext &context); 361b3f7f69dSAidan Dodds 362b9c1b51eSKate Stone AllocationDetails *FindAllocByID(Stream &strm, const uint32_t alloc_id); 363b3f7f69dSAidan Dodds 364b9c1b51eSKate Stone std::shared_ptr<uint8_t> GetAllocationData(AllocationDetails *allocation, 365b9c1b51eSKate Stone StackFrame *frame_ptr); 366b3f7f69dSAidan Dodds 367b9c1b51eSKate Stone void SetElementSize(Element &elem); 368b3f7f69dSAidan Dodds 369b9c1b51eSKate Stone static bool GetFrameVarAsUnsigned(const lldb::StackFrameSP, 370b9c1b51eSKate Stone const char *var_name, uint64_t &val); 371b3f7f69dSAidan Dodds 372b9c1b51eSKate Stone void FindStructTypeName(Element &elem, StackFrame *frame_ptr); 373b3f7f69dSAidan Dodds 374b9c1b51eSKate Stone size_t PopulateElementHeaders(const std::shared_ptr<uint8_t> header_buffer, 375b9c1b51eSKate Stone size_t offset, const Element &elem); 376b9c1b51eSKate Stone 377b9c1b51eSKate Stone size_t CalculateElementHeaderSize(const Element &elem); 37826e52a70SEwan Crawford 37915f2bd95SEwan Crawford // 38015f2bd95SEwan Crawford // Helper functions for jitting the runtime 38115f2bd95SEwan Crawford // 38215f2bd95SEwan Crawford 383b9c1b51eSKate Stone bool JITDataPointer(AllocationDetails *allocation, StackFrame *frame_ptr, 384b3f7f69dSAidan Dodds uint32_t x = 0, uint32_t y = 0, uint32_t z = 0); 38515f2bd95SEwan Crawford 386b9c1b51eSKate Stone bool JITTypePointer(AllocationDetails *allocation, StackFrame *frame_ptr); 38715f2bd95SEwan Crawford 388b9c1b51eSKate Stone bool JITTypePacked(AllocationDetails *allocation, StackFrame *frame_ptr); 38915f2bd95SEwan Crawford 390b9c1b51eSKate Stone bool JITElementPacked(Element &elem, const lldb::addr_t context, 391b9c1b51eSKate Stone StackFrame *frame_ptr); 3928b244e21SEwan Crawford 393b9c1b51eSKate Stone bool JITAllocationSize(AllocationDetails *allocation, StackFrame *frame_ptr); 394a0f08674SEwan Crawford 395b9c1b51eSKate Stone bool JITSubelements(Element &elem, const lldb::addr_t context, 396b9c1b51eSKate Stone StackFrame *frame_ptr); 397b3f7f69dSAidan Dodds 398b9c1b51eSKate Stone bool JITAllocationStride(AllocationDetails *allocation, 399b9c1b51eSKate Stone StackFrame *frame_ptr); 400a0f08674SEwan Crawford 40178f339d1SEwan Crawford // Search for a script detail object using a target address. 40278f339d1SEwan Crawford // If a script does not currently exist this function will return nullptr. 40378f339d1SEwan Crawford // If 'create' is true and there is no previous script with this address, 404b9c1b51eSKate Stone // then a new Script detail object will be created for this address and 405b9c1b51eSKate Stone // returned. 406b9c1b51eSKate Stone ScriptDetails *LookUpScript(lldb::addr_t address, bool create); 40778f339d1SEwan Crawford 408b9c1b51eSKate Stone // Search for a previously saved allocation detail object using a target 409b9c1b51eSKate Stone // address. 410b9c1b51eSKate Stone // If an allocation does not exist for this address then nullptr will be 411b9c1b51eSKate Stone // returned. 412b9c1b51eSKate Stone AllocationDetails *LookUpAllocation(lldb::addr_t address); 4135d057637SLuke Drummond 414b9c1b51eSKate Stone // Creates a new allocation with the specified address assigning a new ID and 415b9c1b51eSKate Stone // removes 4165d057637SLuke Drummond // any previous stored allocation which has the same address. 417b9c1b51eSKate Stone AllocationDetails *CreateAllocation(lldb::addr_t address); 41819459580SLuke Drummond 419b9c1b51eSKate Stone bool GetOverrideExprOptions(clang::TargetOptions &prototype) override; 42019459580SLuke Drummond 421b9c1b51eSKate Stone bool GetIRPasses(LLVMUserExpression::IRPasses &passes) override; 4225ec532a9SColin Riley }; 4235ec532a9SColin Riley 4245ec532a9SColin Riley } // namespace lldb_private 4255ec532a9SColin Riley 4265ec532a9SColin Riley #endif // liblldb_RenderScriptRuntime_h_ 427