Skip to content

Commit

Permalink
Change PlatformPosix::DoLoadImage to use a UtilityFunction.
Browse files Browse the repository at this point in the history
That way we won't have to compile a new expression every time we want
dlopen a library.

<rdar://problem/32626584> 

Differential Revision: https://reviews.llvm.org/D45703

llvm-svn: 330214
  • Loading branch information
jimingham committed Apr 17, 2018
1 parent f483279 commit 1ecb34f
Show file tree
Hide file tree
Showing 4 changed files with 321 additions and 50 deletions.
50 changes: 50 additions & 0 deletions lldb/include/lldb/Target/Process.h
Expand Up @@ -807,6 +807,54 @@ class Process : public std::enable_shared_from_this<Process>,
return error;
}

//------------------------------------------------------------------
// FUTURE WORK: {Set,Get}LoadImageUtilityFunction are the first use we've
// had of having other plugins cache data in the Process. This is handy for
// long-living plugins - like the Platform - which manage interactions whose
// lifetime is governed by the Process lifetime. If we find we need to do
// this more often, we should construct a general solution to the problem.
// The consensus suggestion was that we have a token based registry in the
// Process.
// Some undecided questions are
// (1) who manages the tokens. It's probably best that you add the element
// and get back a token that represents it. That will avoid collisions. But
// there may be some utility in the registerer controlling the token?
// (2) whether the thing added should be simply owned by Process, and
// just go away when it does
// (3) whether the registree should be notified of the Process' demise.
//
// We are postponing designing this till we have at least a second use case.
//------------------------------------------------------------------
//------------------------------------------------------------------
/// Set the cached UtilityFunction that assists in loading binary
/// images into the process.
///
/// This UtilityFunction is maintained in the Process since the Platforms
/// don't track the lifespan of the Targets/Processes that use them.
/// But it is not intended to be comprehended by the Process, it's up to the
/// Platform that set it to do it right.
///
/// @param[in] utility_func_up
/// The incoming utility_function. The process will manage the function's
/// lifetime.
///
//------------------------------------------------------------------
void SetLoadImageUtilityFunction(std::unique_ptr<UtilityFunction>
utility_func_up);

//------------------------------------------------------------------
/// Get the cached UtilityFunction that assists in loading binary
/// images into the process.
///
/// @param[in] platform
/// The platform fetching the UtilityFunction.
///
/// @return
/// The cached utility function or null if the platform is not the
/// same as the target's platform.
//------------------------------------------------------------------
UtilityFunction *GetLoadImageUtilityFunction(Platform *platform);

//------------------------------------------------------------------
/// Get the dynamic loader plug-in for this process.
///
Expand Down Expand Up @@ -3132,6 +3180,8 @@ class Process : public std::enable_shared_from_this<Process>,
StructuredDataPluginMap m_structured_data_plugin_map;

enum { eCanJITDontKnow = 0, eCanJITYes, eCanJITNo } m_can_jit;

std::unique_ptr<UtilityFunction> m_dlopen_utility_func_up;

size_t RemoveBreakpointOpcodesFromBuffer(lldb::addr_t addr, size_t size,
uint8_t *buf) const;
Expand Down

0 comments on commit 1ecb34f

Please sign in to comment.