From b3bbcb122904b55ae3a5906bc107cc356ca1123d Mon Sep 17 00:00:00 2001 From: Luke Drummond Date: Wed, 5 Oct 2016 19:10:47 +0000 Subject: Add the ability to set breakpoints on named RenderScript reductions - Add new `lldb_private::lldb_renderscript::RSReduceBreakpointResolver` class that can set breakpoints on kernels that are constituent functions of named reduction groups. Also support debugging of subsets of the the reduction group with the `-t, --function-role` flag which takes a comma-separated list of reduction function types outconverter,combiner,initializer,accumulator (defaults to all) - Add 2 new helper methods to `RenderScriptRuntime`, 1. `CreateReductionBreakpoint(name, types)`: instantiates a new RSReduceBreakpointResolver and inserts that resolver into the running process. 2. `PlaceBreakpointOnReduction`: which is a public helper function. - hook up the above functionality to the command-line with new `CommandObject*` classes that handle parsing of function roles and dispatch to the runtime. These are namespaced under the snappy `language renderscript reduction breakpoint ...` subcommand - [incidental] Factor multiple common uses of `FindFirstSymbolWithNameAndType(ConstString(".rs.info")` into static `IsRenderScriptScriptModule(ModuleSP module)` function, and replace original uses. llvm-svn: 283362 --- .../RenderScriptRuntime/RenderScriptRuntime.h | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h') diff --git a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h index a699ad8a8dc..41b9d9a0bac 100644 --- a/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h +++ b/lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h @@ -84,6 +84,58 @@ protected: ConstString m_kernel_name; }; +class RSReduceBreakpointResolver : public BreakpointResolver { +public: + enum ReduceKernelTypeFlags { + eKernelTypeAll = ~(0), + eKernelTypeNone = 0, + eKernelTypeAccum = (1 << 0), + eKernelTypeInit = (1 << 1), + eKernelTypeComb = (1 << 2), + eKernelTypeOutC = (1 << 3), + eKernelTypeHalter = (1 << 4) + }; + + RSReduceBreakpointResolver( + Breakpoint *breakpoint, ConstString reduce_name, + std::vector *rs_modules, + int kernel_types = eKernelTypeAll) + : BreakpointResolver(breakpoint, BreakpointResolver::NameResolver), + m_reduce_name(reduce_name), m_rsmodules(rs_modules), + m_kernel_types(kernel_types) { + // The reduce breakpoint resolver handles adding breakpoints for named + // reductions. + // Breakpoints will be resolved for all constituent kernels in the named + // reduction + } + + void GetDescription(Stream *strm) override { + if (strm) + strm->Printf("RenderScript reduce breakpoint for '%s'", + m_reduce_name.AsCString()); + } + + void Dump(Stream *s) const override {} + + Searcher::CallbackReturn SearchCallback(SearchFilter &filter, + SymbolContext &context, Address *addr, + bool containing) override; + + Searcher::Depth GetDepth() override { return Searcher::eDepthModule; } + + lldb::BreakpointResolverSP + CopyForBreakpoint(Breakpoint &breakpoint) override { + lldb::BreakpointResolverSP ret_sp(new RSReduceBreakpointResolver( + &breakpoint, m_reduce_name, m_rsmodules, m_kernel_types)); + return ret_sp; + } + +private: + ConstString m_reduce_name; // The name of the reduction + std::vector *m_rsmodules; + int m_kernel_types; +}; + struct RSKernelDescriptor { public: RSKernelDescriptor(const RSModuleDescriptor *module, llvm::StringRef name, @@ -247,6 +299,11 @@ public: lldb::TargetSP target, Stream &messages, const char *name, const lldb_renderscript::RSCoordinate *coords = nullptr); + bool PlaceBreakpointOnReduction( + lldb::TargetSP target, Stream &messages, const char *reduce_name, + const lldb_renderscript::RSCoordinate *coords = nullptr, + int kernel_types = ~(0)); + void SetBreakAllKernels(bool do_break, lldb::TargetSP target); void Status(Stream &strm) const; @@ -294,6 +351,9 @@ protected: lldb::BreakpointSP CreateKernelBreakpoint(const ConstString &name); + lldb::BreakpointSP CreateReductionBreakpoint(const ConstString &name, + int kernel_types); + void BreakOnModuleKernels( const lldb_renderscript::RSModuleDescriptorSP rsmodule_sp); -- cgit v1.2.3