Author Topic: Code completion using LSP and clangd  (Read 311176 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code completion using LSP and clangd
« Reply #150 on: July 30, 2022, 05:02:08 am »
@BlueHazzard, maybe you can check the log files in your system Temp folder to see what content were sent from the clangd.
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
Re: Code completion using LSP and clangd
« Reply #151 on: July 30, 2022, 09:51:00 pm »
Hi, not quite sure what is happening, and i did not investigate, but i got a crash and this backtrace, just wanted to note it here:
Code
AddrPC           Params
00007FFC87E084EB 00000158724B49E0 0000002690BFE4F0 00000000FFFF86AD  clangd_client.dll!Parser::LSP_ParseSemanticTokens
00007FFC87E13403 00000158724B49E0 00000158771FF080 0000000000000000  clangd_client.dll!Parser::OnLSP_RequestedSemanticTokensResponse
00007FFC87DB64F1 000001586D6EB3F0 00000158771FF080 0000002690BFEED0  clangd_client.dll!ClgdCompletion::OnLSP_Event
00007FFC2F35398C 000001586CB04130 000001586D6EB3F0 00007FFC2A605B5E  wxmsw315ud_gcc_custom.dll!wxAppConsoleBase::HandleEvent
00007FFC2F353A0D 000001586CB04130 000001586D6EB3F0 000001586D50E880  wxmsw315ud_gcc_custom.dll!wxAppConsoleBase::CallEventHandler
00007FFC2F42DBF4 000001586D50E8E0 000001586D6EB3F0 00000158771FF080  wxmsw315ud_gcc_custom.dll!wxEvtHandler::ProcessEventIfMatchesId
00007FFC2F42E90A 000001586D6EB3F0 00000158771FF080 00000158771FF080  wxmsw315ud_gcc_custom.dll!wxEvtHandler::SearchDynamicEventTable
00007FFC2F42E07A 000001586D6EB3F0 00000158771FF080 0000002690BFF0C0  wxmsw315ud_gcc_custom.dll!wxEvtHandler::TryHereOnly
00007FFC2FC31040 000001586D6EB3F0 00000158771FF080 0000015870E46080  wxmsw315ud_gcc_custom.dll!wxEvtHandler::TryBeforeAndHere
00007FFC2F42DE83 000001586D6EB3F0 00000158771FF080 000001586D6EB3F0  wxmsw315ud_gcc_custom.dll!wxEvtHandler::ProcessEvent
00007FFC2F42DF7F 000001587244F920 00000158771FF080 0000002690BFF120  wxmsw315ud_gcc_custom.dll!wxEvtHandler::DoTryChain
00007FFC2F42DF10 000001587244F920 00000158771FF080 000001586CAB5FB0  wxmsw315ud_gcc_custom.dll!wxEvtHandler::ProcessEventLocally
00007FFC2F42DE95 000001587244F920 00000158771FF080 00000158773507D0  wxmsw315ud_gcc_custom.dll!wxEvtHandler::ProcessEvent
00007FFC2F42DA98 000001587244F920 0000000000000000 000001586CB042F8  wxmsw315ud_gcc_custom.dll!wxEvtHandler::ProcessPendingEvents
00007FFC2F3535ED 000001586CB04130 00007FFC2F4FFA99 000001586CB04130  wxmsw315ud_gcc_custom.dll!wxAppConsoleBase::ProcessPendingEvents
00007FFC2F37666E 000001587479F1C0 0000000000000040 0000002690BFF380  wxmsw315ud_gcc_custom.dll!wxEventLoopManual::ProcessEvents
00007FFC2F37677D 000001587479F1C0 000001587479F1D4 000001587479F100  wxmsw315ud_gcc_custom.dll!wxEventLoopManual::DoRun
00007FFC2F376234 000001587479F1C0 000001586CB042F0 000001587479F1C0  wxmsw315ud_gcc_custom.dll!wxEventLoopBase::Run
00007FFC2F352E88 000001586CB04130 0000000000000055 000001586CAB5FB0  wxmsw315ud_gcc_custom.dll!wxAppConsoleBase::MainLoop
00007FFC2F352BB2 000001586CB04130 00007FFCDC9A03E0 00007FFCDC980000  wxmsw315ud_gcc_custom.dll!wxAppConsoleBase::OnRun
00007FFC2F59BA17 000001586CB04130 000001586CB00000 0000000000000000  wxmsw315ud_gcc_custom.dll!wxAppBase::OnRun
00007FF742BF5C8A 000001586CB04130 00007FFC3028D7B0 000001586B0CC050  codeblocks.exe!CodeBlocksApp::OnRun
00007FFC2F3A0FA2 00007FFC3028D7B0 000001586B0CC050 000001586CAAF898  wxmsw315ud_gcc_custom.dll!wxEntryReal
00007FFC2F436B60 00007FFC3028D7B0 000001586B0CC050 0000000000000000  wxmsw315ud_gcc_custom.dll!wxEntry
00007FFC2F436C45 00007FF742BF0000 0000000000000000 000001586B0C3987  wxmsw315ud_gcc_custom.dll!wxEntry
00007FF742BF2544 00007FF742BF0000 0000000000000000 000001586B0C3987  codeblocks.exe!WinMain
00007FF742BF13B1 0000000000000000 0000000000000000 0000000000000000  codeblocks.exe!__tmainCRTStartup
00007FF742BF14C6 0000000000000000 0000000000000000 0000000000000000  codeblocks.exe!WinMainCRTStartup
00007FFCDC997034 0000000000000000 0000000000000000 0000000000000000  KERNEL32.DLL!BaseThreadInitThunk
00007FFCDD9E2651 0000000000000000 0000000000000000 0000000000000000  ntdll.dll!RtlUserThreadStart

This looks like the crashes during CB shutdown or when closing a file while clangd sent a response to a previous request.
Likely fixed in rev 70.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2813
Re: Code completion using LSP and clangd
« Reply #152 on: July 30, 2022, 09:53:38 pm »
I see one bug, I'm not sure it is a clangd bug or our client plugin bug.

When I do code refactoring, I mean I want to rename a variable aaa to bbb.

If there is a line:

Quote
wxLogMessage("aaa", aaa);

Then I will get this:

Quote
wxLogMessage("bbb", aaa);

maybe, clangd does not give us the column information of a variable? It just tell use the line information?

Do you mean that the unquoted aaa should have been changed to the unquoted bbb (the second parameter) ?

Yes.
Fixed rev 70

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: Code completion using LSP and clangd
« Reply #153 on: July 31, 2022, 12:03:11 am »
@BlueHazzard, maybe you can check the log files in your system Temp folder to see what content were sent from the clangd.
It could be this two logs, but i am not 100% sure:
client log:
Code
21:58:21.731 Project: Addr2LineUI wx3.1.x (64 bit): codeblocksdir\src\tools\Addr2LineUI\Addr2LineUI_wx31_64.cbp

21:58:21.731 SystemPath: C:\msys64\mingw64\bin;C:\msys64\mingw64\bin\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\tools;C:\Program Files\WireGuard;C;C:\Program Files\TortoiseSVN\bin;C:\Program Files\AMD\AMDuProf\bin;C:\Users\eberh\AppData\Local\Microsoft\WindowsApps

21:58:21.733 <<< Initialize(): codeblocksdir/src/tools/Addr2LineUI

21:58:21.734 <<< Content-Length: 1202



{"id":"initialize","jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"offsetEncoding":["utf-8"],"textDocument":{"codeAction":{"codeActionLiteralSupport":true},"completion":{"completionItem":{"deprecatedSupport":true,"snippetSupport":true},"completionItemKind":{"valueSet":[0,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]},"editsNearCursor":true},"documentSymbol":{"hierarchicalDocumentSymbolSupport":true},"hover":{"contentFormat":["plaintext"]},"publishDiagnostics":{"categorySupport":true,"codeActionsInline":true,"relatedInformation":true},"semanticTokens":{"dynamicRegistration":true},"signatureHelp":{"signatureInformation":{"parameterInformation":{"labelOffsetSupport":true}}}},"workspace":{"applyEdit":false,"symbol":{"symbolKind":{"valueSet":[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]}},"workspaceEdit":{"documentChanges":false}}},"initializationOptions":{"clangdFileStatus":false,"compilationDatabasePath":null,"configSettings":{"compilationDatabaseChanges":{}},"fallbackFlags":[]},"processId":21764,"rootPath":null,"rootUri":"file:///codeblocksdir/src/tools/Addr2LineUI"}}

21:58:21.990 >>> readJson() len:1873:
{"id":"initialize","jsonrpc":"2.0","result":{"capabilities":{"astProvider":true,"callHierarchyProvider":true,"clangdInlayHintsProvider":true,"codeActionProvider":true,"compilationDatabase":{"automaticReload":true},"completionProvider":{"allCommitCharacters":[" ","\t","(",")","[","]","{","}","<",">",":",";",",","+","-","/","*","%","^","&","#","?",".","=","\"","'","|"],"resolveProvider":false,"triggerCharacters":[".","<",">",":","\"","/","*"]},"declarationProvider":true,"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentLinkProvider":{"resolveProvider":false},"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"\n","moreTriggerCharacter":[]},"documentRangeFormattingProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyTweak"]},"hoverProvider":true,"implementationProvider":true,"memoryUsageProvider":true,"referencesProvider":true,"renameProvider":true,"selectionRangeProvider":true,"semanticTokensProvider":{"full":{"delta":true},"legend":{"tokenModifiers":["declaration","deprecated","deduced","readonly","static","abstract","virtual","dependentName","defaultLibrary","usedAsMutableReference","functionScope","classScope","fileScope","globalScope"],"tokenTypes":["variable","variable","parameter","function","method","function","property","variable","class","interface","enum","enumMember","type","type","unknown","namespace","typeParameter","concept","type","macro","comment"]},"range":false},"signatureHelpProvider":{"triggerCharacters":["(",")","{","}","<",">",","]},"textDocumentSync":{"change":2,"openClose":true,"save":true},"typeDefinitionProvider":true,"typeHierarchyProvider":true,"workspaceSymbolProvider":true},"offsetEncoding":"utf-8","serverInfo":{"name":"clangd","version":"clangd version 14.0.4 windows x86_64-w64-windows-gnu"}}}

server:
Code
Project: Addr2LineUI wx3.1.x (64 bit): codeblocksdir\src\tools\Addr2LineUI\Addr2LineUI_wx31_64.cbp
SystemPath: C:\msys64\mingw64\bin;C:\msys64\mingw64\bin\bin;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\tools;C:\Program Files\WireGuard;C;C:\Program Files\TortoiseSVN\bin;C:\Program Files\AMD\AMDuProf\bin;C:\Users\eberh\AppData\Local\Microsoft\WindowsApps
I[21:58:21.827] clangd version 14.0.4

I[21:58:21.828] Features: windows

I[21:58:21.828] PID: 26712

I[21:58:21.828] Working directory: codeblocksdir/src/tools/Addr2LineUI

I[21:58:21.828] argv[0]: C:\msys64\mingw64\bin\clangd.exe

I[21:58:21.828] argv[1]: --log=verbose

I[21:58:21.828] argv[2]: --query-driver=C:\msys64\mingw64\bin\**\x*

I[21:58:21.828] argv[3]: -j=8

I[21:58:21.828] argv[4]: --limit-results=20

I[21:58:21.828] argv[5]: --resource-dir=C:\msys64\mingw64\lib\clang\14.0.4

V[21:58:21.830] User config file is C:/Users/eberh/AppData/Local/clangd/config.yaml

I[21:58:21.830] Starting LSP over stdin/stdout

V[21:58:21.830] <<< {"id":"initialize","jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"offsetEncoding":["utf-8"],"textDocument":{"codeAction":{"codeActionLiteralSupport":true},"completion":{"completionItem":{"deprecatedSupport":true,"snippetSupport":true},"completionItemKind":{"valueSet":[0,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]},"editsNearCursor":true},"documentSymbol":{"hierarchicalDocumentSymbolSupport":true},"hover":{"contentFormat":["plaintext"]},"publishDiagnostics":{"categorySupport":true,"codeActionsInline":true,"relatedInformation":true},"semanticTokens":{"dynamicRegistration":true},"signatureHelp":{"signatureInformation":{"parameterInformation":{"labelOffsetSupport":true}}}},"workspace":{"applyEdit":false,"symbol":{"symbolKind":{"valueSet":[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]}},"workspaceEdit":{"documentChanges":false}}},"initializationOptions":{"clangdFileStatus":false,"compilationDatabasePath":null,"configSettings":{"compilationDatabaseChanges":{}},"fallbackFlags":[]},"processId":21764,"rootPath":null,"rootUri":"file:///codeblocksdir/src/tools/Addr2LineUI"}}



I[21:58:21.830] <-- initialize("initialize")

I[21:58:21.851] --> reply:initialize("initialize") 21 ms

V[21:58:21.851] >>> {"id":"initialize","jsonrpc":"2.0","result":{"capabilities":{"astProvider":true,"callHierarchyProvider":true,"clangdInlayHintsProvider":true,"codeActionProvider":true,"compilationDatabase":{"automaticReload":true},"completionProvider":{"allCommitCharacters":[" ","\t","(",")","[","]","{","}","<",">",":",";",",","+","-","/","*","%","^","&","#","?",".","=","\"","'","|"],"resolveProvider":false,"triggerCharacters":[".","<",">",":","\"","/","*"]},"declarationProvider":true,"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentLinkProvider":{"resolveProvider":false},"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"\n","moreTriggerCharacter":[]},"documentRangeFormattingProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyTweak"]},"hoverProvider":true,"implementationProvider":true,"memoryUsageProvider":true,"referencesProvider":true,"renameProvider":true,"selectionRangeProvider":true,"semanticTokensProvider":{"full":{"delta":true},"legend":{"tokenModifiers":["declaration","deprecated","deduced","readonly","static","abstract","virtual","dependentName","defaultLibrary","usedAsMutableReference","functionScope","classScope","fileScope","globalScope"],"tokenTypes":["variable","variable","parameter","function","method","function","property","variable","class","interface","enum","enumMember","type","type","unknown","namespace","typeParameter","concept","type","macro","comment"]},"range":false},"signatureHelpProvider":{"triggerCharacters":["(",")","{","}","<",">",","]},"textDocumentSync":{"change":2,"openClose":true,"save":true},"typeDefinitionProvider":true,"typeHierarchyProvider":true,"workspaceSymbolProvider":true},"offsetEncoding":"utf-8","serverInfo":{"name":"clangd","version":"clangd version 14.0.4 windows x86_64-w64-windows-gnu"}}}

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2813
Re: Code completion using LSP and clangd
« Reply #154 on: July 31, 2022, 12:40:25 am »
@BlueHazzard, maybe you can check the log files in your system Temp folder to see what content were sent from the clangd.

To find a particular clangd_client log, look at the file "CBclangd_LogsIndex.txt" in your temp folder.

Each line contains the processid, the date and time of the log, location of the clangd executable, and the CB project .cbp filename.

The logs are named:
\temp\CBclangd_client-<processID>.log
\temp\CBclangd_server-<processID>.log

The CBclangd_client-<processID>.log is the most interesting for debugging CB.

The CBclangd_client-<processID>.log is useful for probing/debugging clangd and is usually required to submit bug reports to the clangd team.

One log (not so interesting) exists for the CC_ProxyProject.cbp. It handles parsing non-project files.

Two logs for each opened project; The client log and the server log.

The first log line header contains the project it belong to. And the .cbp that created it. the time is on the left.

Edit: 2022/07/31
The log representing a project contains all clangd requests and responses for any file or any target. 
In error, I said that there was a log for each target. Not so.
« Last Edit: July 31, 2022, 07:40:26 pm by Pecan »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: Code completion using LSP and clangd
« Reply #155 on: July 31, 2022, 01:04:14 am »
The crash is still happening with r70,
i can reproduce it now:
1) Open codeblocks
2) Open a project with some code (i used the clang_cc project)
3) Hit recompile as fast as you can after project load, and the cc parser is not finished. compiling will start and in the middle -> crash

backtrace and log content is the same as in my previous posts

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2813
Re: Code completion using LSP and clangd
« Reply #156 on: July 31, 2022, 01:24:01 am »
The crash is still happening with r70,
i can reproduce it now:
1) Open codeblocks
2) Open a project with some code (i used the clang_cc project)
3) Hit recompile as fast as you can after project load, and the cc parser is not finished. compiling will start and in the middle -> crash

backtrace and log content is the same as in my previous posts

I'm having a problem getting the crash.

Would you please copy your devel31_64 version of clangd_client.dll with the debug symbols over the top of your output31_64 version and post the crash .RPT file.

Offline AndrewCot

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 679
Re: Code completion using LSP and clangd
« Reply #157 on: July 31, 2022, 03:36:15 am »
I was not able to re-create the crash, but I got a crash if I close C::B down while compiling which did not occur with the latest nightly.  I close by clicking on the [X] on the top right of the C::B window. This crash does not include any ClangD-cleint functions, but does have event functions  in the stack so there is a very small slim possibility it could be related and this is why I am posting it here just in case I am wrong.

Code
-------------------

Error occurred on Sunday, July 31, 2022 at 11:00:29.

CodeBlocks.exe caused an Access Violation at location 00007FFFFAAAC2DC in module codeblocks.dll Reading from location FFFFFFFFFFFFFFFF.

AddrPC           Params
00007FFFFAAAC2DC 00000120EBD30BE0 0000001A76BFED50 00000000000005E9  codeblocks.dll!wxPostEvent+0x9c  [D:/Andrew_Development/Libraries/wxWidgets-3.2.0_win64/include/wx/event.h @ 4169]
  4167:     wxCHECK_RET( dest, "need an object to post event to" );
  4168:
> 4169:     dest->AddPendingEvent(event);
  4170: }
  4171:
00007FFFFA8BD86B 00000120F3EED750 00007FFF000049E8 0000000000000000  codeblocks.dll!PipedProcess::OnTerminate+0xd7  [D:/Andrew_Development/Work_Installers/CodeBLocks_Private_Experimental_GCC/src/sdk/pipedprocess.cpp @ 235]
   233:     event.SetInt(status);
   234:     event.SetX(m_Index);
>  235:     wxPostEvent(m_Parent, event);
   236:
   237:     if (m_pvThis)
00007FFFC2B555A6 00000000002309D0 0000000000002B10 0000000000000000  wxmsw32ud_gcc_cb.dll!wxExecuteWindowCbk+0xaf  [D:/Andrew_Development/Libraries/wxWidgets-3.2.0_win64/build/msw/../../src/msw/utilsexc.cpp @ 341]
   339:         if ( data->handler )
   340:         {
>  341:             data->handler->OnTerminate((int)data->dwProcessId,
   342:                                        (int)data->dwExitCode);
   343:         }
00007FF848E3E858 0000001A76BFF1E0 00007FFFC2B554F7 00000000002309D0  USER32.dll!UserCallWinProcCheckWow+0x2f8
00007FF848E3E3DC 0000000000000000 0000000000000000 0000000000000000  USER32.dll!DispatchClientMessage+0x9c
00007FF848E50BC3 0000000000000000 0000000000000000 00000000000083AE  USER32.dll!__fnDWORD+0x33
00007FF849CF0D74 00007FF848E3A5C3 0000000000000000 0000000000000000  ntdll.dll!KiUserCallbackDispatch+0x24
00007FF847641064 0000000000000000 0000000000000000 0000000000000000  win32u.dll!NtUserPeekMessage+0x14
00007FF848E3A5C3 0000000000000000 00000120E8FCC7E0 0000000000000000  USER32.dll!_PeekMessage+0x43
00007FF848E3A523 00000120EA4331A8 0000001A76BFF440 0000000000000038  USER32.dll!PeekMessageW+0x143
00007FFFC2B37CAF 00000120EF9E2370 00000120EF9E2370 0000001A76BFF490  wxmsw32ud_gcc_cb.dll!wxMSWEventLoopBase::Pending+0x35  [D:/Andrew_Development/Libraries/wxWidgets-3.2.0_win64/build/msw/../../src/msw/evtloopconsole.cpp @ 62]
    60: {
    61:     MSG msg;
>   62:     return ::PeekMessage(&msg, 0, 0, 0, PM_NOREMOVE) != 0;
    63: }
    64:
00007FFFC2AA6E6C 00000120EF9E2370 00000120EF9E2384 0000000000000000  wxmsw32ud_gcc_cb.dll!wxEventLoopManual::DoRun+0x52  [D:/Andrew_Development/Libraries/wxWidgets-3.2.0_win64/build/msw/../../src/common/evtloopcmn.cpp @ 276]
   274:                 // for them too
   275:                 while ( !m_shouldExit
>  276:                             && !Pending()
   277:                                 && !(wxTheApp && wxTheApp->HasPendingEvents())
   278:                                     && ProcessIdle() )
00007FFFC2AA6973 00000120EF9E2370 00000120EA47B650 00000120EF9E2370  wxmsw32ud_gcc_cb.dll!wxEventLoopBase::Run+0xf7  [D:/Andrew_Development/Libraries/wxWidgets-3.2.0_win64/build/msw/../../src/common/evtloopcmn.cpp @ 87]
    85:
    86:     // Finally really run the loop.
>   87:     return DoRun();
    88: }
    89:
00007FFFC2A82E85 00000120EA47B490 0000000000000038 0000000000000000  wxmsw32ud_gcc_cb.dll!wxAppConsoleBase::MainLoop+0x93  [D:/Andrew_Development/Libraries/wxWidgets-3.2.0_win64/build/msw/../../src/common/appbase.cpp @ 381]
   379:         wxTheApp->OnLaunched();
   380:
>  381:     return m_mainLoop ? m_mainLoop->Run() : -1;
   382: }
   383:
