While debugging like normally (before I didn't have this kind of problem) GDB returned message :
Internal error while converting character sets: No error.
Only for viewing string or char kind of variables.
I have tried to disable Windows beta UTF-8 engine, tried additional commands from here StackOverflow
Unfortunately nothing works.
Adding additional command for GDB logging I receive the same message.
1: (394137) ->1059^error,msg="Internal error while converting character sets: No error."
EDIT
As #rainbow.gekota requested, I added some more informations.
Current OS : Windows 10 21H2 (Compilation: 19044:2006)
VSCode ver. : 1.72.0 x64 -> 64bbfbf67ada9953918d72e1df2f4d8e537d340e
GDB ver. : 12.1 for MinGW-W64 x86_64, built by Brecht Sanders
GDB installed from MSYS2 repos.
Here's my launch.json with which I was trying to fix this error with set charset UTF-8
{
"version": "0.2.0",
"configurations": [
{
"name": "Start debugging",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\main.exe",
"args": ["arg1", "arg2", "arg3"],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Fix pretty-printing for gdb",
"text": "set charset UTF-8"
}
],
"preLaunchTask": "Build program",
"logging": { "engineLogging": true }
}
]
}
I don't have any more idea how to reproduce this error. It was working fine until one day.
Unfortunately I couldn't find any logical answer to my question. The only thing that helped was deleting MSYS2 with gdb and gcc installed and installing it once again.
Now I can't reproduce this issues so maybe in the future I'll comeback with the same error. Will see.
Related
Sorry if this has been asked before, but I don't get the previous given answers. I'm new to VS Code and know a bit of c++ coding. I tried the tutorial for windows/mingw :
https://code.visualstudio.com/docs/cpp/config-mingw#_step-through-the-code
and done everything so far. The sample code has been build and I want to debug now, but my variables view is showing something different when stepping through the application when debugging. (see attached image)
The word should contain any of the strings, as well as msg should show something different. My watch for a self made i int shows correctly, though. Whats'up? I did everything as in the tutorial.
also: the terminal tab does not output the msg from cout, but I see it in the debug console instead. (see image in tutorial just above the chapter 'set a watch')
launch.json is:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++.exe - Aktive Datei erstellen und debuggen",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Automatische Strukturierung und Einrückung für \"gdb\" aktivieren",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: g++.exe build active file"
}
]
}
sorry, i'm a newb to vs code :-/
I re-installed using the 64bit version of MinGW from sourceforge as I had an old 32 bit version running via mingw-get.
One possible cause is that pretty-printing did not display UTF-8 content correctly. You can either:
Set it to UTF-8 charset (VSCode debugger having issues with character encoding)
Disable pretty-printing (Cannot see any variable values while debugging)
I'm at a bit of a loss here, I hadn't really expected this to be difficult. I usually work on Linux, but today I had some work that I needed to do and only had a Windows machine. I thought this would be no problem, I can install git for windows, clone my project, and get right to work. Its just been a huge mess. I'm really hoping someone can help me understand where I went wrong in setting all this up on Windows. It isn't something I plan to do frequently, but definitely something I want to be able to do on a Windows machine in a reasonable amount of time.
I'm using WSL and have set my default VSCode Windows integrated terminal to C:\WINDOWS\System32\bash.exe
I installed Windows 10 SDK to fix crtdbg.h include errors as a dependency against <iostream>
I installed gdb with MinGW -
I set the path environment variable
I created a launch.json -
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) CDLL Driver",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/driver",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
My MinGW bin contains the following
I launch my debug task in VSCode and I get the following error
cmd /C "c:\Users\shaun\.vscode\extensions\ms-vscode.cpptools-0.28.2\debugAdapters\bin\WindowsDebugLauncher.exe --stdin=Microsoft-MIEngine-In-4n4ohh2f.ibt --stdout=Microsoft-MIEngine-Out-1irudlfy.q5x --stderr=Microsoft-MIEngine-Error-fg20cagk.ynl --pid=Microsoft-MIEngine-Pid-kzdzn4p4.lro --dbgExe=C:\MinGW\bin\gdb.exe --interpreter=mi "
Command 'cmd' not found, but there are 16 similar ones.
I can provide more information if needed. I'm really hoping I missed something simple here that would be obvious to someone who works on Windows.. Thank you in advance, I really appreciate the help!
If you are using WSL to compile the project you should not use MinGW gdb.
You need to install gdb on you Linux subsystem (using native tools like apt if you are using Ubuntu WSL), reopen your project in WSL and configure the WSL path to gdb.
I was able to successfully debug using this setup on WSL.
Replace your launch.json file with this file
{
"version": "0.2.0",
"configurations": [
{
"args": ["1"],
"name": "gcc.exe - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc.exe build active file"
}
]
}
Make Sure you have installed MinGw Compiler and gdb debugger
I am following that tutorial from the VScode team :
https://code.visualstudio.com/docs/cpp/config-wsl#_debug-helloworldcpp
I have run and built another c++ project.
It compiles but the project kraches at runtime, so I decide to debug it.
So i want to debug and I use gdb as proposed by this good tutorial.
When I execute the debugging with "F5", I have that launch.json file :
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "g++ build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "executable.out",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "g++ build active file",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
I have modified the "program" section to put the name of my executable ( executable.out) , which is located in the "workspaceFolder"
So I don't understand the error message I get when I do "F5" :
launch : program "executable.out" does not exist
Could someone explain to me how to solve that ?
I thought a lot before posting this question.
Thanks a lot in advance.
Best regards
Use absolute path in program:
"program": "${workspaceFolder}/executable.out"
I assume you are using Linux, since you are using g++ compiler.
Did you compile your cpp file to "executable.out", e.g.
g++ main.cpp -o executable.out
Your launch.json configuration look fine to me. It should work.
I'm trying to remote debug a c++ app from a VM ubuntu 16.04 amd64 host to a debian armbian target of cubietruck board (ARM® Cortex™-A7 Dual-Core) via vs code.
I have follwed this guide https://medium.com/#spe_/debugging-c-c-programs-remotely-using-visual-studio-code-and-gdbserver-559d3434fb78 with the only addition of the field
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
so the whole launch.json has become
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Launch",
"type": "cppdbg",
"request": "launch",
"miDebuggerPath": "/home/user/ARM/gcc-linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"program": "/home/user/myproject/bin/app",
"miDebuggerServerAddress": "localhost:9091",
"args": [],
"stopAtEntry": false,
"cwd": "/home/user/myproject",
"environment": [],
"externalConsole": true,
"linux": {
"MIMode": "gdb"
},
"osx": {
"MIMode": "gdb"
},
"windows": {
"MIMode": "gdb"
}
}
]
}
in launch.json file so as to support pretty printer.
In the host I'm using the linaro-7.3.1-2018.05-x86_64_arm-linux-gnueabihf gdb while the gdb in arm board has the native 8.0.1 gdb.
Everything works fine except from the pretty printer since the strings are not shown correctly. Whenever I hover over a string the fields npos and _M_dataplus pop up and one should open the _M_dataplus filed to see the actual string.
In host the linaro gdb supports pretty-printer since the command info pretty-printer gives the output :
builtin
mpx_bound128
However when I give the same command in target gdb 8.0.1, I get:
Undefined info command: "pretty-printer". Try "help info".
I also created a .gdbinit file in my host home folder that contains the enable pretty-printer command. I saw in the debug console that it was executed successfully but the result was erroneous as well.
Since I am pretty novice in remote debugging, what should I do to get the pretty-printer working. Should I install pretty-printer in the remote board as well or am I doing something else wrong?
1.make sure your bin is NOT built with -static-libstdc++
2.if you have to use -static-libstdc++, please add the following in your ~/.gdbinit:
python sys.path.append('/usr/share/gdb/python') <--provided by gdb `show configuration: --with-gdb-datadir=`
python sys.path.append("/usr/share/gcc-8/python/") <--corresponding to your gcc version
source /usr/share/gdb/auto-load/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.25-gdb.py <--this script is for std::string/list/map/etc pretty-printing.
3.edit your launch.json:
"setupCommands": [
{ "text": "-interpreter-exec console \"set sysroot /\"", "ignoreFailures": true },
{ "text": "-enable-pretty-printing", "ignoreFailures": true },
],
This is what I did to resolve the same issue occured to me. Hope this would resolve your issue.
ref1: http://tomszilagyi.github.io/2018/03/Remote-gdb-with-stl-pp
ref2: http://transit.iut2.upmf-grenoble.fr/doc/gdb-doc/html/gdb/Writing-a-Pretty_002dPrinter.html
ref3: Import Error: No module name libstdcxx
I've created a c++ project on ubuntu in visual studio code.
It launches the program using gdb mode, but does not show anything in Output. When I launch program from console, the output is present. I tried inserting "console" property, but vscode tells me, that it is forbidden (from similar issue with node https://github.com/Microsoft/vscode/issues/30842).
How can I enable vscode to show the output from my program?
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
You config is correct. The program output should be in the DEBUG CONSOLE.
Menu | Debug Console or Ctrl+Shift+Y.
The program was launched in external terminal and due to the configuration of my screen I didn't see it. Everything works fine.
Add this line in setting.json in code-runner.executorMap
"cpp": "g++ -o $fileNameWithoutExt $fileNameWithoutExt.cpp && ./$fileNameWithoutExt"