A lot of comments in LLDB are surrounded by an ASCII line to delimit the begging and end of the comment. Its use is not really consistent across the code base, sometimes the lines are longer, sometimes they are shorter and sometimes they are omitted. Furthermore, it looks kind of weird with the 80 column limit, where the comment actually extends past the line, but not by much. Furthermore, when /// is used for Doxygen comments, it looks particularly odd. And when // is used, it incorrectly gives the impression that it's actually a Doxygen comment. I assume these lines were added to improve distinguishing between comments and code. However, given that todays editors and IDEs do a great job at highlighting comments, I think it's worth to drop this for the sake of consistency. The alternative is fixing all the inconsistencies, which would create a lot more churn. Differential revision: https://reviews.llvm.org/D60508 llvm-svn: 358135
112 lines
3.9 KiB
C++
112 lines
3.9 KiB
C++
//===-- AppleGetThreadItemInfoHandler.h ----------------------------*- C++
|
|
//-*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef lldb_AppleGetThreadItemInfoHandler_h_
|
|
#define lldb_AppleGetThreadItemInfoHandler_h_
|
|
|
|
#include <map>
|
|
#include <mutex>
|
|
#include <vector>
|
|
|
|
#include "lldb/Symbol/CompilerType.h"
|
|
#include "lldb/Utility/Status.h"
|
|
#include "lldb/lldb-public.h"
|
|
|
|
// This class will insert a UtilityFunction into the inferior process for
|
|
// calling libBacktraceRecording's
|
|
// __introspection_dispatch_thread_get_item_info()
|
|
// function. The function in the inferior will return a struct by value
|
|
// with these members:
|
|
//
|
|
// struct get_thread_item_info_return_values
|
|
// {
|
|
// introspection_dispatch_item_info_ref *item_buffer;
|
|
// uint64_t item_buffer_size;
|
|
// };
|
|
//
|
|
// The item_buffer pointer is an address in the inferior program's address
|
|
// space (item_buffer_size in size) which must be mach_vm_deallocate'd by
|
|
// lldb.
|
|
//
|
|
// The AppleGetThreadItemInfoHandler object should persist so that the
|
|
// UtilityFunction
|
|
// can be reused multiple times.
|
|
|
|
namespace lldb_private {
|
|
|
|
class AppleGetThreadItemInfoHandler {
|
|
public:
|
|
AppleGetThreadItemInfoHandler(lldb_private::Process *process);
|
|
|
|
~AppleGetThreadItemInfoHandler();
|
|
|
|
struct GetThreadItemInfoReturnInfo {
|
|
lldb::addr_t item_buffer_ptr; /* the address of the item buffer from
|
|
libBacktraceRecording */
|
|
lldb::addr_t item_buffer_size; /* the size of the item buffer from
|
|
libBacktraceRecording */
|
|
|
|
GetThreadItemInfoReturnInfo()
|
|
: item_buffer_ptr(LLDB_INVALID_ADDRESS), item_buffer_size(0) {}
|
|
};
|
|
|
|
/// Get the information about a work item by calling
|
|
/// __introspection_dispatch_thread_get_item_info. If there's a page of
|
|
/// memory that needs to be freed, pass in the address and size and it will
|
|
/// be freed before getting the list of queues.
|
|
///
|
|
/// \param [in] thread_id
|
|
/// The thread to get the extended backtrace for.
|
|
///
|
|
/// \param [in] page_to_free
|
|
/// An address of an inferior process vm page that needs to be
|
|
/// deallocated,
|
|
/// LLDB_INVALID_ADDRESS if this is not needed.
|
|
///
|
|
/// \param [in] page_to_free_size
|
|
/// The size of the vm page that needs to be deallocated if an address was
|
|
/// passed in to page_to_free.
|
|
///
|
|
/// \param [out] error
|
|
/// This object will be updated with the error status / error string from
|
|
/// any failures encountered.
|
|
///
|
|
/// \returns
|
|
/// The result of the inferior function call execution. If there was a
|
|
/// failure of any kind while getting
|
|
/// the information, the item_buffer_ptr value will be
|
|
/// LLDB_INVALID_ADDRESS.
|
|
GetThreadItemInfoReturnInfo GetThreadItemInfo(Thread &thread,
|
|
lldb::tid_t thread_id,
|
|
lldb::addr_t page_to_free,
|
|
uint64_t page_to_free_size,
|
|
lldb_private::Status &error);
|
|
|
|
void Detach();
|
|
|
|
private:
|
|
lldb::addr_t
|
|
SetupGetThreadItemInfoFunction(Thread &thread,
|
|
ValueList &get_thread_item_info_arglist);
|
|
|
|
static const char *g_get_thread_item_info_function_name;
|
|
static const char *g_get_thread_item_info_function_code;
|
|
|
|
lldb_private::Process *m_process;
|
|
std::unique_ptr<UtilityFunction> m_get_thread_item_info_impl_code;
|
|
std::mutex m_get_thread_item_info_function_mutex;
|
|
|
|
lldb::addr_t m_get_thread_item_info_return_buffer_addr;
|
|
std::mutex m_get_thread_item_info_retbuffer_mutex;
|
|
};
|
|
|
|
} // using namespace lldb_private
|
|
|
|
#endif // lldb_AppleGetThreadItemInfoHandler_h_
|