00007FFFC2A82BBD 00000120EA47B490 00007FF8490703E0 00007FF849050000  wxmsw32ud_gcc_cb.dll!wxAppConsoleBase::OnRun+0x25  [D:/Andrew_Development/Libraries/wxWidgets-3.2.0_win64/build/msw/../../src/common/appbase.cpp @ 303]
   301: int wxAppConsoleBase::OnRun()
   302: {
>  303:     return MainLoop();
   304: }
   305:
00007FFFC2CDDF7B 00000120EA47B490 00007FF849C75BA1 0000000000000000  wxmsw32ud_gcc_cb.dll!wxAppBase::OnRun+0x35  [D:/Andrew_Development/Libraries/wxWidgets-3.2.0_win64/build/msw/../../src/common/appcmn.cpp @ 334]
   332:     //else: it has been changed, assume the user knows what he is doing
   333:
>  334:     return wxAppConsole::OnRun();
   335: }
   336:
00007FF62FE68EBC 00000120EA47B490 00007FFFC3ADA7B0 00000120E8A1EAF0  CodeBlocks.exe!CodeBlocksApp::OnRun+0x30  [D:/Andrew_Development/Work_Installers/CodeBLocks_Private_Experimental_GCC/src/src/app.cpp @ 1070]
  1068:     try
  1069:     {
> 1070:         int retval = wxApp::OnRun();
  1071:         // wx 2.6.3 docs says that OnRun() function's return value is used as exit code
  1072:         return m_Batch ? m_BatchExitCode : retval;
00007FFFC2AD1B32 00007FFFC3ADA7B0 00000120E8A1EAF0 00000120EA4692F0  wxmsw32ud_gcc_cb.dll!wxEntryReal+0xaa  [D:/Andrew_Development/Libraries/wxWidgets-3.2.0_win64/build/msw/../../src/common/init.cpp @ 503]
   501:
   502:         // app execution
>  503:         return wxTheApp->OnRun();
   504:     }
   505:     wxCATCH_ALL( wxTheApp->OnUnhandledException(); return -1; )
