25#define LLDB_OPTIONS_thread_trace_start_intel_pt
26#include "TraceIntelPTCommandOptions.inc"
29 uint32_t option_idx, llvm::StringRef option_arg,
34 switch (short_option) {
36 if (std::optional<uint64_t> bytes =
40 error.SetErrorStringWithFormat(
"invalid bytes expression for '%s'",
41 option_arg.str().c_str());
50 if (option_arg.empty() || option_arg.getAsInteger(0, psb_period) ||
52 error.SetErrorStringWithFormat(
"invalid integer value for option '%s'",
53 option_arg.str().c_str());
59 llvm_unreachable(
"Unimplemented option");
71llvm::ArrayRef<OptionDefinition>
73 return llvm::ArrayRef(g_thread_trace_start_intel_pt_options);
78 llvm::ArrayRef<lldb::tid_t> tids) {
90#define LLDB_OPTIONS_process_trace_start_intel_pt
91#include "TraceIntelPTCommandOptions.inc"
94 uint32_t option_idx, llvm::StringRef option_arg,
97 const int short_option = m_getopt_table[option_idx].val;
99 switch (short_option) {
101 if (std::optional<uint64_t> bytes =
103 m_ipt_trace_size = *bytes;
105 error.SetErrorStringWithFormat(
"invalid bytes expression for '%s'",
106 option_arg.str().c_str());
110 if (std::optional<uint64_t> bytes =
112 m_process_buffer_size_limit = *bytes;
114 error.SetErrorStringWithFormat(
"invalid bytes expression for '%s'",
115 option_arg.str().c_str());
123 m_per_cpu_tracing =
true;
127 m_disable_cgroup_filtering =
true;
132 if (option_arg.empty() || option_arg.getAsInteger(0, psb_period) ||
134 error.SetErrorStringWithFormat(
"invalid integer value for option '%s'",
135 option_arg.str().c_str());
137 m_psb_period = psb_period;
141 llvm_unreachable(
"Unimplemented option");
156llvm::ArrayRef<OptionDefinition>
158 return llvm::ArrayRef(g_process_trace_start_intel_pt_options);
172std::optional<uint64_t>
174 if (size_expression.empty()) {
177 const uint64_t kBytesMultiplier = 1;
178 const uint64_t kKibiBytesMultiplier = 1024;
179 const uint64_t kMebiBytesMultiplier = 1024 * 1024;
181 DenseMap<StringRef, uint64_t> multipliers = {
182 {
"mib", kMebiBytesMultiplier}, {
"mb", kMebiBytesMultiplier},
183 {
"m", kMebiBytesMultiplier}, {
"kib", kKibiBytesMultiplier},
184 {
"kb", kKibiBytesMultiplier}, {
"k", kKibiBytesMultiplier},
185 {
"b", kBytesMultiplier}, {
"", kBytesMultiplier}};
187 const auto non_digit_index = size_expression.find_first_not_of(
"0123456789");
188 if (non_digit_index == 0) {
192 const llvm::StringRef number_part =
193 non_digit_index == llvm::StringRef::npos
195 : size_expression.substr(0, non_digit_index);
196 uint64_t parsed_number;
197 if (number_part.getAsInteger(10, parsed_number)) {
201 if (non_digit_index != llvm::StringRef::npos) {
202 const auto multiplier = size_expression.substr(non_digit_index).lower();
204 auto it = multipliers.find(multiplier);
205 if (it == multipliers.end())
208 return parsed_number * it->second;
210 return parsed_number;
static llvm::raw_ostream & error(Stream &strm)
A command line argument class.
void SetStatus(lldb::ReturnStatus status)
void SetError(const Status &error, const char *fallback_error_cstr=nullptr)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
std::vector< Option > m_getopt_table
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
void OptionParsingStarting(ExecutionContext *execution_context) override
void DoExecute(Args &command, CommandReturnObject &result) override
std::optional< uint64_t > m_psb_period
uint64_t m_ipt_trace_size
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_arg, ExecutionContext *execution_context) override
Set the value of an option.
void OptionParsingStarting(ExecutionContext *execution_context) override
bool DoExecuteOnThreads(Args &command, CommandReturnObject &result, llvm::ArrayRef< lldb::tid_t > tids) override
Method that handles the command after the main arguments have been parsed.
llvm::Error Start(uint64_t ipt_trace_size, uint64_t total_buffer_size_limit, bool enable_tsc, std::optional< uint64_t > psb_period, bool m_per_cpu_tracing, bool disable_cgroup_filtering)
Start tracing a live process.
std::optional< uint64_t > ParseUserFriendlySizeExpression(llvm::StringRef size_expression)
Convert an integral size expression like 12KiB or 4MB into bytes.
const bool kDefaultPerCpuTracing
const std::optional< size_t > kDefaultPsbPeriod
const bool kDefaultDisableCgroupFiltering
const size_t kDefaultIptTraceSize
const bool kDefaultEnableTscValue
const size_t kDefaultProcessBufferSizeLimit
A class that represents a running process on the host machine.
@ eReturnStatusSuccessFinishResult