Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => CodeCompletion redesign => Topic started by: ollydbg on February 21, 2024, 08:56:57 am

Title: clangd_client string name inside the codecompletion\parser\cclogger.cpp file
Post by: ollydbg on February 21, 2024, 08:56:57 am
Hi, Pecan, I see this changes in revision 13432

Code
 // Initialized from CodeCompletion constructor
-void CCLogger::Init(wxEvtHandler* parent, int logId, int debugLogId, int addTokenId)
+// ----------------------------------------------------------------------------
+//-void CCLogger::Init(wxEvtHandler* parent, int logId, int debugLogId, int debugLogErrorId, int addTokenId)
+void CCLogger::Init(wxEvtHandler* parent, int logId, int logErrorId, int debugLogId, int debugLogErrorId, int addTokenId)
+// ----------------------------------------------------------------------------
 {
     m_Parent     = parent;
     m_LogId      = logId;
     m_DebugLogId = debugLogId;
+    m_DebugLogErrorId = debugLogErrorId;
     m_AddTokenId = addTokenId;
+    m_AddTokenId = addTokenId;
+    m_pCfgMgr    = Manager::Get()->GetConfigManager("clangd_client");
+
 }

When I try to run the CCTest program, I got an assert failed:

Code
const wxString PersonalityManager::GetPersonality()
{
    cbAssert(m_ready);
    return m_pers;
}

The issue is that CCTest program has dynamically link to the codeblocks.dll(maybe I need to remove it, but it would be hard such dependency).

So I believe either CCTest code need to initialize some *Manager instance, or the code in the cclogger need to be changed.

But why the "clangd_client" name is in this function call?

Thanks.


EDIT:

Code
m_AddTokenId = addTokenId;

This line is duplicated.



Title: Re: clangd_client string name inside the codecompletion\parser\cclogger.cpp file
Post by: ollydbg on February 21, 2024, 11:01:31 am
If I remove the line:

Code
diff --git a/src/plugins/codecompletion/parser/cclogger.cpp b/src/plugins/codecompletion/parser/cclogger.cpp
index 65e9d905..31c9d034 100644
--- a/src/plugins/codecompletion/parser/cclogger.cpp
+++ b/src/plugins/codecompletion/parser/cclogger.cpp
@@ -76,7 +76,7 @@ void CCLogger::Init(wxEvtHandler* parent, int logId, int logErrorId, int debugLo
     m_DebugLogErrorId = debugLogErrorId;
     m_AddTokenId = addTokenId;
     m_AddTokenId = addTokenId;
-    m_pCfgMgr    = Manager::Get()->GetConfigManager("clangd_client");
+    //m_pCfgMgr    = Manager::Get()->GetConfigManager("clangd_client");
 
 }
 


Then I can run the CCTest. Though the CCTest's frame window can be opened, I still can't see the debug log messages in the windows, so there are other issues.
Title: Re: clangd_client string name inside the codecompletion\parser\cclogger.cpp file
Post by: ollydbg on February 21, 2024, 03:54:49 pm
OK, I found a workaround:

Code
diff --git a/src/plugins/codecompletion/cctest/cctest_frame.cpp b/src/plugins/codecompletion/cctest/cctest_frame.cpp
index 32ab3cd0..30fa8ff6 100644
--- a/src/plugins/codecompletion/cctest/cctest_frame.cpp
+++ b/src/plugins/codecompletion/cctest/cctest_frame.cpp
@@ -20,6 +20,8 @@
 
 #include "parsemanager_test.h"
 
+#include "personalitymanager.h"
+
 //(*InternalHeaders(CCTestFrame)
 #include <wx/intl.h>
 #include <wx/settings.h>
@@ -215,6 +217,8 @@ CCTestFrame::CCTestFrame(const wxString& main_file) :
     Connect(wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction)&CCTestFrame::OnMenuAboutSelected);
     //*)
 
+    Manager::Get()->GetPersonalityManager()->MarkAsReady();
+
     // redirect the wxLogMessage to the text ctrl of the frame
     wxLogTextCtrl* textLog = new wxLogTextCtrl(m_CompletionTestCtrl);
     wxLog::SetActiveTarget(textLog);

Title: Re: clangd_client string name inside the codecompletion\parser\cclogger.cpp file
Post by: Pecan on February 21, 2024, 07:19:38 pm
@ ollydbg

Thanks for finding a work around.
I'll pay attention to it as soon as I can.

For now, my whole day is spent trying to find a work around for the playWX.cpp crash when using Ubuntu and gtk 3.2 .
I'm getting close.
Title: Re: clangd_client string name inside the codecompletion\parser\cclogger.cpp file
Post by: ollydbg on February 22, 2024, 12:00:49 am
@ ollydbg

Thanks for finding a work around.
I'll pay attention to it as soon as I can.

OK, thanks.

Quote
For now, my whole day is spent trying to find a work around for the playWX.cpp crash when using Ubuntu and gtk 3.2 .
I'm getting close.

I see you have committed a fix in the trunk. In-fact, the scintilla and its wxWidgets port are very complex, and I had no idea about the crash issue. Maybe, the gtk 3.2 has changed the event send sequence, maybe we need to migrate to a more modern wx port of scintilla. (I think we have maintain an old scintilla)
Title: Re: clangd_client string name inside the codecompletion\parser\cclogger.cpp file
Post by: Pecan on March 02, 2024, 06:06:46 pm
"clangd_client" name and "CodeCompletion" name protected by preprocessor guards, activated only when BUILDING_PLUGIN define is present.

@ollydbg, thanks for the patience.
Title: Re: clangd_client string name inside the codecompletion\parser\cclogger.cpp file
Post by: ollydbg on March 06, 2024, 02:19:55 pm
Hi, I'm currently code-refactoring the legecy codecompletion plugin's tokenizer.

I see one change by you:

Code
-    CodeBlocksThreadEvent evt(wxEVT_COMMAND_MENU_SELECTED, m_DebugLogId);
+    bool debugLogging = m_pCfgMgr->ReadBool("/logPluginDebug_check", false);
+    if (not debugLogging and (id==m_DebugLogId)) return;

when the parser finished parsing a project, it normally will print something like: xxxxx tokens and xxxx seconds.

But with this change, I can't see this.

I searched for a while, and I can't find the variable named "/logPluginDebug_check", so what is this purpose of this variable.

For me, I would like to see the debug events from the codecompletion plugin.

Thanks.
Title: Re: clangd_client string name inside the codecompletion\parser\cclogger.cpp file
Post by: Pecan on March 06, 2024, 11:28:09 pm
@ollydbg
Sorry about this (again).
Please put preprocessor guards around code like that.
I was using it to debug the CodeCompletion plugin and did not consider that it would be used stand-alone.
Code
#if defined(MAKING_PLUGIN)
   <the offending code>
#endif

Commit the changes when you are satisfied.
Sorry again.
Title: Re: clangd_client string name inside the codecompletion\parser\cclogger.cpp file
Post by: Pecan on March 06, 2024, 11:34:04 pm

@ollydbg
Sorry about this (again).
Please put preprocessor guards around code like that.
I was using it to debug the CodeCompletion plugin and did not consider that it would be used stand-alone.

I think the best thing to do is just revert the changes to a version that is usable for you.
I'll do that now.
Title: Re: clangd_client string name inside the codecompletion\parser\cclogger.cpp file
Post by: Pecan on March 06, 2024, 11:54:21 pm
#ollydbug

Look and set the debug checkbox to see if it solves the problem.
If not, I'll revert to a previous CCLogger with my changes.
Title: Re: clangd_client string name inside the codecompletion\parser\cclogger.cpp file
Post by: ollydbg on March 07, 2024, 03:50:10 am
Hi, Pecan, I think the variable/field name are different?

The code I see is:

Code
// ----------------------------------------------------------------------------
void CCLogger::DebugLog(const wxString& msg, int id)
// ----------------------------------------------------------------------------
{
    // Could crash here; should check if shutting down
    if (Manager::IsAppShuttingDown())
        return;

    if (!m_Parent || m_DebugLogId<1) return;

    bool debugLogging = false;
    if (m_pCfgMgr) debugLogging = m_pCfgMgr->ReadBool("/logPluginDebug_check", false);
    if ((not debugLogging) and (id == m_DebugLogId)) return;

Note, the name is "logPluginDebug_check"

But in the CheckBox, the name is "CCDebugLogging".

Are they the same?

When I enabled that CheckBox in the CodeCompletion plugin's setting, I still got the code check "debugLogging" is false.

Title: Re: clangd_client string name inside the codecompletion\parser\cclogger.cpp file
Post by: ollydbg on March 07, 2024, 03:56:10 am
The code about CCLogger is that some log functions can be called either in the worker thread or in the main gui thread.

So, you can see there are some thread event send to the main thread.

There are too many lockers in the CC code, I think we should take some time to clean up those lockers.
Title: Re: clangd_client string name inside the codecompletion\parser\cclogger.cpp file
Post by: Pecan on March 07, 2024, 04:35:35 am
Thanks for trying. I'll restore CCLogger to the rev before I made any changes.
Title: Re: clangd_client string name inside the codecompletion\parser\cclogger.cpp file
Post by: Pecan on March 07, 2024, 06:04:56 am
@ollydbg
I've reverted CodeCompletion.cpp/h lines that I changed related to CCLogger. I change no other lines of code.

In CCLogger I reverted to rev 13427, so you may have to change 'NativeParser' name back to ParseManager.
I recompiled CB and got no errors.
I hope I didn't miss anything. If so, let me know.

Thanks for being so patient about this.

 
Title: Re: clangd_client string name inside the codecompletion\parser\cclogger.cpp file
Post by: ollydbg on March 07, 2024, 01:13:15 pm
@ollydbg
I've reverted CodeCompletion.cpp/h lines that I changed related to CCLogger. I change no other lines of code.

In CCLogger I reverted to rev 13427, so you may have to change 'NativeParser' name back to ParseManager.
I recompiled CB and got no errors.
I hope I didn't miss anything. If so, let me know.

Thanks for being so patient about this.

Thanks.

BTW: I fixed  the build error for CCTest project in revision 13489.