00007FFFC2B69390 00007FFFC3ADA7B0 00000120E8A1EAF0 0000000000000000  wxmsw32ud_gcc_cb.dll!wxEntry+0x20  [D:/Andrew_Development/Libraries/wxWidgets-3.2.0_win64/build/msw/../../src/msw/main.cpp @ 184]
   182: int wxEntry(int& argc, wxChar **argv)
   183: {
>  184:     return wxEntryReal(argc, argv);
   185: }
   186:
00007FFFC2B6947A 00007FF62FE60000 0000000000000000 00000120E8A13C5A  wxmsw32ud_gcc_cb.dll!wxEntry+0x4e  [D:/Andrew_Development/Libraries/wxWidgets-3.2.0_win64/build/msw/../../src/msw/main.cpp @ 296]
   294:         return -1;
   295:
>  296:     return wxEntry(wxArgs.argc, wxArgs.argv);
   297: }
   298:
00007FF62FE6257D 00007FF62FE60000 0000000000000000 00000120E8A13C5A  CodeBlocks.exe!WinMain+0x3a  [D:/Andrew_Development/Work_Installers/CodeBLocks_Private_Experimental_GCC/src/src/app.cpp @ 339]
   337: } // namespace
   338:
>  339: IMPLEMENT_APP(CodeBlocksApp) // TODO: This gives a "redundant declaration" warning, though I think it's false. Dig through macro and check.
   340:
   341: BEGIN_EVENT_TABLE(CodeBlocksApp, wxApp)
