Caroline Tice | 6e4c5ce | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 1 | //====-- UserSettingsController.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 | |
Daniel Malea | d891f9b | 2012-12-05 00:20:57 +0000 | [diff] [blame] | 10 | #include "lldb/lldb-python.h" |
| 11 | |
Caroline Tice | 6e4c5ce | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 12 | #include <string.h> |
| 13 | #include <algorithm> |
| 14 | |
| 15 | #include "lldb/Core/UserSettingsController.h" |
| 16 | #include "lldb/Core/Error.h" |
Greg Clayton | 928d130 | 2010-12-19 03:41:24 +0000 | [diff] [blame] | 17 | #include "lldb/Core/RegularExpression.h" |
Caroline Tice | 6e4c5ce | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 18 | #include "lldb/Core/Stream.h" |
| 19 | #include "lldb/Core/StreamString.h" |
| 20 | #include "lldb/Interpreter/CommandInterpreter.h" |
Greg Clayton | 73844aa | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 21 | #include "lldb/Interpreter/OptionValueString.h" |
Caroline Tice | 6e4c5ce | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 22 | |
Greg Clayton | d284b66 | 2011-02-18 01:44:25 +0000 | [diff] [blame] | 23 | using namespace lldb; |
Caroline Tice | 6e4c5ce | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 24 | using namespace lldb_private; |
| 25 | |
Greg Clayton | d284b66 | 2011-02-18 01:44:25 +0000 | [diff] [blame] | 26 | |
Greg Clayton | 73844aa | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 27 | lldb::OptionValueSP |
| 28 | Properties::GetPropertyValue (const ExecutionContext *exe_ctx, |
| 29 | const char *path, |
| 30 | bool will_modify, |
| 31 | Error &error) const |
| 32 | { |
| 33 | OptionValuePropertiesSP properties_sp (GetValueProperties ()); |
| 34 | if (properties_sp) |
| 35 | return properties_sp->GetSubValue(exe_ctx, path, will_modify, error); |
| 36 | return lldb::OptionValueSP(); |
Greg Clayton | d284b66 | 2011-02-18 01:44:25 +0000 | [diff] [blame] | 37 | } |
| 38 | |
Greg Clayton | 73844aa | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 39 | Error |
| 40 | Properties::SetPropertyValue (const ExecutionContext *exe_ctx, |
| 41 | VarSetOperationType op, |
| 42 | const char *path, |
| 43 | const char *value) |
Caroline Tice | 6e4c5ce | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 44 | { |
Greg Clayton | 73844aa | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 45 | OptionValuePropertiesSP properties_sp (GetValueProperties ()); |
| 46 | if (properties_sp) |
| 47 | return properties_sp->SetSubValue(exe_ctx, op, path, value); |
| 48 | Error error; |
| 49 | error.SetErrorString ("no properties"); |
| 50 | return error; |
Jim Ingham | 7ac83bd | 2010-09-07 20:27:09 +0000 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | void |
Greg Clayton | 73844aa | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 54 | Properties::DumpAllPropertyValues (const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) |
Jim Ingham | 7ac83bd | 2010-09-07 20:27:09 +0000 | [diff] [blame] | 55 | { |
Greg Clayton | 73844aa | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 56 | OptionValuePropertiesSP properties_sp (GetValueProperties ()); |
| 57 | if (properties_sp) |
| 58 | return properties_sp->DumpValue (exe_ctx, strm, dump_mask); |
Jim Ingham | 7ac83bd | 2010-09-07 20:27:09 +0000 | [diff] [blame] | 59 | } |
| 60 | |
Caroline Tice | 6e4c5ce | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 61 | void |
Greg Clayton | 73844aa | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 62 | Properties::DumpAllDescriptions (CommandInterpreter &interpreter, |
| 63 | Stream &strm) const |
Caroline Tice | 6e4c5ce | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 64 | { |
Greg Clayton | 73844aa | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 65 | strm.PutCString("Top level variables:\n\n"); |
Caroline Tice | 6e4c5ce | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 66 | |
Greg Clayton | 73844aa | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 67 | OptionValuePropertiesSP properties_sp (GetValueProperties ()); |
| 68 | if (properties_sp) |
| 69 | return properties_sp->DumpAllDescriptions (interpreter, strm); |
| 70 | } |
| 71 | |
| 72 | |
| 73 | |
| 74 | Error |
| 75 | Properties::DumpPropertyValue (const ExecutionContext *exe_ctx, Stream &strm, const char *property_path, uint32_t dump_mask) |
| 76 | { |
| 77 | OptionValuePropertiesSP properties_sp (GetValueProperties ()); |
| 78 | if (properties_sp) |
Caroline Tice | 6e4c5ce | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 79 | { |
Greg Clayton | 73844aa | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 80 | return properties_sp->DumpPropertyValue (exe_ctx, |
| 81 | strm, |
| 82 | property_path, |
| 83 | dump_mask); |
Caroline Tice | 6e4c5ce | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 84 | } |
Greg Clayton | 73844aa | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 85 | Error error; |
| 86 | error.SetErrorString("empty property list"); |
| 87 | return error; |
Caroline Tice | 6e4c5ce | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | size_t |
Greg Clayton | 73844aa | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 91 | Properties::Apropos (const char *keyword, std::vector<const Property *> &matching_properties) const |
Caroline Tice | 6e4c5ce | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 92 | { |
Greg Clayton | 73844aa | 2012-08-22 17:17:09 +0000 | [diff] [blame] | 93 | OptionValuePropertiesSP properties_sp (GetValueProperties ()); |
| 94 | if (properties_sp) |
| 95 | { |
| 96 | properties_sp->Apropos (keyword, matching_properties); |
| 97 | } |
| 98 | return matching_properties.size(); |
Caroline Tice | 6e4c5ce | 2010-09-04 00:03:46 +0000 | [diff] [blame] | 99 | } |
Greg Clayton | 87e9d32 | 2012-10-19 18:02:49 +0000 | [diff] [blame] | 100 | |
| 101 | |
| 102 | lldb::OptionValuePropertiesSP |
| 103 | Properties::GetSubProperty (const ExecutionContext *exe_ctx, |
| 104 | const ConstString &name) |
| 105 | { |
| 106 | OptionValuePropertiesSP properties_sp (GetValueProperties ()); |
| 107 | if (properties_sp) |
| 108 | return properties_sp->GetSubProperty (exe_ctx, name); |
| 109 | return lldb::OptionValuePropertiesSP(); |
| 110 | } |
| 111 | |