A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/microsoft/vscode-cpptools/issues/1768 below:

Watching local variables of types vectors, maps etc. is empty when debugging C++ with lldb · Issue #1768 · microsoft/vscode-cpptools · GitHub

Steps to Reproduce:

// app.cpp
#include <iostream>
#include <vector>
#include <map>
#include <string>

int main() {
	int i = 4;
	std::string s = "four";
	std::vector<int> v;
	std::map<int,std::string> m;
	v.push_back(2);
	v.push_back(1);
	v.push_back(3);
	m.insert(std::make_pair(2,"two"));
	m.insert(std::make_pair(1,"one"));
	m.insert(std::make_pair(3,"three"));
}
// launch.json
{
        
	"version": "0.2.0",
	"configurations": [
		{
			"name": "(lldb) Launch",
			"type": "cppdbg",
			"request": "launch",
			"program": "${workspaceFolder}/app",
			"args": [],
			"stopAtEntry": false,
			"cwd": "${workspaceFolder}",
			"environment": [],
			"externalConsole": false,
			"MIMode": "lldb"
		}
	]
}

Built with:
g++ -o app app.cpp -g -Wall -std=c++17 -lstdc++

Watchlist shows this at breakpoint for last statement in main:

i: 4
s: "four"
v: size=0
m: size=0

Using lldb manually from terminal shows correct content of v, and m:

Process 8715 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x00000001000018d5 app`main at app.cpp:18
   15           v.push_back(3);
   16           m.insert(std::make_pair(2,"two"));
   17           m.insert(std::make_pair(1,"one"));
-> 18           m.insert(std::make_pair(3,"three"));
   19   }
   20
   21
Target 0: (app) stopped.
(lldb) p m
(std::__1::map<int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<int>, std::__1::allocator<std::__1::pair<const int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > >) $0 = size=2 {
  [0] = (first = 1, second = "one")
  [1] = (first = 2, second = "two")
}
(lldb) p s
(std::__1::string) $1 = "four"
(lldb) p v
(std::__1::vector<int, std::__1::allocator<int> >) $2 = size=3 {
  [0] = 2
  [1] = 1
  [2] = 3
}

Output console:
Extensions:
waiting for v8 protocol on stdin/stdout

kghose, dareagle, juliorenner, arberx, ueoo and 28 more


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4