00007FF62FE613AE 0000000000000000 0000000000000000 0000000000000000  CodeBlocks.exe!__tmainCRTStartup+0x22e  [C:/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c @ 329]
00007FF62FE614E6 0000000000000000 0000000000000000 0000000000000000  CodeBlocks.exe!mainCRTStartup+0x16  [C:/M/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crtexe.c @ 206]
00007FF849067034 0000000000000000 0000000000000000 0000000000000000  KERNEL32.DLL!BaseThreadInitThunk+0x14
00007FF849CA2651 0000000000000000 0000000000000000 0000000000000000  ntdll.dll!RtlUserThreadStart+0x21

Windows 10.0.19044
DrMingw 0.9.5


Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code completion using LSP and clangd
« Reply #158 on: July 31, 2022, 06:10:12 am »
Hi, Pecan, if possible, can you have several more small svn commits instead of a big svn commit.

I mean I see your commit history(such as rev70), it mainly have several code changes from many places, and the expected way is for each logic code change, you should have a commit. This make the code a bit clean and easy to track.

Thanks.

BTW: The best way is using git, not svn.  :)
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 MaxGaspa

  • Multiple posting newcomer
  • *
  • Posts: 37
Re: Code completion using LSP and clangd
« Reply #159 on: September 07, 2022, 10:26:16 pm »
Hi Pecan,

