From 45393edc06c2d83d1a0163b2f79b4dba066eb516 Mon Sep 17 00:00:00 2001 From: cxl Date: Fri, 10 Jan 2014 19:57:24 +0000 Subject: [PATCH] CppDemangle, improved diag Ctrl::Name git-svn-id: svn://ultimatepp.org/upp/trunk@6747 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Debug.cpp | 29 +++++++++++++++++++++++++++++ uppsrc/Core/Diag.h | 1 + uppsrc/CtrlCore/Ctrl.cpp | 26 ++++++++++++++++++++++++++ uppsrc/CtrlCore/CtrlCore.h | 2 ++ uppsrc/CtrlCore/CtrlMouse.cpp | 1 + uppsrc/CtrlCore/GtkCreate.cpp | 8 +++++++- uppsrc/CtrlCore/GtkCtrl.cpp | 16 ++-------------- uppsrc/CtrlCore/GtkEvent.cpp | 1 - uppsrc/CtrlCore/Win32Ctrl.cpp | 12 +++--------- uppsrc/CtrlCore/X11Ctrl.cpp | 12 +----------- uppsrc/ide/LayDes/fontprop.cpp | 2 +- 11 files changed, 73 insertions(+), 37 deletions(-) diff --git a/uppsrc/Core/Debug.cpp b/uppsrc/Core/Debug.cpp index b20f73224..03bc10a9a 100644 --- a/uppsrc/Core/Debug.cpp +++ b/uppsrc/Core/Debug.cpp @@ -283,3 +283,32 @@ String _DBG_Value_AsString(Value const &v) { return AsString(v); } #endif END_UPP_NAMESPACE + +#if defined(__GNUG__) && defined(PLATFORM_POSIX) +#include +#include +#include + +NAMESPACE_UPP + +struct cpp_demangle_handle__ { + char* p; + cpp_demangle_handle__(char* ptr) : p(ptr) { } + ~cpp_demangle_handle__() { std::free(p); } +}; + +String CppDemangle(const char* name) { + int status = -4; + cpp_demangle_handle__ result( abi::__cxa_demangle(name, NULL, NULL, &status) ); + return (status==0) ? result.p : name ; +} + +#else + +String CppDemangle(const char* name) { + return name; +} + +#endif + +END_UPP_NAMESPACE diff --git a/uppsrc/Core/Diag.h b/uppsrc/Core/Diag.h index 18cf37bb4..cf330fa87 100644 --- a/uppsrc/Core/Diag.h +++ b/uppsrc/Core/Diag.h @@ -220,6 +220,7 @@ void DumpMap(Stream& s, const T& t) { String AsString(const MemoryProfile& mem); +String CppDemangle(const char* name); #if 0 // rare cases when release-mode DLOG/DDUMP is needed diff --git a/uppsrc/CtrlCore/Ctrl.cpp b/uppsrc/CtrlCore/Ctrl.cpp index 4d0697b15..b58c1fef4 100644 --- a/uppsrc/CtrlCore/Ctrl.cpp +++ b/uppsrc/CtrlCore/Ctrl.cpp @@ -965,4 +965,30 @@ CH_INT(GUI_AKD_Conservative, 0); CH_INT(GUI_DragDistance, 4); CH_INT(GUI_DblClickTime, 500); +String Ctrl::Name0() const { + GuiLock __; + String s = CppDemangle(typeid(*this).name()); + const Ctrl *q = this; + String path; + while(q) { + String id = q->GetLayoutId(); + path = "." + Nvl(id, "?") + path; + q = q->parent; + } + s << ' ' << path; +#ifdef CPU_64 + s << " : 0x" + FormatIntHex(this); +#else + s << " : " + Format("0x%x", (int) this); +#endif + if(IsChild()) + s << " (parent " << CppDemangle(typeid(*parent).name()) << ")"; + return s; +} + +String Ctrl::Name(Ctrl *ctrl) +{ + return Upp::Name(ctrl); +} + END_UPP_NAMESPACE diff --git a/uppsrc/CtrlCore/CtrlCore.h b/uppsrc/CtrlCore/CtrlCore.h index 47994c65a..b723bbc2b 100644 --- a/uppsrc/CtrlCore/CtrlCore.h +++ b/uppsrc/CtrlCore/CtrlCore.h @@ -638,6 +638,8 @@ private: void SysEndLoop(); + String Name0() const; + static void InitTimer(); static String appname; diff --git a/uppsrc/CtrlCore/CtrlMouse.cpp b/uppsrc/CtrlCore/CtrlMouse.cpp index 018bd8f0c..13c4f6263 100644 --- a/uppsrc/CtrlCore/CtrlMouse.cpp +++ b/uppsrc/CtrlCore/CtrlMouse.cpp @@ -471,6 +471,7 @@ void Ctrl::DoCursorShape() { } void Ctrl::CheckMouseCtrl() { + LLOG("CheckMouseCtrl " << mouseCtrl); GuiLock __; Point p = GetMousePos(); if(mouseCtrl) { diff --git a/uppsrc/CtrlCore/GtkCreate.cpp b/uppsrc/CtrlCore/GtkCreate.cpp index 41ed08fb3..7bced8c80 100644 --- a/uppsrc/CtrlCore/GtkCreate.cpp +++ b/uppsrc/CtrlCore/GtkCreate.cpp @@ -74,12 +74,18 @@ void Ctrl::Create(Ctrl *owner, bool popup) StateH(OPEN); activeCtrl = this; + + int mousex, mousey; + gdk_window_get_pointer(gdk(), &mousex, &mousey, NULL); + Point m(mousex, mousey); + r = GetWndScreenRect().GetSize(); + if(r.Contains(m)) + DispatchMouse(MOUSEMOVE, m); } void Ctrl::WndDestroy() { GuiLock __; - DLOG("WndDestroy " << msecs()); LLOG("WndDestroy " << Name()); DndExit(); Ctrl *owner = GetOwner(); diff --git a/uppsrc/CtrlCore/GtkCtrl.cpp b/uppsrc/CtrlCore/GtkCtrl.cpp index 50677d1f5..fc50760d6 100644 --- a/uppsrc/CtrlCore/GtkCtrl.cpp +++ b/uppsrc/CtrlCore/GtkCtrl.cpp @@ -75,21 +75,9 @@ void GuiPlatformAfterMenuPopUp() { } -String Ctrl::Name() const { - GuiLock __; -#ifdef CPU_64 - String s = String(typeid(*this).name()) + " : 0x" + FormatIntHex(this); -#else - String s = String(typeid(*this).name()) + " : " + Format("0x%x", (int) this); -#endif - if(IsChild()) - s << "(parent " << String(typeid(*parent).name()) << ")"; - return s; -} - -String Ctrl::Name(Ctrl *ctrl) +String Ctrl::Name() const { - return Upp::Name(ctrl); + return Name0(); } void Ctrl::InstallPanicBox() diff --git a/uppsrc/CtrlCore/GtkEvent.cpp b/uppsrc/CtrlCore/GtkEvent.cpp index 2ffc7ebd2..0a5bde595 100644 --- a/uppsrc/CtrlCore/GtkEvent.cpp +++ b/uppsrc/CtrlCore/GtkEvent.cpp @@ -369,7 +369,6 @@ void Ctrl::Proc() switch(CurrentEvent.type) { case GDK_MOTION_NOTIFY: { GtkMouseEvent(MOUSEMOVE, MOUSEMOVE, 0); - DoCursorShape(); break; } case GDK_BUTTON_PRESS: diff --git a/uppsrc/CtrlCore/Win32Ctrl.cpp b/uppsrc/CtrlCore/Win32Ctrl.cpp index 1989f0ff2..819257535 100644 --- a/uppsrc/CtrlCore/Win32Ctrl.cpp +++ b/uppsrc/CtrlCore/Win32Ctrl.cpp @@ -136,15 +136,9 @@ void Ctrl::SyncCaret() { String Ctrl::Name() const { GuiLock __; -#ifdef CPU_64 - String s = String(typeid(*this).name()) + " : 0x" + FormatIntHex(this); -#else - String s = String(typeid(*this).name()) + " : " + Format("0x%x", (int) this); -#endif - if(IsChild()) - s << "(parent " << String(typeid(*parent).name()) << ")"; - else - s << Format("(hwnd 0x%x)", (int)(intptr_t) GetHWND()); + String s = Name0(); + if(!IsChild()) + s << Format(" (hwnd 0x%x)", (int)(intptr_t) GetHWND()); return s; } diff --git a/uppsrc/CtrlCore/X11Ctrl.cpp b/uppsrc/CtrlCore/X11Ctrl.cpp index d9deeb401..d50320205 100644 --- a/uppsrc/CtrlCore/X11Ctrl.cpp +++ b/uppsrc/CtrlCore/X11Ctrl.cpp @@ -25,17 +25,7 @@ void Ctrl::GuiPlatformGetTopRect(Rect& r) const } String Ctrl::Name() const { - GuiLock __; -#ifdef CPU_64 - String s = String(typeid(*this).name()) + " : 0x" + FormatIntHex(this); -#else - String s = String(typeid(*this).name()) + " : " + Format("0x%x", (int) this); -#endif - if(IsChild()) - s << "(parent " << String(typeid(*parent).name()) << ")"; - else - s << Format("(window 0x%x)", (int)(intptr_t) GetWindow()); - return s; + return Name0(); } bool Ctrl::GuiPlatformRefreshFrameSpecial(const Rect&) diff --git a/uppsrc/ide/LayDes/fontprop.cpp b/uppsrc/ide/LayDes/fontprop.cpp index 6bd4cf086..d1ca5a669 100644 --- a/uppsrc/ide/LayDes/fontprop.cpp +++ b/uppsrc/ide/LayDes/fontprop.cpp @@ -39,7 +39,7 @@ struct FontDisplay : public Display { w.DrawRect(r, paper); Font font = q; String text = FormatFont(font); - font.Height(StdFont().Info().GetHeight() - 1); + font.Height(StdFont().GetHeight() - 1); w.DrawText(2, (r.Height() - font.Info().GetHeight()) / 2, text, font, ink); } };