Closed dreamtomb closed 6 years ago
@dreamtomb Are you saying that if you remove vector<int> v
and the references to v
, it will run? Are you sure that your compilation step isn't failing?
@pieandcakes thank you for your reply。
That was almost right.I mean that if i don't use Vector ,my program can run and the cmd window is displayed normally,but if i use Vector(or stack),the program can't run and the cmd window appear and disappear soon .And it shows that
=thread-group-added,id="i1" GNU gdb (GDB) 7.6.1 Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "mingw32". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. =cmd-param-changed,param="pagination",value="off" [New Thread 10920.0x2f9c] [New Thread 10920.0x3fe8] [New Thread 10920.0x116c] [New Thread 10920.0x1c90] ERROR: During startup program exited with code 0xc0000139.
Do you know what should i do?Thank you sincerely。
can you see if compilation generated an error?
Also, which version of mingw are you using?
@pieandcakes sorry,what should i do for your first question? And this is my mingw version : gcc version 6.3.0 (MinGW.org GCC-6.3.0-1)
@dreamtomb can you see if you can get a newer version of MinGW? I can't duplicate your problem so i'm wondering if it is a toolset version issue:
g++ --version g++ (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 7.1.0 Copyright (C) 2017 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
gdb --version GNU gdb (GDB) 7.11.1 Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
@pieandcakes sorry,this time i update the mingw,and it didn't help.
it shows : =thread-group-added,id="i1" GNU gdb (GDB) 8.0.1 Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-w64-mingw32". Type "show configuration" for configuration details. For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word". =cmd-param-changed,param="pagination",value="off" [New Thread 9952.0x3588] [New Thread 9952.0x2ca4] [New Thread 9952.0x44b8] [New Thread 9952.0x14bc] [Thread 9952.0x44b8 exited with code 3221225785] [Thread 9952.0x14bc exited with code 3221225785] ERROR: Unable to start debugging. GDB exited unexpectedly.
After you update, did you recompile?
Can you enable logging and see if we get more information? Add "logging": { "engineLogging": true }
to your launch.json
@pieandcakes it shows this:
1: (171) LaunchOptions<LocalLaunchOptions xmlns='http://schemas.microsoft.com/vstudio/MDDDebuggerOptions/2014'
1: (182) LaunchOptions ExePath='f:\c_plusplus_project\PAT_and_postgraduate\PAT\B_level\1002\main.cpp.exe'
1: (182) LaunchOptions WorkingDirectory='f:\c_plusplus_project\PAT_and_postgraduate\PAT\B_level\1002'
1: (182) LaunchOptions ExeArguments=''
1: (182) LaunchOptions MIMode='gdb'
1: (182) LaunchOptions MIDebuggerPath='C:/MinGW/mingw32/bin/gdb.exe'
1: (182) LaunchOptions WaitDynamicLibLoad='false'
1: (182) LaunchOptions ExternalConsole='true'
1: (182) LaunchOptions>
1: (182) LaunchOptions
ERROR: During startup program exited with code 0xc0000139. 1: (1266) <--gdb-exit
I see gdb
gives us:
1: (1171) ->1011^error,msg="During startup program exited with code 0xc0000139."
Searching online, it shows that gdb can't find the entrypoint of some library code which seems to be an issue where your compiler doesn't match your debugger. If you are using MinGW's gdb to compile, you need to make 100% sure you are also using the same g++ to compile your code, else it looks like you get this message.
@pieandcakes sorry,i am a beginner,and i just tried a simple loop,and i find that it can run and debug.so what should i do to make my gdb and g++ same?
Did you recompile after you updated MinGW using specifically the g++ that is in the MinGW toolset? Provide the full path to g++ when you are compiling. Can you make sure you can run the app from the command line after you have done that and make sure it will run? Then try again.
Thank you for your help.
Did that work?
@pieandcakes yes,it finally works.Thank you very much.
I'm having a similar issue to the one reported in this thread, but not only with vector, but also with string or map for example.
I've made sure that I'm compiling and debugging g++ and gdb of the same mingw version, but the program would still not debug whenever I try to use one of these standard libraries... any advice?
tasks.json:
{ "version": "2.0.0", "tasks": [ { "type": "shell", "label": "C/C++: g++.exe build active file", "command": "C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\g++.exe", "args": [ "-g", "${file}", "-o", "${fileDirname}\${fileBasenameNoExtension}.exe" ], "options": { "cwd": "${workspaceFolder}" }, "problemMatcher": [ "$gcc" ], "group": { "kind": "build", "isDefault": true } } ] }
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": "g++.exe - Build and debug active file", "type": "cppdbg", "request": "launch", "program": "${fileDirname}\${fileBasenameNoExtension}.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "MIMode": "gdb", "miDebuggerPath": "C:\Program Files\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin\gdb.exe", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ], "preLaunchTask": "C/C++: g++.exe build active file", // "logging": { "engineLogging": true } } ] }
If anyone is still searching for a solution, follow this guide. It solved all debugging problems for me.
For me creating a new workspace worked somehow.
hello,when i use vscode,if i use vector ,i can't debug the program . i use windows 10, i use vscode 1.19.1,c/c++0.14.5, here is my launch.json:
{ "version": "0.2.0", "configurations": [ { "name": "(gdb) Launch", "type": "cppdbg", "request": "launch", "program": "${file}.exe", "args": [], "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": "task1" } ] }
and here is my tasks.json:
{ "version": "2.0.0", "tasks": [ { "label": "task1", "type": "shell", "command": "g++", "args": [ "-g","-Wall","-std=c++11","${file}","-o","${file}.exe" ], "group": { "kind": "build", "isDefault": true } } ] }
and here is my program: `#includeinclude
using namespace std; int main(){ vector v;
for(int i=0;i<10;i++){
v.push_back(i);
}
for(int i=0;i<10;i++){
cout<<v.at(i)<<endl;
}
system("pause");
}`
then only when i use vector and press F5,i can't debug. what should i do?thank you very much!