mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
ide: GDB improvements
git-svn-id: svn://ultimatepp.org/upp/trunk@12037 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
c890a6b6f1
commit
8a769224fe
11 changed files with 64 additions and 136 deletions
|
|
@ -69,7 +69,8 @@ public:
|
|||
One(T *newt) { ptr = newt; }
|
||||
template <class TT>
|
||||
One(One<TT>&& p) { Pick(pick(p)); }
|
||||
One(MakeOne<T>&&);
|
||||
template <class TT>
|
||||
One(MakeOne<TT>&&);
|
||||
One(const One<T>& p, int) { ptr = p.IsEmpty() ? NULL : DeepCopyNew(*p); }
|
||||
One(const One<T>& p) = delete;
|
||||
~One() { Free(); }
|
||||
|
|
@ -83,9 +84,10 @@ struct MakeOne : One<T> {
|
|||
};
|
||||
|
||||
template <class T>
|
||||
One<T>::One(MakeOne<T>&& p)
|
||||
template <class TT>
|
||||
One<T>::One(MakeOne<TT>&& p)
|
||||
{
|
||||
Pick(pick(p));
|
||||
Attach(p.Detach());
|
||||
}
|
||||
|
||||
class Any : Moveable<Any> {
|
||||
|
|
|
|||
|
|
@ -249,6 +249,7 @@ struct OneFileHost : Host {
|
|||
virtual String GetHostPath(const String& path) { return host->GetHostPath(path); }
|
||||
virtual String GetLocalPath(const String& path) { return host->GetLocalPath(path); }
|
||||
virtual String NormalizePath(const String& path) { return host->NormalizePath(path); }
|
||||
virtual String NormalizeExecutablePath(const String& path) { return host->NormalizeExecutablePath(path); }
|
||||
virtual void DeleteFile(const Vector<String>& path) { host->DeleteFile(path); }
|
||||
virtual void DeleteFolderDeep(const String& folder) { host->DeleteFolderDeep(folder); }
|
||||
virtual void ChDir(const String& path) { host->ChDir(path); }
|
||||
|
|
@ -268,7 +269,6 @@ struct OneFileHost : Host {
|
|||
virtual void Launch(const char *cmdline, bool) { host->Launch(cmdline); }
|
||||
virtual void AddFlags(Index<String>& cfg) { host->AddFlags(cfg); }
|
||||
virtual const Vector<String>& GetExecutablesDirs() const { return host->GetExecutablesDirs(); }
|
||||
virtual const HostTools& GetTools() const { return host->GetTools(); }
|
||||
|
||||
virtual Vector<FileInfo> GetFileInfo(const Vector<String>& path) {
|
||||
Vector<FileInfo> fi = host->GetFileInfo(path);
|
||||
|
|
|
|||
|
|
@ -148,7 +148,6 @@ void IdeSetBar();
|
|||
|
||||
void IdeGotoFileAndId(const String& path, const String& id);
|
||||
|
||||
#include "HostTools.h"
|
||||
#include "Host.h"
|
||||
|
||||
struct IdeMacro {
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@ file
|
|||
Host readonly separator,
|
||||
Host.h,
|
||||
Host.cpp,
|
||||
HostTools.h,
|
||||
HostTools.cpp,
|
||||
Logger readonly separator,
|
||||
Logger.cpp,
|
||||
Logger.h,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
#include <plugin/bz2/bz2.h>
|
||||
|
||||
LocalHost::LocalHost()
|
||||
: tools(MakeOne<LocalHostTools>())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -29,6 +28,11 @@ String LocalHost::NormalizePath(const String& path)
|
|||
return ::NormalizePath(path);
|
||||
}
|
||||
|
||||
String LocalHost::NormalizeExecutablePath(const String& path)
|
||||
{
|
||||
return NormalizeExePath(path);
|
||||
}
|
||||
|
||||
Vector<Host::FileInfo> LocalHost::GetFileInfo(const Vector<String>& path)
|
||||
{
|
||||
Vector<FileInfo> fi;
|
||||
|
|
@ -364,11 +368,6 @@ const Vector<String>& LocalHost::GetExecutablesDirs() const
|
|||
return exedirs;
|
||||
}
|
||||
|
||||
const HostTools& LocalHost::GetTools() const
|
||||
{
|
||||
return *tools.Get();
|
||||
}
|
||||
|
||||
bool LocalHost::HasPlatformFlag(const Index<String>& cfg)
|
||||
{
|
||||
static const Index<String> platformFlags = {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ public:
|
|||
virtual String GetHostPath(const String& path) = 0;
|
||||
virtual String GetLocalPath(const String& path) = 0;
|
||||
virtual String NormalizePath(const String& path) = 0;
|
||||
virtual String NormalizeExecutablePath(const String& path) = 0;
|
||||
virtual Vector<FileInfo> GetFileInfo(const Vector<String>& path) = 0;
|
||||
virtual void DeleteFile(const Vector<String>& path) = 0;
|
||||
virtual void DeleteFolderDeep(const String& dir) = 0;
|
||||
|
|
@ -35,7 +36,6 @@ public:
|
|||
virtual void AddFlags(Index<String>& cfg) = 0;
|
||||
|
||||
virtual const Vector<String>& GetExecutablesDirs() const = 0;
|
||||
virtual const HostTools& GetTools() const = 0;
|
||||
};
|
||||
|
||||
class LocalHost : public Host {
|
||||
|
|
@ -53,6 +53,7 @@ public: /* Host */
|
|||
String GetHostPath(const String& path) override;
|
||||
String GetLocalPath(const String& path) override;
|
||||
String NormalizePath(const String& path) override;
|
||||
String NormalizeExecutablePath(const String& path) override;
|
||||
Vector<FileInfo> GetFileInfo(const Vector<String>& path) override;
|
||||
void DeleteFile(const Vector<String>& path) override;
|
||||
void DeleteFolderDeep(const String& dir) override;
|
||||
|
|
@ -74,13 +75,9 @@ public: /* Host */
|
|||
void AddFlags(Index<String>& cfg) override;
|
||||
|
||||
const Vector<String>& GetExecutablesDirs() const override;
|
||||
const HostTools& GetTools() const override;
|
||||
|
||||
private:
|
||||
bool HasPlatformFlag(const Index<String>& cfg);
|
||||
|
||||
private:
|
||||
One<HostTools> tools;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
#include "Core.h"
|
||||
|
||||
String LocalHostTools::NormalizeExecutablePath(const String& path) const
|
||||
{
|
||||
return ::NormalizeExePath(path);
|
||||
}
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
class HostTools {
|
||||
public:
|
||||
virtual ~HostTools() {}
|
||||
|
||||
virtual String NormalizeExecutablePath(const String& path) const = 0;
|
||||
};
|
||||
|
||||
class LocalHostTools final : public HostTools {
|
||||
public:
|
||||
String NormalizeExecutablePath(const String& path) const override;
|
||||
};
|
||||
|
||||
|
|
@ -152,8 +152,6 @@ public:
|
|||
String autoline;
|
||||
bool firstrun;
|
||||
|
||||
int frame_idx;
|
||||
|
||||
int pid = 0; // debugee pid
|
||||
|
||||
String DoRun();
|
||||
|
|
@ -176,7 +174,7 @@ public:
|
|||
|
||||
void Step(const char *cmd);
|
||||
|
||||
String Cmdp(const char *cmdline, bool fr = false);
|
||||
String Cmdp(const char *cmdline, bool fr = false, bool setframe = true);
|
||||
|
||||
void DoRunTo() { RunTo(); }
|
||||
|
||||
|
|
@ -186,8 +184,7 @@ public:
|
|||
void DisasCursor();
|
||||
void DisasFocus();
|
||||
void DropFrames();
|
||||
|
||||
String ObtainFrame(int frame_idx);
|
||||
void LoadFrames();
|
||||
|
||||
void SwitchFrame();
|
||||
void SwitchThread();
|
||||
|
|
@ -217,9 +214,8 @@ public:
|
|||
void BreakRunning();
|
||||
|
||||
bool Create(One<Host>&& host, const String& exefile, const String& cmdline, bool console);
|
||||
|
||||
// Period check for killed console
|
||||
TimeCallback periodic;
|
||||
|
||||
TimeCallback periodic; // Period check for killed console
|
||||
void Periodic();
|
||||
|
||||
typedef Gdb CLASSNAME;
|
||||
|
|
@ -227,13 +223,7 @@ public:
|
|||
virtual ~Gdb();
|
||||
Gdb();
|
||||
|
||||
private:
|
||||
void RestoreFramePos();
|
||||
|
||||
bool CreateDbg(One<Host>& host, const String& exeFile, bool console);
|
||||
|
||||
private:
|
||||
const int max_stack_trace_size;
|
||||
const int max_stack_trace_size = 400;
|
||||
};
|
||||
|
||||
#include "Gdb_MI2.h"
|
||||
|
|
|
|||
|
|
@ -83,7 +83,6 @@ void Gdb::CopyStackAll()
|
|||
String s = ss.GetLine();
|
||||
CParser p(s);
|
||||
try {
|
||||
bool active = p.Char('*');
|
||||
if(p.IsNumber()) {
|
||||
int id = p.ReadInt();
|
||||
r << "----------------------------------\r\n"
|
||||
|
|
@ -92,7 +91,6 @@ void Gdb::CopyStackAll()
|
|||
FastCmd(Sprintf("thread %d", id));
|
||||
|
||||
int i = 0;
|
||||
int q = ~frame;
|
||||
frame.Clear();
|
||||
for(;;) {
|
||||
String s = FormatFrame(FastCmd("frame " + AsString(i++)));
|
||||
|
|
@ -223,7 +221,7 @@ void Gdb::CheckEnd(const char *s)
|
|||
}
|
||||
}
|
||||
|
||||
String Gdb::Cmdp(const char *cmdline, bool fr)
|
||||
String Gdb::Cmdp(const char *cmdline, bool fr, bool setframe)
|
||||
{
|
||||
expression_cache.Clear();
|
||||
IdeHidePtr();
|
||||
|
|
@ -250,9 +248,11 @@ String Gdb::Cmdp(const char *cmdline, bool fr)
|
|||
catch(CParser::Error) {}
|
||||
SyncDisas(fr);
|
||||
}
|
||||
frame.Clear();
|
||||
frame.Add(0, FormatFrame(FastCmd("frame")));
|
||||
frame <<= 0;
|
||||
if(setframe) {
|
||||
frame.Clear();
|
||||
frame.Add(0, FormatFrame(FastCmd("frame")));
|
||||
frame <<= 0;
|
||||
}
|
||||
threads.Clear();
|
||||
s = FastCmd("info threads");
|
||||
StringStream ss(s);
|
||||
|
|
@ -326,28 +326,19 @@ void Gdb::BreakRunning()
|
|||
{
|
||||
#ifdef PLATFORM_WIN32
|
||||
HANDLE h = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
|
||||
if(!h) {
|
||||
auto error = t_("Failed to open debugge process.");
|
||||
|
||||
Loge() << METHOD_NAME << error;
|
||||
ErrorOK(error);
|
||||
|
||||
if(h) {
|
||||
DebugBreakProcess(h);
|
||||
CloseHandle(h);
|
||||
return;
|
||||
}
|
||||
|
||||
DebugBreakProcess(h);
|
||||
CloseHandle(h);
|
||||
#endif
|
||||
#ifdef PLATFORM_POSIX
|
||||
if (kill(pid, SIGINT) == -1) {
|
||||
auto error = t_("Failed to send SIGINT signal to debugge process.");
|
||||
|
||||
Loge() << METHOD_NAME << error;
|
||||
ErrorOK(error);
|
||||
|
||||
if(kill(pid, SIGINT) != -1)
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
const char *error = t_("Failed to interrupt debugee process.");
|
||||
Loge() << METHOD_NAME << error;
|
||||
ErrorOK(error);
|
||||
}
|
||||
|
||||
void Gdb::Run()
|
||||
|
|
@ -390,57 +381,43 @@ void Gdb::DisasFocus()
|
|||
|
||||
void Gdb::DropFrames()
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
frame.Clear();
|
||||
while(i <= max_stack_trace_size) {
|
||||
auto s = ObtainFrame(i);
|
||||
if(IsNull(s)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == max_stack_trace_size) {
|
||||
auto msg = Sprintf(
|
||||
"More entries.. (Only first %d elements had been printed)", max_stack_trace_size);
|
||||
|
||||
frame.Add(i, msg);
|
||||
break;
|
||||
}
|
||||
|
||||
frame.Add(i++, s);
|
||||
}
|
||||
|
||||
if (frame_idx == -1 && frame.GetCount() >= 0) {
|
||||
frame_idx = 0;
|
||||
}
|
||||
|
||||
RestoreFramePos();
|
||||
if(frame.GetCount() < 2)
|
||||
LoadFrames();
|
||||
}
|
||||
|
||||
String Gdb::ObtainFrame(int frame_idx)
|
||||
void Gdb::LoadFrames()
|
||||
{
|
||||
return FormatFrame(FastCmd(Sprintf("frame %d", frame_idx)));
|
||||
if(frame.GetCount())
|
||||
frame.Trim(frame.GetCount() - 1);
|
||||
int i = frame.GetCount();
|
||||
int n = 0;
|
||||
for(;;) {
|
||||
String s = FormatFrame(FastCmd(Sprintf("frame %d", i)));
|
||||
if(IsNull(s))
|
||||
break;
|
||||
if(n++ >= max_stack_trace_size) {
|
||||
frame.Add(Null, Sprintf("<load more> (%d loaded)", frame.GetCount()));
|
||||
break;
|
||||
}
|
||||
frame.Add(i++, s);
|
||||
}
|
||||
}
|
||||
|
||||
void Gdb::SwitchFrame()
|
||||
{
|
||||
auto i = static_cast<int>(~frame);
|
||||
if (i == max_stack_trace_size) {
|
||||
RestoreFramePos();
|
||||
return;
|
||||
int i = ~frame;
|
||||
if(IsNull(i)) {
|
||||
i = frame.GetCount() - 1;
|
||||
LoadFrames();
|
||||
frame <<= i;
|
||||
}
|
||||
|
||||
frame_idx = i;
|
||||
|
||||
Cmdp(Sprintf("frame %d", i), i);
|
||||
Cmdp("frame " + AsString(i), i, false);
|
||||
}
|
||||
|
||||
void Gdb::SwitchThread()
|
||||
{
|
||||
frame_idx = -1;
|
||||
|
||||
int i = static_cast<int>(~threads);
|
||||
Cmdp(Sprintf("thread %d", i), i);
|
||||
int i = ~threads;
|
||||
Cmdp("thread " + AsString(i));
|
||||
}
|
||||
|
||||
bool Gdb::Key(dword key, int count)
|
||||
|
|
@ -455,18 +432,13 @@ bool Gdb::Key(dword key, int count)
|
|||
return Ctrl::Key(key, count);
|
||||
}
|
||||
|
||||
void Gdb::RestoreFramePos()
|
||||
{
|
||||
if (frame_idx >= 0 && frame_idx < frame.GetCount()) {
|
||||
frame <<= frame_idx;
|
||||
}
|
||||
}
|
||||
|
||||
bool Gdb::Create(One<Host>&& _host, const String& exefile, const String& cmdline, bool console)
|
||||
{
|
||||
host = pick(_host);
|
||||
|
||||
if (!CreateDbg(host, exefile, console)) {
|
||||
|
||||
dbg = host->StartProcess(GdbCommand(console) + host->NormalizeExecutablePath(exefile));
|
||||
|
||||
if (!dbg) {
|
||||
ErrorOK("Error while invoking gdb!");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -509,14 +481,6 @@ bool Gdb::Create(One<Host>&& _host, const String& exefile, const String& cmdline
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Gdb::CreateDbg(One<Host>& host, const String& exeFile, bool console)
|
||||
{
|
||||
const auto& hostTools = host->GetTools();
|
||||
dbg = host->StartProcess(GdbCommand(console) + hostTools.NormalizeExecutablePath(exeFile));
|
||||
|
||||
return static_cast<bool>(dbg);
|
||||
}
|
||||
|
||||
Gdb::~Gdb()
|
||||
{
|
||||
IdeRemoveBottom(*this);
|
||||
|
|
@ -531,8 +495,6 @@ void Gdb::Periodic()
|
|||
}
|
||||
|
||||
Gdb::Gdb()
|
||||
: frame_idx(-1)
|
||||
, max_stack_trace_size(200)
|
||||
{
|
||||
locals.NoHeader();
|
||||
locals.AddColumn("", 1);
|
||||
|
|
@ -593,9 +555,8 @@ Gdb::Gdb()
|
|||
|
||||
One<Debugger> GdbCreate(One<Host>&& host, const String& exefile, const String& cmdline, bool console)
|
||||
{
|
||||
One<Gdb> dbg = MakeOne<Gdb>();
|
||||
if(!dbg->Create(pick(host), exefile, cmdline, console)) {
|
||||
auto dbg = MakeOne<Gdb>();
|
||||
if(!dbg->Create(pick(host), exefile, cmdline, console))
|
||||
return nullptr;
|
||||
}
|
||||
return dbg;
|
||||
return pick(dbg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -565,7 +565,7 @@ void Ide::EditFile0(const String& path, byte charset, int spellcheck_comments, c
|
|||
const int64 max_size = 768*1024*1024;
|
||||
#endif
|
||||
const int view_limit = 256*1024*1024;
|
||||
if(view_file.GetSize() < 256*1024*1024 || editastext.Find(editfile) >= 0 && view_file.GetSize() < max_size) {
|
||||
if(view_file.GetSize() < view_limit || editastext.Find(editfile) >= 0 && view_file.GetSize() < max_size) {
|
||||
le = editor.Load(view_file, charset);
|
||||
view_file.Close();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue