Author Topic: clangd_client string name inside the codecompletion\parser\cclogger.cpp file  (Read 10893 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
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.



« Last Edit: February 21, 2024, 09:03:40 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
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.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
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);

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2813
@ 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.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
@ 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)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2813
"clangd_client" name and "CodeCompletion" name protected by preprocessor guards, activated only when BUILDING_PLUGIN define is present.

@ollydbg, thanks for the patience.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
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.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2813
@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.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2813

@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.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2813
#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.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
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.

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
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.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2813
Thanks for trying. I'll restore CCLogger to the rev before I made any changes.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2813
@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.

 
« Last Edit: March 07, 2024, 06:48:01 am by Pecan »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
@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.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.