1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// copyright : (C) 2014 The CodeLite Team
// file name : LLDBSettings.cpp
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#include "LLDBSettings.h"
#include <wx/filename.h>
#include "cl_standard_paths.h"
#include <wx/ffile.h>
#ifdef __WXMAC__
static const wxString s_DefaultTypes =
"type summary add wxString --summary-string \"${var.m_impl}\"\n"
"type summary add wxPoint --summary-string \"x = ${var.x}, y = ${var.y}\"\n"
"type summary add wxRect --summary-string \"(x = ${var.x}, y = ${var.y}) (width = ${var.width}, height = ${var.height})\"\n";
#else
static const wxString s_DefaultTypes =
"type summary add wxString --summary-string \"${var.m_impl._M_dataplus._M_p}\"\n"
"type summary add wxPoint --summary-string \"x = ${var.x}, y = ${var.y}\"\n"
"type summary add wxRect --summary-string \"(x = ${var.x}, y = ${var.y}) (width = ${var.width}, height = ${var.height})\"\n";
#endif
LLDBSettings::LLDBSettings()
: m_arrItems(50)
, m_flags(kLLDBOptionRaiseCodeLite)
, m_stackFrames(100)
, m_proxyIp("127.0.0.1")
, m_proxyPort(13610)
{
m_types = s_DefaultTypes;
}
LLDBSettings::~LLDBSettings()
{
}
wxString LLDBSettings::LoadPerspective()
{
wxFileName fn( clStandardPaths::Get().GetUserDataDir(), "lldb.perspective");
fn.AppendDir("config");
wxFFile fp(fn.GetFullPath(), "rb");
if ( fp.IsOpened() ) {
wxString content;
fp.ReadAll( &content, wxConvUTF8 );
return content;
}
return "";
}
void LLDBSettings::SavePerspective(const wxString &perspective)
{
wxFileName fn( clStandardPaths::Get().GetUserDataDir(), "lldb.perspective");
fn.AppendDir("config");
wxFFile fp(fn.GetFullPath(), "w+b");
if ( fp.IsOpened() ) {
fp.Write( perspective );
fp.Close();
}
}
void LLDBSettings::FromJSON(const JSONElement& json)
{
m_arrItems = json.namedObject("m_maxArrayElements").toSize_t(m_arrItems);
m_stackFrames = json.namedObject("m_maxCallstackFrames").toSize_t(m_stackFrames);
m_flags = json.namedObject("m_flags").toSize_t(m_flags);
m_types = json.namedObject("m_types").toString(s_DefaultTypes);
m_proxyPort = json.namedObject("m_proxyPort").toInt(13610);
m_proxyIp = json.namedObject("m_proxyIp").toString("127.0.0.1");
m_lastLocalFolder = json.namedObject("m_lastLocalFolder").toString();
m_lastRemoteFolder = json.namedObject("m_lastRemoteFolder").toString();
}
JSONElement LLDBSettings::ToJSON() const
{
JSONElement json = JSONElement::createObject();
json.addProperty("m_maxArrayElements", m_arrItems);
json.addProperty("m_maxCallstackFrames", m_stackFrames);
json.addProperty("m_flags", m_flags);
json.addProperty("m_types", m_types);
json.addProperty("m_proxyPort", m_proxyPort);
json.addProperty("m_proxyIp", m_proxyIp);
json.addProperty("m_lastLocalFolder", m_lastLocalFolder);
json.addProperty("m_lastRemoteFolder", m_lastRemoteFolder);
return json;
}
LLDBSettings& LLDBSettings::Load()
{
wxFileName fn( clStandardPaths::Get().GetUserDataDir(), "lldb.conf");
fn.AppendDir("config");
wxFFile fp(fn.GetFullPath(), "rb");
if ( fp.IsOpened() ) {
wxString content;
fp.ReadAll( &content, wxConvUTF8 );
JSONRoot root(content);
FromJSON( root.toElement() );
fp.Close();
}
return *this;
}
LLDBSettings& LLDBSettings::Save()
{
wxFileName fn( clStandardPaths::Get().GetUserDataDir(), "lldb.conf");
fn.AppendDir("config");
wxFFile fp(fn.GetFullPath(), "w+b");
if ( fp.IsOpened() ) {
fp.Write( ToJSON().format() );
fp.Close();
}
return *this;
}
|