Skip to content

Commit 5af0047

Browse files
committed
Move to void* buffer instead of data buffer heap
1 parent 42e84ed commit 5af0047

File tree

3 files changed

+130
-130
lines changed

3 files changed

+130
-130
lines changed

lldb/include/lldb/Target/Process.h

Lines changed: 73 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,11 @@ class Process : public std::enable_shared_from_this<Process>,
396396
return GetStaticBroadcasterClass();
397397
}
398398

399-
/// A notification structure that can be used by clients to listen
400-
/// for changes in a process's lifetime.
401-
///
402-
/// \see RegisterNotificationCallbacks (const Notifications&) @see
403-
/// UnregisterNotificationCallbacks (const Notifications&)
399+
/// A notification structure that can be used by clients to listen
400+
/// for changes in a process's lifetime.
401+
///
402+
/// \see RegisterNotificationCallbacks (const Notifications&) @see
403+
/// UnregisterNotificationCallbacks (const Notifications&)
404404
typedef struct {
405405
void *baton;
406406
void (*initialize)(void *baton, Process *process);
@@ -771,7 +771,7 @@ class Process : public std::enable_shared_from_this<Process>,
771771
///
772772
/// \return
773773
/// The constant reference to the member m_image_tokens.
774-
const std::vector<lldb::addr_t>& GetImageTokens() { return m_image_tokens; }
774+
const std::vector<lldb::addr_t> &GetImageTokens() { return m_image_tokens; }
775775

776776
/// Get the image information address for the current process.
777777
///
@@ -801,32 +801,32 @@ class Process : public std::enable_shared_from_this<Process>,
801801
/// public clients.
802802
virtual void WillPublicStop() {}
803803

804-
/// Register for process and thread notifications.
805-
///
806-
/// Clients can register notification callbacks by filling out a
807-
/// Process::Notifications structure and calling this function.
808-
///
809-
/// \param[in] callbacks
810-
/// A structure that contains the notification baton and
811-
/// callback functions.
812-
///
813-
/// \see Process::Notifications
804+
/// Register for process and thread notifications.
805+
///
806+
/// Clients can register notification callbacks by filling out a
807+
/// Process::Notifications structure and calling this function.
808+
///
809+
/// \param[in] callbacks
810+
/// A structure that contains the notification baton and
811+
/// callback functions.
812+
///
813+
/// \see Process::Notifications
814814
void RegisterNotificationCallbacks(const Process::Notifications &callbacks);
815815

816-
/// Unregister for process and thread notifications.
817-
///
818-
/// Clients can unregister notification callbacks by passing a copy of the
819-
/// original baton and callbacks in \a callbacks.
820-
///
821-
/// \param[in] callbacks
822-
/// A structure that contains the notification baton and
823-
/// callback functions.
824-
///
825-
/// \return
826-
/// Returns \b true if the notification callbacks were
827-
/// successfully removed from the process, \b false otherwise.
828-
///
829-
/// \see Process::Notifications
816+
/// Unregister for process and thread notifications.
817+
///
818+
/// Clients can unregister notification callbacks by passing a copy of the
819+
/// original baton and callbacks in \a callbacks.
820+
///
821+
/// \param[in] callbacks
822+
/// A structure that contains the notification baton and
823+
/// callback functions.
824+
///
825+
/// \return
826+
/// Returns \b true if the notification callbacks were
827+
/// successfully removed from the process, \b false otherwise.
828+
///
829+
/// \see Process::Notifications
830830
bool UnregisterNotificationCallbacks(const Process::Notifications &callbacks);
831831

832832
//==================================================================
@@ -1592,14 +1592,13 @@ class Process : public std::enable_shared_from_this<Process>,
15921592
// Callback definition for read Memory in chunks
15931593
//
15941594
// Status, the status returned from ReadMemoryFromInferior
1595-
// DataBufferHeap, buffer with bytes potentially written to it
1595+
// uint8_t*, pointer to the bytes read
15961596
// addr_t, the current_addr, start + bytes read so far.
15971597
// uint64_t bytes_to_read, the expected bytes read, this
15981598
// is important if it's a partial read
15991599
// uint64_t bytes_read_for_chunk, the actual count of bytes read for this
16001600
// chunk
1601-
typedef std::function<IterationAction(lldb_private::Status &,
1602-
lldb_private::DataBufferHeap &,
1601+
typedef std::function<IterationAction(lldb_private::Status &, const void *,
16031602
lldb::addr_t, uint64_t, uint64_t)>
16041603
ReadMemoryChunkCallback;
16051604

@@ -1611,9 +1610,13 @@ class Process : public std::enable_shared_from_this<Process>,
16111610
/// A virtual load address that indicates where to start reading
16121611
/// memory from.
16131612
///
1614-
/// \param[in] data
1615-
/// The data buffer heap to use to read the chunk. The chunk size
1616-
/// depends upon the byte size of the buffer.
1613+
/// \param[out] buf
1614+
/// A byte buffer that is at least \a chunk_size bytes long that
1615+
/// will receive the memory bytes.
1616+
///
1617+
/// \param[in] chunk_size
1618+
/// The chunk size to use when reading, a local buffer will be created
1619+
/// with a pointer passed to the callback
16171620
///
16181621
/// \param[in] size
16191622
/// The number of bytes to read.
@@ -1628,8 +1631,9 @@ class Process : public std::enable_shared_from_this<Process>,
16281631
/// size, then this function will get called again with \a
16291632
/// vm_addr, \a buf, and \a size updated appropriately. Zero is
16301633
/// returned in the case of an error.
1631-
size_t ReadMemoryInChunks(lldb::addr_t vm_addr, DataBufferHeap &data,
1632-
size_t size, ReadMemoryChunkCallback callback);
1634+
size_t ReadMemoryInChunks(lldb::addr_t vm_addr, void *buf,
1635+
lldb::addr_t chunk_size, size_t size,
1636+
ReadMemoryChunkCallback callback);
16331637

16341638
/// Read a NULL terminated C string from memory
16351639
///
@@ -1944,8 +1948,7 @@ class Process : public std::enable_shared_from_this<Process>,
19441948
///
19451949
/// \return
19461950
/// An error value.
1947-
virtual Status
1948-
GetMemoryRegions(lldb_private::MemoryRegionInfos &region_list);
1951+
virtual Status GetMemoryRegions(lldb_private::MemoryRegionInfos &region_list);
19491952

19501953
/// Get the number of watchpoints supported by this target.
19511954
///
@@ -2286,14 +2289,12 @@ class Process : public std::enable_shared_from_this<Process>,
22862289
// If we are waiting to stop that will return control to the user,
22872290
// then we also want to run SelectMostRelevantFrame, which is controlled
22882291
// by "select_most_relevant".
2289-
lldb::StateType
2290-
WaitForProcessToStop(const Timeout<std::micro> &timeout,
2291-
lldb::EventSP *event_sp_ptr = nullptr,
2292-
bool wait_always = true,
2293-
lldb::ListenerSP hijack_listener = lldb::ListenerSP(),
2294-
Stream *stream = nullptr, bool use_run_lock = true,
2295-
SelectMostRelevant select_most_relevant =
2296-
DoNoSelectMostRelevantFrame);
2292+
lldb::StateType WaitForProcessToStop(
2293+
const Timeout<std::micro> &timeout, lldb::EventSP *event_sp_ptr = nullptr,
2294+
bool wait_always = true,
2295+
lldb::ListenerSP hijack_listener = lldb::ListenerSP(),
2296+
Stream *stream = nullptr, bool use_run_lock = true,
2297+
SelectMostRelevant select_most_relevant = DoNoSelectMostRelevantFrame);
22972298

22982299
uint32_t GetIOHandlerID() const { return m_iohandler_sync.GetValue(); }
22992300

@@ -2394,17 +2395,17 @@ class Process : public std::enable_shared_from_this<Process>,
23942395

23952396
void SetDynamicCheckers(DynamicCheckerFunctions *dynamic_checkers);
23962397

2397-
/// Prune ThreadPlanStacks for unreported threads.
2398-
///
2399-
/// \param[in] tid
2400-
/// The tid whose Plan Stack we are seeking to prune.
2401-
///
2402-
/// \return
2403-
/// \b true if the TID is found or \b false if not.
2404-
bool PruneThreadPlansForTID(lldb::tid_t tid);
2398+
/// Prune ThreadPlanStacks for unreported threads.
2399+
///
2400+
/// \param[in] tid
2401+
/// The tid whose Plan Stack we are seeking to prune.
2402+
///
2403+
/// \return
2404+
/// \b true if the TID is found or \b false if not.
2405+
bool PruneThreadPlansForTID(lldb::tid_t tid);
24052406

2406-
/// Prune ThreadPlanStacks for all unreported threads.
2407-
void PruneThreadPlans();
2407+
/// Prune ThreadPlanStacks for all unreported threads.
2408+
void PruneThreadPlans();
24082409

24092410
/// Find the thread plan stack associated with thread with \a tid.
24102411
///
@@ -3093,7 +3094,7 @@ void PruneThreadPlans();
30933094
PreResumeCallbackAndBaton(PreResumeActionCallback in_callback,
30943095
void *in_baton)
30953096
: callback(in_callback), baton(in_baton) {}
3096-
bool operator== (const PreResumeCallbackAndBaton &rhs) {
3097+
bool operator==(const PreResumeCallbackAndBaton &rhs) {
30973098
return callback == rhs.callback && baton == rhs.baton;
30983099
}
30993100
};
@@ -3114,26 +3115,26 @@ void PruneThreadPlans();
31143115
lldb::ListenerSP m_private_state_listener_sp; // This is the listener for the
31153116
// private state thread.
31163117
HostThread m_private_state_thread; ///< Thread ID for the thread that watches
3117-
///internal state events
3118+
/// internal state events
31183119
ProcessModID m_mod_id; ///< Tracks the state of the process over stops and
3119-
///other alterations.
3120+
/// other alterations.
31203121
uint32_t m_process_unique_id; ///< Each lldb_private::Process class that is
3121-
///created gets a unique integer ID that
3122-
///increments with each new instance
3122+
/// created gets a unique integer ID that
3123+
/// increments with each new instance
31233124
uint32_t m_thread_index_id; ///< Each thread is created with a 1 based index
3124-
///that won't get re-used.
3125+
/// that won't get re-used.
31253126
std::map<uint64_t, uint32_t> m_thread_id_to_index_id_map;
31263127
int m_exit_status; ///< The exit status of the process, or -1 if not set.
31273128
std::string m_exit_string; ///< A textual description of why a process exited.
31283129
std::mutex m_exit_status_mutex; ///< Mutex so m_exit_status m_exit_string can
3129-
///be safely accessed from multiple threads
3130+
/// be safely accessed from multiple threads
31303131
std::recursive_mutex m_thread_mutex;
31313132
ThreadList m_thread_list_real; ///< The threads for this process as are known
3132-
///to the protocol we are debugging with
3133+
/// to the protocol we are debugging with
31333134
ThreadList m_thread_list; ///< The threads for this process as the user will
3134-
///see them. This is usually the same as
3135+
/// see them. This is usually the same as
31353136
///< m_thread_list_real, but might be different if there is an OS plug-in
3136-
///creating memory threads
3137+
/// creating memory threads
31373138
ThreadPlanStackMap m_thread_plans; ///< This is the list of thread plans for
31383139
/// threads in m_thread_list, as well as
31393140
/// threads we knew existed, but haven't
@@ -3142,16 +3143,16 @@ void PruneThreadPlans();
31423143
m_extended_thread_list; ///< Constituent for extended threads that may be
31433144
/// generated, cleared on natural stops
31443145
lldb::RunDirection m_base_direction; ///< ThreadPlanBase run direction
3145-
uint32_t m_extended_thread_stop_id; ///< The natural stop id when
3146-
///extended_thread_list was last updated
3146+
uint32_t m_extended_thread_stop_id; ///< The natural stop id when
3147+
/// extended_thread_list was last updated
31473148
QueueList
31483149
m_queue_list; ///< The list of libdispatch queues at a given stop point
31493150
uint32_t m_queue_list_stop_id; ///< The natural stop id when queue list was
3150-
///last fetched
3151+
/// last fetched
31513152
StopPointSiteList<lldb_private::WatchpointResource>
31523153
m_watchpoint_resource_list; ///< Watchpoint resources currently in use.
31533154
std::vector<Notifications> m_notifications; ///< The list of notifications
3154-
///that this process can deliver.
3155+
/// that this process can deliver.
31553156
std::vector<lldb::addr_t> m_image_tokens;
31563157
StopPointSiteList<lldb_private::BreakpointSite>
31573158
m_breakpoint_site_list; ///< This is the list of breakpoint

lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ Status MinidumpFileBuilder::ReadWriteMemoryInChunks(
976976
Log *log = GetLog(LLDBLog::Object);
977977
Status addDataError;
978978
Process::ReadMemoryChunkCallback callback =
979-
[&](Status &error, DataBufferHeap &data, lldb::addr_t current_addr,
979+
[&](Status &error, const void *buf, lldb::addr_t current_addr,
980980
uint64_t bytes_to_read,
981981
uint64_t bytes_read_for_chunk) -> lldb_private::IterationAction {
982982
if (error.Fail() || bytes_read_for_chunk == 0) {
@@ -1000,7 +1000,7 @@ Status MinidumpFileBuilder::ReadWriteMemoryInChunks(
10001000
// This error will be captured by the outer scope and is considered fatal.
10011001
// If we get an error writing to disk we can't easily guarauntee that we
10021002
// won't corrupt the minidump.
1003-
addDataError = AddData(data_buffer.GetBytes(), bytes_read_for_chunk);
1003+
addDataError = AddData(buf, bytes_read_for_chunk);
10041004
if (addDataError.Fail())
10051005
return lldb_private::IterationAction::Stop;
10061006

@@ -1022,8 +1022,8 @@ Status MinidumpFileBuilder::ReadWriteMemoryInChunks(
10221022

10231023
const lldb::addr_t addr = range.range.start();
10241024
const lldb::addr_t size = range.range.size();
1025-
bytes_read =
1026-
m_process_sp->ReadMemoryInChunks(addr, data_buffer, size, callback);
1025+
bytes_read = m_process_sp->ReadMemoryInChunks(
1026+
addr, data_buffer.GetBytes(), data_buffer.GetByteSize(), size, callback);
10271027
return addDataError;
10281028
}
10291029

0 commit comments

Comments
 (0)