2011-04-28 06:04:39 +08:00
|
|
|
//===-- OptionGroupOutputFile.cpp -------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-05-14 04:21:08 +08:00
|
|
|
#include "lldb/Interpreter/OptionGroupOutputFile.h"
|
2011-04-28 06:04:39 +08:00
|
|
|
|
|
|
|
// C Includes
|
|
|
|
// C++ Includes
|
|
|
|
// Other libraries and framework includes
|
|
|
|
// Project includes
|
2011-09-10 08:48:33 +08:00
|
|
|
#include "lldb/Utility/Utils.h"
|
2011-04-28 06:04:39 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
OptionGroupOutputFile::OptionGroupOutputFile() :
|
|
|
|
m_file (),
|
|
|
|
m_append (false, false)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
OptionGroupOutputFile::~OptionGroupOutputFile ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static OptionDefinition
|
|
|
|
g_option_table[] =
|
|
|
|
{
|
2012-10-24 09:12:14 +08:00
|
|
|
{ LLDB_OPT_SET_1 , false, "outfile", 'o', required_argument, NULL, 0, eArgTypeFilename , "Specify a path for capturing command output."},
|
2012-12-04 08:32:51 +08:00
|
|
|
{ LLDB_OPT_SET_1 , false, "append-outfile" , 'apnd', no_argument, NULL, 0, eArgTypeNone , "Append to the the file specified with '--outfile <path>'."},
|
2011-04-28 06:04:39 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
OptionGroupOutputFile::GetNumDefinitions ()
|
|
|
|
{
|
2012-05-16 07:21:36 +08:00
|
|
|
return llvm::array_lengthof(g_option_table);
|
2011-04-28 06:04:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const OptionDefinition *
|
|
|
|
OptionGroupOutputFile::GetDefinitions ()
|
|
|
|
{
|
|
|
|
return g_option_table;
|
|
|
|
}
|
|
|
|
|
|
|
|
Error
|
|
|
|
OptionGroupOutputFile::SetOptionValue (CommandInterpreter &interpreter,
|
2012-12-04 08:32:51 +08:00
|
|
|
uint32_t option_idx,
|
|
|
|
const char *option_arg)
|
2011-04-28 06:04:39 +08:00
|
|
|
{
|
|
|
|
Error error;
|
2012-12-04 08:32:51 +08:00
|
|
|
const int short_option = g_option_table[option_idx].short_option;
|
2011-04-28 06:04:39 +08:00
|
|
|
|
|
|
|
switch (short_option)
|
|
|
|
{
|
|
|
|
case 'o':
|
|
|
|
error = m_file.SetValueFromCString (option_arg);
|
|
|
|
break;
|
|
|
|
|
2012-12-04 08:32:51 +08:00
|
|
|
case 'apnd':
|
2011-04-28 06:04:39 +08:00
|
|
|
m_append.SetCurrentValue(true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2011-10-26 08:56:27 +08:00
|
|
|
error.SetErrorStringWithFormat ("unrecognized option '%c'", short_option);
|
2011-04-28 06:04:39 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
OptionGroupOutputFile::OptionParsingStarting (CommandInterpreter &interpreter)
|
|
|
|
{
|
|
|
|
m_file.Clear();
|
|
|
|
m_append.Clear();
|
|
|
|
}
|