Greg Clayton | 67cc063 | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 1 | //===-- OptionValueArch.cpp ---------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
Greg Clayton | 67cc063 | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 10 | #include "lldb/Interpreter/OptionValueArch.h" |
| 11 | |
| 12 | // C Includes |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
Enrico Granata | 5548cb5 | 2013-01-28 23:47:25 +0000 | [diff] [blame] | 16 | #include "lldb/DataFormatters/FormatManager.h" |
Greg Clayton | 67cc063 | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 17 | #include "lldb/Interpreter/CommandCompletions.h" |
Todd Fiala | e1cfbc7 | 2016-08-11 23:51:28 +0000 | [diff] [blame] | 18 | #include "lldb/Interpreter/CommandInterpreter.h" |
Pavel Labath | 145d95c | 2018-04-17 18:53:35 +0000 | [diff] [blame] | 19 | #include "lldb/Utility/Args.h" |
Pavel Labath | d821c99 | 2018-08-07 11:07:21 +0000 | [diff] [blame] | 20 | #include "lldb/Utility/State.h" |
Greg Clayton | 67cc063 | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 21 | |
| 22 | using namespace lldb; |
| 23 | using namespace lldb_private; |
| 24 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 25 | void OptionValueArch::DumpValue(const ExecutionContext *exe_ctx, Stream &strm, |
| 26 | uint32_t dump_mask) { |
| 27 | if (dump_mask & eDumpOptionType) |
| 28 | strm.Printf("(%s)", GetTypeAsCString()); |
| 29 | if (dump_mask & eDumpOptionValue) { |
Greg Clayton | 67cc063 | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 30 | if (dump_mask & eDumpOptionType) |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 31 | strm.PutCString(" = "); |
Greg Clayton | 67cc063 | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 32 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 33 | if (m_current_value.IsValid()) { |
| 34 | const char *arch_name = m_current_value.GetArchitectureName(); |
| 35 | if (arch_name) |
| 36 | strm.PutCString(arch_name); |
Greg Clayton | 67cc063 | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 37 | } |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 38 | } |
Greg Clayton | 67cc063 | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 39 | } |
| 40 | |
Zachary Turner | 97206d5 | 2017-05-12 04:51:55 +0000 | [diff] [blame] | 41 | Status OptionValueArch::SetValueFromString(llvm::StringRef value, |
| 42 | VarSetOperationType op) { |
| 43 | Status error; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 44 | switch (op) { |
| 45 | case eVarSetOperationClear: |
| 46 | Clear(); |
| 47 | NotifyValueChanged(); |
| 48 | break; |
| 49 | |
| 50 | case eVarSetOperationReplace: |
| 51 | case eVarSetOperationAssign: { |
| 52 | std::string value_str = value.trim().str(); |
| 53 | if (m_current_value.SetTriple(value_str.c_str())) { |
| 54 | m_value_was_set = true; |
| 55 | NotifyValueChanged(); |
| 56 | } else |
| 57 | error.SetErrorStringWithFormat("unsupported architecture '%s'", |
| 58 | value_str.c_str()); |
| 59 | break; |
| 60 | } |
| 61 | case eVarSetOperationInsertBefore: |
| 62 | case eVarSetOperationInsertAfter: |
| 63 | case eVarSetOperationRemove: |
| 64 | case eVarSetOperationAppend: |
| 65 | case eVarSetOperationInvalid: |
| 66 | error = OptionValue::SetValueFromString(value, op); |
| 67 | break; |
| 68 | } |
| 69 | return error; |
Greg Clayton | 67cc063 | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 70 | } |
| 71 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 72 | lldb::OptionValueSP OptionValueArch::DeepCopy() const { |
| 73 | return OptionValueSP(new OptionValueArch(*this)); |
Greg Clayton | 67cc063 | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 74 | } |
| 75 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 76 | size_t OptionValueArch::AutoComplete(CommandInterpreter &interpreter, |
Raphael Isemann | a2e76c0 | 2018-07-13 18:28:14 +0000 | [diff] [blame] | 77 | CompletionRequest &request) { |
| 78 | request.SetWordComplete(false); |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 79 | CommandCompletions::InvokeCommonCompletionCallbacks( |
Raphael Isemann | a2e76c0 | 2018-07-13 18:28:14 +0000 | [diff] [blame] | 80 | interpreter, CommandCompletions::eArchitectureCompletion, request, |
| 81 | nullptr); |
Raphael Isemann | 1a6d7ab | 2018-07-27 18:42:46 +0000 | [diff] [blame] | 82 | return request.GetNumberOfMatches(); |
Greg Clayton | 67cc063 | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 83 | } |