LLDB  mainline
OptionGroupOutputFile.cpp
Go to the documentation of this file.
1 //===-- OptionGroupOutputFile.cpp -------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
10 
11 #include "lldb/Host/OptionParser.h"
12 
13 using namespace lldb;
14 using namespace lldb_private;
15 
16 OptionGroupOutputFile::OptionGroupOutputFile()
17  : m_file(), m_append(false, false) {}
18 
20 
21 static const uint32_t SHORT_OPTION_APND = 0x61706e64; // 'apnd'
22 
23 static constexpr OptionDefinition g_option_table[] = {
24  {LLDB_OPT_SET_1, false, "outfile", 'o', OptionParser::eRequiredArgument,
25  nullptr, {}, 0, eArgTypeFilename,
26  "Specify a path for capturing command output."},
27  {LLDB_OPT_SET_1, false, "append-outfile", SHORT_OPTION_APND,
28  OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone,
29  "Append to the file specified with '--outfile <path>'."},
30 };
31 
32 llvm::ArrayRef<OptionDefinition> OptionGroupOutputFile::GetDefinitions() {
33  return llvm::makeArrayRef(g_option_table);
34 }
35 
36 Status
38  llvm::StringRef option_arg,
39  ExecutionContext *execution_context) {
40  Status error;
41  const int short_option = g_option_table[option_idx].short_option;
42 
43  switch (short_option) {
44  case 'o':
45  error = m_file.SetValueFromString(option_arg);
46  break;
47 
48  case SHORT_OPTION_APND:
50  break;
51 
52  default:
53  error.SetErrorStringWithFormat("unrecognized option '%c'", short_option);
54  break;
55  }
56 
57  return error;
58 }
59 
61  ExecutionContext *execution_context) {
62  m_file.Clear();
63  m_append.Clear();
64 }
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
llvm::ArrayRef< OptionDefinition > GetDefinitions() override
void OptionParsingStarting(ExecutionContext *execution_context) override
static const uint32_t SHORT_OPTION_APND
Status SetOptionValue(uint32_t option_idx, llvm::StringRef option_value, ExecutionContext *execution_context) override
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
static constexpr OptionDefinition g_option_table[]
Definition: SBAddress.h:15
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Set the current error string to a formatted error string.
Definition: Status.cpp:255
#define LLDB_OPT_SET_1
Definition: lldb-defines.h:111
An error handling class.
Definition: Status.h:44