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 227f193d69SLuke Drummond #include "llvm/ADT/SmallVector.h" 237f193d69SLuke 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; 387f193d69SLuke 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; 43*00f56eebSLuke Drummond struct RSCoordinate { 44*00f56eebSLuke Drummond uint32_t x, y, z; 45*00f56eebSLuke Drummond 46*00f56eebSLuke Drummond RSCoordinate() : x(), y(), z(){}; 47*00f56eebSLuke Drummond 48*00f56eebSLuke Drummond bool operator==(const lldb_renderscript::RSCoordinate &rhs) { 49*00f56eebSLuke Drummond return x == rhs.x && y == rhs.y && z == rhs.z; 50*00f56eebSLuke Drummond } 51*00f56eebSLuke Drummond }; 524640cde1SColin Riley 5398156583SEwan Crawford // Breakpoint Resolvers decide where a breakpoint is placed, 5498156583SEwan Crawford // so having our own allows us to limit the search scope to RS kernel modules. 5598156583SEwan Crawford // As well as check for .expand kernels as a fallback. 56b9c1b51eSKate Stone class RSBreakpointResolver : public BreakpointResolver { 5798156583SEwan Crawford public: 58b3f7f69dSAidan Dodds RSBreakpointResolver(Breakpoint *bkpt, ConstString name) 59b9c1b51eSKate Stone : BreakpointResolver(bkpt, BreakpointResolver::NameResolver), 60b9c1b51eSKate Stone m_kernel_name(name) {} 6198156583SEwan Crawford 62b9c1b51eSKate Stone void GetDescription(Stream *strm) override { 6398156583SEwan Crawford if (strm) 64b9c1b51eSKate Stone strm->Printf("RenderScript kernel breakpoint for '%s'", 65b9c1b51eSKate Stone m_kernel_name.AsCString()); 6698156583SEwan Crawford } 6798156583SEwan Crawford 68b9c1b51eSKate Stone void Dump(Stream *s) const override {} 6998156583SEwan Crawford 70b9c1b51eSKate Stone Searcher::CallbackReturn SearchCallback(SearchFilter &filter, 71b9c1b51eSKate Stone SymbolContext &context, Address *addr, 72b9c1b51eSKate Stone bool containing) override; 7398156583SEwan Crawford 74b9c1b51eSKate Stone Searcher::Depth GetDepth() override { return Searcher::eDepthModule; } 7598156583SEwan Crawford 7698156583SEwan Crawford lldb::BreakpointResolverSP 77b9c1b51eSKate Stone CopyForBreakpoint(Breakpoint &breakpoint) override { 78b9c1b51eSKate Stone lldb::BreakpointResolverSP ret_sp( 79b9c1b51eSKate Stone new RSBreakpointResolver(&breakpoint, m_kernel_name)); 8098156583SEwan Crawford return ret_sp; 8198156583SEwan Crawford } 8298156583SEwan Crawford 8398156583SEwan Crawford protected: 8498156583SEwan Crawford ConstString m_kernel_name; 8598156583SEwan Crawford }; 865ec532a9SColin Riley 87b9c1b51eSKate Stone struct RSKernelDescriptor { 885ec532a9SColin Riley public: 897f193d69SLuke Drummond RSKernelDescriptor(const RSModuleDescriptor *module, llvm::StringRef name, 90b9c1b51eSKate Stone uint32_t slot) 91b9c1b51eSKate Stone : m_module(module), m_name(name), m_slot(slot) {} 925ec532a9SColin Riley 93b9c1b51eSKate Stone void Dump(Stream &strm) const; 945ec532a9SColin Riley 954640cde1SColin Riley const RSModuleDescriptor *m_module; 965ec532a9SColin Riley ConstString m_name; 975ec532a9SColin Riley RSSlot m_slot; 985ec532a9SColin Riley }; 995ec532a9SColin Riley 100b9c1b51eSKate Stone struct RSGlobalDescriptor { 1015ec532a9SColin Riley public: 1027f193d69SLuke Drummond RSGlobalDescriptor(const RSModuleDescriptor *module, llvm::StringRef name) 103b9c1b51eSKate Stone : m_module(module), m_name(name) {} 1045ec532a9SColin Riley 105b9c1b51eSKate Stone void Dump(Stream &strm) const; 1065ec532a9SColin Riley 1074640cde1SColin Riley const RSModuleDescriptor *m_module; 1085ec532a9SColin Riley ConstString m_name; 1095ec532a9SColin Riley }; 1105ec532a9SColin Riley 1117f193d69SLuke Drummond struct RSReductionDescriptor { 1127f193d69SLuke Drummond RSReductionDescriptor(const RSModuleDescriptor *module, uint32_t sig, 1137f193d69SLuke Drummond uint32_t accum_data_size, llvm::StringRef name, 1147f193d69SLuke Drummond llvm::StringRef init_name, llvm::StringRef accum_name, 1157f193d69SLuke Drummond llvm::StringRef comb_name, llvm::StringRef outc_name, 1167f193d69SLuke Drummond llvm::StringRef halter_name = ".") 1177f193d69SLuke Drummond : m_module(module), m_reduce_name(name), m_init_name(init_name), 1187f193d69SLuke Drummond m_accum_name(accum_name), m_comb_name(comb_name), 1197f193d69SLuke Drummond m_outc_name(outc_name), m_halter_name(halter_name) { 1207f193d69SLuke Drummond // TODO Check whether the combiner is an autogenerated name, and track 1217f193d69SLuke Drummond // this 1227f193d69SLuke Drummond } 1237f193d69SLuke Drummond 1247f193d69SLuke Drummond void Dump(Stream &strm) const; 1257f193d69SLuke Drummond 1267f193d69SLuke Drummond const RSModuleDescriptor *m_module; 1277f193d69SLuke Drummond ConstString m_reduce_name; // This is the name given to the general reduction 1287f193d69SLuke Drummond // as a group as passed to pragma 1297f193d69SLuke Drummond // reduce(m_reduce_name). There is no kernel function with this name 1307f193d69SLuke Drummond ConstString m_init_name; // The name of the initializer name. "." if no 1317f193d69SLuke Drummond // initializer given 1327f193d69SLuke Drummond ConstString m_accum_name; // The accumulator function name. "." if not given 1337f193d69SLuke Drummond ConstString m_comb_name; // The name of the combiner function. If this was not 1347f193d69SLuke Drummond // given, a name is generated by the 1357f193d69SLuke Drummond // compiler. TODO 1367f193d69SLuke Drummond ConstString m_outc_name; // The name of the outconverter 1377f193d69SLuke Drummond 1387f193d69SLuke Drummond ConstString m_halter_name; // The name of the halter function. XXX This is not 1397f193d69SLuke Drummond // yet specified by the RenderScript 1407f193d69SLuke Drummond // compiler or runtime, and its semantics and existence is still under 1417f193d69SLuke Drummond // discussion by the 1427f193d69SLuke Drummond // RenderScript Contributors 1437f193d69SLuke Drummond RSSlot m_accum_sig; // metatdata signature for this reduction (bitwise mask of 1447f193d69SLuke Drummond // type information (see 1457f193d69SLuke Drummond // libbcc/include/bcinfo/MetadataExtractor.h 1467f193d69SLuke Drummond uint32_t m_accum_data_size; // Data size of the accumulator function input 1477f193d69SLuke Drummond bool m_comb_name_generated; // Was the combiner name generated by the compiler 1487f193d69SLuke Drummond }; 1497f193d69SLuke Drummond 150b9c1b51eSKate Stone class RSModuleDescriptor { 1517f193d69SLuke Drummond bool ParseExportForeachCount(llvm::StringRef *, size_t n_lines); 1527f193d69SLuke Drummond 1537f193d69SLuke Drummond bool ParseExportVarCount(llvm::StringRef *, size_t n_lines); 1547f193d69SLuke Drummond 1557f193d69SLuke Drummond bool ParseExportReduceCount(llvm::StringRef *, size_t n_lines); 1567f193d69SLuke Drummond 1577f193d69SLuke Drummond bool ParseBuildChecksum(llvm::StringRef *, size_t n_lines); 1587f193d69SLuke Drummond 1597f193d69SLuke Drummond bool ParsePragmaCount(llvm::StringRef *, size_t n_lines); 1607f193d69SLuke Drummond 1615ec532a9SColin Riley public: 162b3f7f69dSAidan Dodds RSModuleDescriptor(const lldb::ModuleSP &module) : m_module(module) {} 1635ec532a9SColin Riley 164222b937cSEugene Zelenko ~RSModuleDescriptor() = default; 1655ec532a9SColin Riley 166b9c1b51eSKate Stone bool ParseRSInfo(); 1675ec532a9SColin Riley 168b9c1b51eSKate Stone void Dump(Stream &strm) const; 1695ec532a9SColin Riley 1705ec532a9SColin Riley const lldb::ModuleSP m_module; 1715ec532a9SColin Riley std::vector<RSKernelDescriptor> m_kernels; 1725ec532a9SColin Riley std::vector<RSGlobalDescriptor> m_globals; 1737f193d69SLuke Drummond std::vector<RSReductionDescriptor> m_reductions; 1744640cde1SColin Riley std::map<std::string, std::string> m_pragmas; 1754640cde1SColin Riley std::string m_resname; 1765ec532a9SColin Riley }; 1775ec532a9SColin Riley 178222b937cSEugene Zelenko } // namespace lldb_renderscript 17998156583SEwan Crawford 180b9c1b51eSKate Stone class RenderScriptRuntime : public lldb_private::CPPLanguageRuntime { 1815ec532a9SColin Riley public: 182b9c1b51eSKate Stone enum ModuleKind { 183ef20b08fSColin Riley eModuleKindIgnored, 184ef20b08fSColin Riley eModuleKindLibRS, 185ef20b08fSColin Riley eModuleKindDriver, 186ef20b08fSColin Riley eModuleKindImpl, 187ef20b08fSColin Riley eModuleKindKernelObj 188ef20b08fSColin Riley }; 189ef20b08fSColin Riley 190222b937cSEugene Zelenko ~RenderScriptRuntime() override; 1915ec532a9SColin Riley 1925ec532a9SColin Riley //------------------------------------------------------------------ 1935ec532a9SColin Riley // Static Functions 1945ec532a9SColin Riley //------------------------------------------------------------------ 195b9c1b51eSKate Stone static void Initialize(); 1965ec532a9SColin Riley 197b9c1b51eSKate Stone static void Terminate(); 1985ec532a9SColin Riley 199b3f7f69dSAidan Dodds static lldb_private::LanguageRuntime * 200b3f7f69dSAidan Dodds CreateInstance(Process *process, lldb::LanguageType language); 2015ec532a9SColin Riley 202b3f7f69dSAidan Dodds static lldb::CommandObjectSP 203b3f7f69dSAidan Dodds GetCommandObject(CommandInterpreter &interpreter); 2044640cde1SColin Riley 205b9c1b51eSKate Stone static lldb_private::ConstString GetPluginNameStatic(); 2065ec532a9SColin Riley 207b9c1b51eSKate Stone static bool IsRenderScriptModule(const lldb::ModuleSP &module_sp); 208ef20b08fSColin Riley 209b9c1b51eSKate Stone static ModuleKind GetModuleKind(const lldb::ModuleSP &module_sp); 210ef20b08fSColin Riley 211b9c1b51eSKate Stone static void ModulesDidLoad(const lldb::ProcessSP &process_sp, 212b9c1b51eSKate Stone const ModuleList &module_list); 213ef20b08fSColin Riley 214b9c1b51eSKate Stone bool IsVTableName(const char *name) override; 2155ec532a9SColin Riley 216b9c1b51eSKate Stone bool GetDynamicTypeAndAddress(ValueObject &in_value, 217b9c1b51eSKate Stone lldb::DynamicValueType use_dynamic, 218b9c1b51eSKate Stone TypeAndOrName &class_type_or_name, 219b9c1b51eSKate Stone Address &address, 2205f57b6eeSEnrico Granata Value::ValueType &value_type) override; 221c74275bcSEnrico Granata 222b9c1b51eSKate Stone TypeAndOrName FixUpDynamicType(const TypeAndOrName &type_and_or_name, 223b9c1b51eSKate Stone ValueObject &static_value) override; 2245ec532a9SColin Riley 225b9c1b51eSKate Stone bool CouldHaveDynamicValue(ValueObject &in_value) override; 2265ec532a9SColin Riley 227b9c1b51eSKate Stone lldb::BreakpointResolverSP CreateExceptionResolver(Breakpoint *bkpt, 228b9c1b51eSKate Stone bool catch_bp, 229b9c1b51eSKate Stone bool throw_bp) override; 2305ec532a9SColin Riley 231b9c1b51eSKate Stone bool LoadModule(const lldb::ModuleSP &module_sp); 2325ec532a9SColin Riley 233b9c1b51eSKate Stone void DumpModules(Stream &strm) const; 2345ec532a9SColin Riley 235b9c1b51eSKate Stone void DumpContexts(Stream &strm) const; 2364640cde1SColin Riley 237b9c1b51eSKate Stone void DumpKernels(Stream &strm) const; 2384640cde1SColin Riley 239b9c1b51eSKate Stone bool DumpAllocation(Stream &strm, StackFrame *frame_ptr, const uint32_t id); 240a0f08674SEwan Crawford 241b9c1b51eSKate Stone void ListAllocations(Stream &strm, StackFrame *frame_ptr, 242b9c1b51eSKate Stone const uint32_t index); 24315f2bd95SEwan Crawford 244b9c1b51eSKate Stone bool RecomputeAllAllocations(Stream &strm, StackFrame *frame_ptr); 2450d2bfcfbSEwan Crawford 246*00f56eebSLuke Drummond bool PlaceBreakpointOnKernel( 247*00f56eebSLuke Drummond lldb::TargetSP target, Stream &messages, const char *name, 248*00f56eebSLuke Drummond const lldb_renderscript::RSCoordinate *coords = nullptr); 2494640cde1SColin Riley 250b9c1b51eSKate Stone void SetBreakAllKernels(bool do_break, lldb::TargetSP target); 2517dc7771cSEwan Crawford 252b9c1b51eSKate Stone void Status(Stream &strm) const; 2534640cde1SColin Riley 254b9c1b51eSKate Stone void ModulesDidLoad(const ModuleList &module_list) override; 255ef20b08fSColin Riley 256b9c1b51eSKate Stone bool LoadAllocation(Stream &strm, const uint32_t alloc_id, 257b9c1b51eSKate Stone const char *filename, StackFrame *frame_ptr); 25855232f09SEwan Crawford 259b9c1b51eSKate Stone bool SaveAllocation(Stream &strm, const uint32_t alloc_id, 260b9c1b51eSKate Stone const char *filename, StackFrame *frame_ptr); 26155232f09SEwan Crawford 262b9c1b51eSKate Stone void Update(); 263ef20b08fSColin Riley 264b9c1b51eSKate Stone void Initiate(); 265ef20b08fSColin Riley 266222b937cSEugene Zelenko //------------------------------------------------------------------ 267222b937cSEugene Zelenko // PluginInterface protocol 268222b937cSEugene Zelenko //------------------------------------------------------------------ 269b9c1b51eSKate Stone lldb_private::ConstString GetPluginName() override; 2704640cde1SColin Riley 271b9c1b51eSKate Stone uint32_t GetPluginVersion() override; 272222b937cSEugene Zelenko 273b9c1b51eSKate Stone static bool GetKernelCoordinate(lldb_renderscript::RSCoordinate &coord, 274b9c1b51eSKate Stone Thread *thread_ptr); 2754f8817c2SEwan Crawford 276222b937cSEugene Zelenko protected: 27715f2bd95SEwan Crawford struct ScriptDetails; 27815f2bd95SEwan Crawford struct AllocationDetails; 2798b244e21SEwan Crawford struct Element; 28015f2bd95SEwan Crawford 281b9c1b51eSKate Stone void InitSearchFilter(lldb::TargetSP target) { 2827dc7771cSEwan Crawford if (!m_filtersp) 2837dc7771cSEwan Crawford m_filtersp.reset(new SearchFilterForUnconstrainedSearches(target)); 2847dc7771cSEwan Crawford } 2857dc7771cSEwan Crawford 286b9c1b51eSKate Stone void FixupScriptDetails(lldb_renderscript::RSModuleDescriptorSP rsmodule_sp); 2874640cde1SColin Riley 288b9c1b51eSKate Stone void LoadRuntimeHooks(lldb::ModuleSP module, ModuleKind kind); 2894640cde1SColin Riley 290b9c1b51eSKate Stone bool RefreshAllocation(AllocationDetails *allocation, StackFrame *frame_ptr); 29115f2bd95SEwan Crawford 292b9c1b51eSKate Stone bool EvalRSExpression(const char *expression, StackFrame *frame_ptr, 293b9c1b51eSKate Stone uint64_t *result); 29415f2bd95SEwan Crawford 295b9c1b51eSKate Stone lldb::BreakpointSP CreateKernelBreakpoint(const ConstString &name); 2967dc7771cSEwan Crawford 297b9c1b51eSKate Stone void BreakOnModuleKernels( 298b9c1b51eSKate Stone const lldb_renderscript::RSModuleDescriptorSP rsmodule_sp); 2997dc7771cSEwan Crawford 3004640cde1SColin Riley struct RuntimeHook; 301b9c1b51eSKate Stone typedef void (RenderScriptRuntime::*CaptureStateFn)( 302b9c1b51eSKate Stone RuntimeHook *hook_info, 303b3f7f69dSAidan Dodds ExecutionContext &context); // Please do this! 3044640cde1SColin Riley 305b9c1b51eSKate Stone struct HookDefn { 3064640cde1SColin Riley const char *name; 30782780287SAidan Dodds const char *symbol_name_m32; // mangled name for the 32 bit architectures 30882780287SAidan Dodds const char *symbol_name_m64; // mangled name for the 64 bit archs 3094640cde1SColin Riley uint32_t version; 3104640cde1SColin Riley ModuleKind kind; 3114640cde1SColin Riley CaptureStateFn grabber; 3124640cde1SColin Riley }; 3134640cde1SColin Riley 314b9c1b51eSKate Stone struct RuntimeHook { 3154640cde1SColin Riley lldb::addr_t address; 3164640cde1SColin Riley const HookDefn *defn; 3174640cde1SColin Riley lldb::BreakpointSP bp_sp; 3184640cde1SColin Riley }; 3194640cde1SColin Riley 3204640cde1SColin Riley typedef std::shared_ptr<RuntimeHook> RuntimeHookSP; 3214640cde1SColin Riley 3224640cde1SColin Riley lldb::ModuleSP m_libRS; 3234640cde1SColin Riley lldb::ModuleSP m_libRSDriver; 3244640cde1SColin Riley lldb::ModuleSP m_libRSCpuRef; 32598156583SEwan Crawford std::vector<lldb_renderscript::RSModuleDescriptorSP> m_rsmodules; 32678f339d1SEwan Crawford 32778f339d1SEwan Crawford std::vector<std::unique_ptr<ScriptDetails>> m_scripts; 32878f339d1SEwan Crawford std::vector<std::unique_ptr<AllocationDetails>> m_allocations; 3294640cde1SColin Riley 330b9c1b51eSKate Stone std::map<lldb::addr_t, lldb_renderscript::RSModuleDescriptorSP> 331b9c1b51eSKate Stone m_scriptMappings; 3324640cde1SColin Riley std::map<lldb::addr_t, RuntimeHookSP> m_runtimeHooks; 333*00f56eebSLuke Drummond std::map<lldb::user_id_t, std::unique_ptr<lldb_renderscript::RSCoordinate>> 334*00f56eebSLuke Drummond m_conditional_breaks; 3354640cde1SColin Riley 336b9c1b51eSKate Stone lldb::SearchFilterSP 337b9c1b51eSKate Stone m_filtersp; // Needed to create breakpoints through Target API 3387dc7771cSEwan Crawford 339ef20b08fSColin Riley bool m_initiated; 3404640cde1SColin Riley bool m_debuggerPresentFlagged; 3417dc7771cSEwan Crawford bool m_breakAllKernels; 3424640cde1SColin Riley static const HookDefn s_runtimeHookDefns[]; 3434640cde1SColin Riley static const size_t s_runtimeHookCount; 34419459580SLuke Drummond LLVMUserExpression::IRPasses *m_ir_passes; 3454640cde1SColin Riley 3465ec532a9SColin Riley private: 3475ec532a9SColin Riley RenderScriptRuntime(Process *process); // Call CreateInstance instead. 3484640cde1SColin Riley 349b9c1b51eSKate Stone static bool HookCallback(void *baton, StoppointCallbackContext *ctx, 350b9c1b51eSKate Stone lldb::user_id_t break_id, 3514640cde1SColin Riley lldb::user_id_t break_loc_id); 3524640cde1SColin Riley 353b9c1b51eSKate Stone static bool KernelBreakpointHit(void *baton, StoppointCallbackContext *ctx, 354b9c1b51eSKate Stone lldb::user_id_t break_id, 355b9c1b51eSKate Stone lldb::user_id_t break_loc_id); 356018f5a7eSEwan Crawford 357b9c1b51eSKate Stone void HookCallback(RuntimeHook *hook_info, ExecutionContext &context); 3584640cde1SColin Riley 359b9c1b51eSKate Stone void CaptureScriptInit(RuntimeHook *hook_info, ExecutionContext &context); 3604640cde1SColin Riley 361b9c1b51eSKate Stone void CaptureAllocationInit(RuntimeHook *hook_info, ExecutionContext &context); 362a0f08674SEwan Crawford 363b9c1b51eSKate Stone void CaptureAllocationDestroy(RuntimeHook *hook_info, 364b9c1b51eSKate Stone ExecutionContext &context); 365b3f7f69dSAidan Dodds 366b9c1b51eSKate Stone void CaptureSetGlobalVar(RuntimeHook *hook_info, ExecutionContext &context); 367b3f7f69dSAidan Dodds 368b9c1b51eSKate Stone void CaptureScriptInvokeForEachMulti(RuntimeHook *hook_info, 369b9c1b51eSKate Stone ExecutionContext &context); 370b3f7f69dSAidan Dodds 371b9c1b51eSKate Stone AllocationDetails *FindAllocByID(Stream &strm, const uint32_t alloc_id); 372b3f7f69dSAidan Dodds 373b9c1b51eSKate Stone std::shared_ptr<uint8_t> GetAllocationData(AllocationDetails *allocation, 374b9c1b51eSKate Stone StackFrame *frame_ptr); 375b3f7f69dSAidan Dodds 376b9c1b51eSKate Stone void SetElementSize(Element &elem); 377b3f7f69dSAidan Dodds 378b9c1b51eSKate Stone static bool GetFrameVarAsUnsigned(const lldb::StackFrameSP, 379b9c1b51eSKate Stone const char *var_name, uint64_t &val); 380b3f7f69dSAidan Dodds 381b9c1b51eSKate Stone void FindStructTypeName(Element &elem, StackFrame *frame_ptr); 382b3f7f69dSAidan Dodds 383b9c1b51eSKate Stone size_t PopulateElementHeaders(const std::shared_ptr<uint8_t> header_buffer, 384b9c1b51eSKate Stone size_t offset, const Element &elem); 385b9c1b51eSKate Stone 386b9c1b51eSKate Stone size_t CalculateElementHeaderSize(const Element &elem); 38726e52a70SEwan Crawford 388*00f56eebSLuke Drummond void SetConditional(lldb::BreakpointSP bp, lldb_private::Stream &messages, 389*00f56eebSLuke Drummond const lldb_renderscript::RSCoordinate &coord); 39015f2bd95SEwan Crawford // 39115f2bd95SEwan Crawford // Helper functions for jitting the runtime 39215f2bd95SEwan Crawford // 39315f2bd95SEwan Crawford 394b9c1b51eSKate Stone bool JITDataPointer(AllocationDetails *allocation, StackFrame *frame_ptr, 395b3f7f69dSAidan Dodds uint32_t x = 0, uint32_t y = 0, uint32_t z = 0); 39615f2bd95SEwan Crawford 397b9c1b51eSKate Stone bool JITTypePointer(AllocationDetails *allocation, StackFrame *frame_ptr); 39815f2bd95SEwan Crawford 399b9c1b51eSKate Stone bool JITTypePacked(AllocationDetails *allocation, StackFrame *frame_ptr); 40015f2bd95SEwan Crawford 401b9c1b51eSKate Stone bool JITElementPacked(Element &elem, const lldb::addr_t context, 402b9c1b51eSKate Stone StackFrame *frame_ptr); 4038b244e21SEwan Crawford 404b9c1b51eSKate Stone bool JITAllocationSize(AllocationDetails *allocation, StackFrame *frame_ptr); 405a0f08674SEwan Crawford 406b9c1b51eSKate Stone bool JITSubelements(Element &elem, const lldb::addr_t context, 407b9c1b51eSKate Stone StackFrame *frame_ptr); 408b3f7f69dSAidan Dodds 409b9c1b51eSKate Stone bool JITAllocationStride(AllocationDetails *allocation, 410b9c1b51eSKate Stone StackFrame *frame_ptr); 411a0f08674SEwan Crawford 41278f339d1SEwan Crawford // Search for a script detail object using a target address. 41378f339d1SEwan Crawford // If a script does not currently exist this function will return nullptr. 41478f339d1SEwan Crawford // If 'create' is true and there is no previous script with this address, 415b9c1b51eSKate Stone // then a new Script detail object will be created for this address and 416b9c1b51eSKate Stone // returned. 417b9c1b51eSKate Stone ScriptDetails *LookUpScript(lldb::addr_t address, bool create); 41878f339d1SEwan Crawford 419b9c1b51eSKate Stone // Search for a previously saved allocation detail object using a target 420b9c1b51eSKate Stone // address. 421b9c1b51eSKate Stone // If an allocation does not exist for this address then nullptr will be 422b9c1b51eSKate Stone // returned. 423b9c1b51eSKate Stone AllocationDetails *LookUpAllocation(lldb::addr_t address); 4245d057637SLuke Drummond 425b9c1b51eSKate Stone // Creates a new allocation with the specified address assigning a new ID and 426b9c1b51eSKate Stone // removes 4275d057637SLuke Drummond // any previous stored allocation which has the same address. 428b9c1b51eSKate Stone AllocationDetails *CreateAllocation(lldb::addr_t address); 42919459580SLuke Drummond 430b9c1b51eSKate Stone bool GetOverrideExprOptions(clang::TargetOptions &prototype) override; 43119459580SLuke Drummond 432b9c1b51eSKate Stone bool GetIRPasses(LLVMUserExpression::IRPasses &passes) override; 4335ec532a9SColin Riley }; 4345ec532a9SColin Riley 4355ec532a9SColin Riley } // namespace lldb_private 4365ec532a9SColin Riley 4375ec532a9SColin Riley #endif // liblldb_RenderScriptRuntime_h_ 438