Path: blob/main/contrib/llvm-project/lldb/source/Interpreter/OptionValueSInt64.cpp
39587 views
//===-- OptionValueSInt64.cpp ---------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/Interpreter/OptionValueSInt64.h"910#include "lldb/Utility/Stream.h"1112using namespace lldb;13using namespace lldb_private;1415void OptionValueSInt64::DumpValue(const ExecutionContext *exe_ctx, Stream &strm,16uint32_t dump_mask) {17// printf ("%p: DumpValue (exe_ctx=%p, strm, mask) m_current_value = %"18// PRIi6419// "\n", this, exe_ctx, m_current_value);20if (dump_mask & eDumpOptionType)21strm.Printf("(%s)", GetTypeAsCString());22// if (dump_mask & eDumpOptionName)23// DumpQualifiedName (strm);24if (dump_mask & eDumpOptionValue) {25if (dump_mask & eDumpOptionType)26strm.PutCString(" = ");27strm.Printf("%" PRIi64, m_current_value);28}29}3031Status OptionValueSInt64::SetValueFromString(llvm::StringRef value_ref,32VarSetOperationType op) {33Status error;34switch (op) {35case eVarSetOperationClear:36Clear();37NotifyValueChanged();38break;3940case eVarSetOperationReplace:41case eVarSetOperationAssign: {42llvm::StringRef value_trimmed = value_ref.trim();43int64_t value;44if (llvm::to_integer(value_trimmed, value)) {45if (value >= m_min_value && value <= m_max_value) {46m_value_was_set = true;47m_current_value = value;48NotifyValueChanged();49} else50error.SetErrorStringWithFormat(51"%" PRIi64 " is out of range, valid values must be between %" PRIi6452" and %" PRIi64 ".",53value, m_min_value, m_max_value);54} else {55error.SetErrorStringWithFormat("invalid int64_t string value: '%s'",56value_ref.str().c_str());57}58} break;5960case eVarSetOperationInsertBefore:61case eVarSetOperationInsertAfter:62case eVarSetOperationRemove:63case eVarSetOperationAppend:64case eVarSetOperationInvalid:65error = OptionValue::SetValueFromString(value_ref, op);66break;67}68return error;69}707172