I' using the ClangdClientForCBNightly_20220813_rev12864_win64.zip with the latest CB nightly and I'm observing a minor issue and a crash. They are present on both Win7 Pro  and Windows 10 Enterprise

The minor issue is related to the option "Update parser when typing )on save otherwise". I de-select this option because I'd like to update just when I'm saving the file. In reality the updating happens both when typing and (instead of otherwise) when saving. May be this is the implemented feature but in some cases the parser updating when typing is a little bit annoying, I think that updating just on saving can be very useful especially when you are typing a new code and several errors appears when I'm correcting them

The crash happens when the window, shown in the attached picture , is present in the editor. CB just freeze and the a crash happen. I'm also attaching the .RPT file related to this crash.

Hope this helps

Max

Offline AndrewCot

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 679
Re: Code completion using LSP and clangd
« Reply #160 on: September 08, 2022, 12:21:10 am »
MaxGaspa, The type of crash in the rpt file has been seen before and Miguel has made some changes a month or two ago that reduced the occurrence of it, but it looks like it is still occurring.  It is my understanding from what I have seen that the problem is not to do with the Clangd_Client plugin, but you just had the dialog up when it crashed.

Just before it crashed were you editing or had some other app (not C::B) in focus?


It looks like it could be the same or similar issue to the crashes as per the following ticket:
https://sourceforge.net/p/codeblocks/tickets/1168

