2020-01-24 08:23:27 +01:00
|
|
|
//===-- OptionGroupOutputFile.cpp -----------------------------------------===//
|
2011-04-27 22:04:39 +00:00
|
|
|
//
|
2019-01-19 08:50:56 +00:00
|
|
|
// 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
|
2011-04-27 22:04:39 +00:00
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
2011-05-13 20:21:08 +00:00
|
|
|
#include "lldb/Interpreter/OptionGroupOutputFile.h"
|
2011-04-27 22:04:39 +00:00
|
|
|
|
2017-03-22 23:33:16 +00:00
|
|
|
#include "lldb/Host/OptionParser.h"
|
2011-04-27 22:04:39 +00:00
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
|
|
OptionGroupOutputFile::OptionGroupOutputFile()
|
|
|
|
|
: m_file(), m_append(false, false) {}
|
|
|
|
|
|
|
|
|
|
OptionGroupOutputFile::~OptionGroupOutputFile() {}
|
|
|
|
|
|
2014-03-18 04:43:47 +00:00
|
|
|
static const uint32_t SHORT_OPTION_APND = 0x61706e64; // 'apnd'
|
|
|
|
|
|
2018-09-26 18:50:19 +00:00
|
|
|
static constexpr OptionDefinition g_option_table[] = {
|
2014-07-09 16:31:49 +00:00
|
|
|
{LLDB_OPT_SET_1, false, "outfile", 'o', OptionParser::eRequiredArgument,
|
2018-09-26 18:50:19 +00:00
|
|
|
nullptr, {}, 0, eArgTypeFilename,
|
2014-07-09 16:31:49 +00:00
|
|
|
"Specify a path for capturing command output."},
|
2014-03-18 04:43:47 +00:00
|
|
|
{LLDB_OPT_SET_1, false, "append-outfile", SHORT_OPTION_APND,
|
2018-09-26 18:50:19 +00:00
|
|
|
OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone,
|
2015-06-18 05:27:05 +00:00
|
|
|
"Append to the file specified with '--outfile <path>'."},
|
2011-04-27 22:04:39 +00:00
|
|
|
};
|
|
|
|
|
|
2016-09-22 20:22:55 +00:00
|
|
|
llvm::ArrayRef<OptionDefinition> OptionGroupOutputFile::GetDefinitions() {
|
2016-09-22 21:06:13 +00:00
|
|
|
return llvm::makeArrayRef(g_option_table);
|
2011-04-27 22:04:39 +00:00
|
|
|
}
|
|
|
|
|
|
2017-05-12 04:51:55 +00:00
|
|
|
Status
|
|
|
|
|
OptionGroupOutputFile::SetOptionValue(uint32_t option_idx,
|
|
|
|
|
llvm::StringRef option_arg,
|
|
|
|
|
ExecutionContext *execution_context) {
|
|
|
|
|
Status error;
|
2012-12-04 00:32:51 +00:00
|
|
|
const int short_option = g_option_table[option_idx].short_option;
|
2011-04-27 22:04:39 +00:00
|
|
|
|
|
|
|
|
switch (short_option) {
|
|
|
|
|
case 'o':
|
2015-02-20 11:14:59 +00:00
|
|
|
error = m_file.SetValueFromString(option_arg);
|
2011-04-27 22:04:39 +00:00
|
|
|
break;
|
|
|
|
|
|
2014-03-18 04:43:47 +00:00
|
|
|
case SHORT_OPTION_APND:
|
2011-04-27 22:04:39 +00:00
|
|
|
m_append.SetCurrentValue(true);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2019-08-22 08:08:05 +00:00
|
|
|
llvm_unreachable("Unimplemented option");
|
2011-04-27 22:04:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return error;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-11 23:51:28 +00:00
|
|
|
void OptionGroupOutputFile::OptionParsingStarting(
|
|
|
|
|
ExecutionContext *execution_context) {
|
2011-04-27 22:04:39 +00:00
|
|
|
m_file.Clear();
|
|
|
|
|
m_append.Clear();
|
|
|
|
|
}
|