Offline MaxGaspa

  • Multiple posting newcomer
  • *
  • Posts: 37
Re: Code completion using LSP and clangd
« Reply #161 on: September 08, 2022, 03:14:46 am »
Just before it crashed were you editing or had some other app (not C::B) in focus?

I was editing the related file source file in CB ....

Max

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Code completion using LSP and clangd
« Reply #162 on: September 09, 2022, 07:15:02 am »
The crash(both reported by MaxGaspa and https://sourceforge.net/p/codeblocks/tickets/1168/) looks like inside the CCManager code:

Code
AddrPC           Params
0000000070CB7861 000000002D1DC710 000000000083EDDC 000000000083EDD8  codeblocks.dll!cbThreadPool::Done
0000000070CB7497 000000000083EE30 000000002D1DC710 000000002D96A1F0  codeblocks.dll!cbThreadPool::Done
00000000709830CA 000000000B03A350 000000000083F140 000000002F8D3F80  codeblocks.dll!CCManager::OnPopupScroll

Mainly in the CCManager::OnPopupScroll function.
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
Re: Code completion using LSP and clangd
« Reply #163 on: September 10, 2022, 09:14:35 pm »
I'm beginning to think this actually is a clangd_client problem.
Clangd_client is using a feature of ccmanager that was never used before. Namely a call to ccmanager::NotifyDocumentation().
CodeCompletion never used it. No other code has ever used it. So this is a path through ccmanager that has previously never been thoroughly test.

I'm working on it.

Edit: 2022/09/13
As it turns out, the problem existed before clangd_client was created.
But clangd_client gets the problem also.
The html documentation popup gets stuck opened (usually by slow double-clicking on a completion selection) and cannot be closed. Using the mouse to focus outside CB then attempting to focus back into CB reveils the stall.
The debugger just shows (for me) "corrupted stack".
But I suspect the stall occurs before focusing outside CB.
« Last Edit: September 13, 2022, 09:25:04 pm by Pecan »

Offline gd_on

  • Lives here!
  • ****
  • Posts: 800
Re: Code completion using LSP and clangd
« Reply #164 on: September 12, 2022, 04:26:59 pm »
Probably because of recent changes in C::B sdk, clangd_client does not compile when using wxWidgets 3.2.1 (probably >= 3.1.6)
Error in client.cpp, line 3672 : CodeBlocksLogEvent waits for a wxBitmapBundle*, but logbmp is a wxBitmap*
Windows 11 64 bits (23H2), svn C::B (last version or almost!), wxWidgets 3.2.5 (tests with 3.3), Msys2 Compilers 14.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).