Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:01,389 --> 00:00:07,199
[Music]
2
00:00:04,960 --> 00:00:09,280
hi everyone my name is erica sweet i
3
00:00:07,200 --> 00:00:11,839
work on the c plus plus team and i'm
4
00:00:09,279 --> 00:00:14,079
here to share what's new for c plus plus
5
00:00:11,839 --> 00:00:17,198
cross platform developers and visual
6
00:00:14,080 --> 00:00:20,000
studio 2022 if you're a c plus plus
7
00:00:17,199 --> 00:00:22,080
developer who is building for or looking
8
00:00:20,000 --> 00:00:24,559
to add support for more than one
9
00:00:22,079 --> 00:00:27,198
platform or if you're developing with an
10
00:00:24,559 --> 00:00:28,399
eye to open source then this talk is for
11
00:00:27,199 --> 00:00:30,800
you
12
00:00:28,399 --> 00:00:32,799
maybe you target both windows and linux
13
00:00:30,800 --> 00:00:35,200
but your team isn't as familiar or
14
00:00:32,799 --> 00:00:36,640
productive with command line tools like
15
00:00:35,200 --> 00:00:38,640
gdb
16
00:00:36,640 --> 00:00:40,878
maybe you maintain different workflows
17
00:00:38,640 --> 00:00:43,359
or configuration files for every
18
00:00:40,878 --> 00:00:45,199
combination of target platform and
19
00:00:43,359 --> 00:00:47,439
development environment and you're
20
00:00:45,200 --> 00:00:50,239
looking to streamline that process while
21
00:00:47,439 --> 00:00:52,399
still supporting a diverse set of tools
22
00:00:50,238 --> 00:00:55,038
or maybe you only build locally for
23
00:00:52,399 --> 00:00:57,520
windows and you rely on your ci pipeline
24
00:00:55,039 --> 00:00:59,840
to check non-windows builds
25
00:00:57,520 --> 00:01:02,239
if you don't target windows at all then
26
00:00:59,840 --> 00:01:05,040
stay tuned as we discuss c plus plus
27
00:01:02,238 --> 00:01:07,679
cross platform dependency management and
28
00:01:05,040 --> 00:01:10,960
build and debug a linux skui application
29
00:01:07,680 --> 00:01:13,040
natively on windows with wsl
30
00:01:10,959 --> 00:01:15,759
so i'm starting with a cmake project
31
00:01:13,040 --> 00:01:17,920
open in visual studio cmic is an open
32
00:01:15,759 --> 00:01:20,000
source cross-platform build system
33
00:01:17,920 --> 00:01:22,640
generator that's supported natively in
34
00:01:20,000 --> 00:01:24,560
visual studio and is our recommendation
35
00:01:22,640 --> 00:01:27,280
for c plus plus cross-platform
36
00:01:24,560 --> 00:01:29,439
development if you don't use cmake then
37
00:01:27,280 --> 00:01:31,200
visual studio has remote debugging tools
38
00:01:29,438 --> 00:01:33,279
for you that we'll cover in the second
39
00:01:31,200 --> 00:01:35,118
half of this demo
40
00:01:33,280 --> 00:01:37,759
one piece of feedback that we received
41
00:01:35,118 --> 00:01:40,078
on visual studio 2019 was that it could
42
00:01:37,759 --> 00:01:42,079
be difficult to reproduce cmake builds
43
00:01:40,078 --> 00:01:44,319
outside a visual studio
44
00:01:42,078 --> 00:01:46,559
so to address this we work closely with
45
00:01:44,319 --> 00:01:49,919
the maintainers of cmake to develop a
46
00:01:46,560 --> 00:01:52,240
new file called cmakepresets.json
47
00:01:49,920 --> 00:01:54,320
that's supported directly by cmake and
48
00:01:52,239 --> 00:01:56,319
can be used to drive cmake generation
49
00:01:54,319 --> 00:01:57,359
and build both with and without our
50
00:01:56,319 --> 00:01:59,039
tools
51
00:01:57,359 --> 00:02:02,000
that means your team can use it from
52
00:01:59,040 --> 00:02:05,200
visual studio from vs code from the
53
00:02:02,000 --> 00:02:08,479
cmake gui in a ci pipeline or from the
54
00:02:05,200 --> 00:02:10,319
command line on windows linux and mac
55
00:02:08,479 --> 00:02:12,640
visual studio's cmake presets
56
00:02:10,318 --> 00:02:14,519
integration is automatically enabled for
57
00:02:12,639 --> 00:02:16,878
me because i have the
58
00:02:14,520 --> 00:02:19,200
cmakepresets.json file at the root of my
59
00:02:16,878 --> 00:02:21,439
open folder but if i didn't have that
60
00:02:19,199 --> 00:02:24,878
file then i could enable the integration
61
00:02:21,439 --> 00:02:27,919
by going to tools options cmake checking
62
00:02:24,878 --> 00:02:30,079
prefer using cmg presets for configure
63
00:02:27,919 --> 00:02:33,280
build and test and then closing and
64
00:02:30,080 --> 00:02:35,200
reopening the folder in visual studio
65
00:02:33,280 --> 00:02:37,519
cmg presets is the recommended
66
00:02:35,199 --> 00:02:39,439
alternative to cmake settings and will
67
00:02:37,519 --> 00:02:43,280
be the default configuration method in
68
00:02:39,439 --> 00:02:45,759
future releases of visual studio 2022
69
00:02:43,280 --> 00:02:48,560
so you might realize across the menu bar
70
00:02:45,759 --> 00:02:50,560
that i now have three drop downs the
71
00:02:48,560 --> 00:02:53,280
drop down on the left is my active
72
00:02:50,560 --> 00:02:55,519
target system so because cmake is cross
73
00:02:53,280 --> 00:02:57,759
platform i can build and debug this
74
00:02:55,519 --> 00:03:00,879
project on my local machine
75
00:02:57,759 --> 00:03:03,519
on any number of wsl distros that visual
76
00:03:00,878 --> 00:03:05,919
studio will automatically pick up on or
77
00:03:03,519 --> 00:03:08,800
on ssh connections and these can be
78
00:03:05,919 --> 00:03:10,639
connections to servers desktop it
79
00:03:08,800 --> 00:03:12,800
doesn't matter and i can target all
80
00:03:10,639 --> 00:03:14,878
these systems from the same instance of
81
00:03:12,800 --> 00:03:16,959
visual studio
82
00:03:14,878 --> 00:03:19,359
the drop down in the middle is my active
83
00:03:16,959 --> 00:03:21,598
configure preset which drives cmake
84
00:03:19,360 --> 00:03:23,519
cache generation and corresponds to the
85
00:03:21,598 --> 00:03:24,479
siemens configure step from the command
86
00:03:23,519 --> 00:03:26,400
line
87
00:03:24,479 --> 00:03:29,039
and the drop down on the right is my
88
00:03:26,400 --> 00:03:31,360
active build preset which drives c make
89
00:03:29,039 --> 00:03:33,840
builds and corresponds to the cmake
90
00:03:31,360 --> 00:03:37,280
build step from the command line and i
91
00:03:33,840 --> 00:03:40,000
can select manage build presets to open
92
00:03:37,280 --> 00:03:41,519
up my cmakepresets.json file and take a
93
00:03:40,000 --> 00:03:43,919
closer look
94
00:03:41,519 --> 00:03:46,480
in this file i can define any number of
95
00:03:43,919 --> 00:03:48,719
configure presets build presets or test
96
00:03:46,479 --> 00:03:50,560
presets which encode the information
97
00:03:48,719 --> 00:03:52,878
that i would normally pass to cmake from
98
00:03:50,560 --> 00:03:55,680
the command line so in my configure
99
00:03:52,878 --> 00:03:57,840
preset that's things like my generator
100
00:03:55,680 --> 00:04:00,080
and my build directory
101
00:03:57,840 --> 00:04:02,000
i've already set up my presets file so i
102
00:04:00,080 --> 00:04:04,640
can go ahead and kick off cache
103
00:04:02,000 --> 00:04:06,000
generation on windows
104
00:04:04,639 --> 00:04:07,839
for lots more information on
105
00:04:06,000 --> 00:04:10,479
cmakepresets.json
106
00:04:07,840 --> 00:04:11,560
as well as its companion user level file
107
00:04:10,479 --> 00:04:14,318
cmake
108
00:04:11,560 --> 00:04:18,079
userpresets.json you can check out aka
109
00:04:14,318 --> 00:04:20,238
dot ms slash c make presets vs
110
00:04:18,079 --> 00:04:22,160
all right so it looks like cash
111
00:04:20,238 --> 00:04:24,478
generation has finished but it was
112
00:04:22,160 --> 00:04:25,759
unsuccessful because i'm missing a
113
00:04:24,478 --> 00:04:29,519
dependency
114
00:04:25,759 --> 00:04:31,680
cma cannot find glad so as a c-plus plus
115
00:04:29,519 --> 00:04:33,680
developer you might be used to copying
116
00:04:31,680 --> 00:04:36,000
and pasting dependencies around and
117
00:04:33,680 --> 00:04:38,478
resolving any transitive dependencies by
118
00:04:36,000 --> 00:04:40,959
hand or you might be used to platform
119
00:04:38,478 --> 00:04:43,439
specific solutions like a system package
120
00:04:40,959 --> 00:04:46,079
manager and to help mitigate this i'm
121
00:04:43,439 --> 00:04:48,240
using vc package which is an open source
122
00:04:46,079 --> 00:04:52,399
cross platform dependency management
123
00:04:48,240 --> 00:04:55,280
tool for c and c plus so because one i
124
00:04:52,399 --> 00:04:57,359
have this vc package.json file adjacent
125
00:04:55,279 --> 00:04:59,918
to my root c make lists
126
00:04:57,360 --> 00:05:01,919
and two i'm passing the vc package tool
127
00:04:59,918 --> 00:05:04,159
chain file to cmake
128
00:05:01,918 --> 00:05:06,319
then when i configure this project vc
129
00:05:04,160 --> 00:05:08,639
package will automatically bring down
130
00:05:06,319 --> 00:05:11,680
and build all of the dependencies that
131
00:05:08,639 --> 00:05:14,160
i've listed here from source or download
132
00:05:11,680 --> 00:05:16,160
them if i'm using binary caching and
133
00:05:14,160 --> 00:05:18,639
install them in a subdirectory of this
134
00:05:16,160 --> 00:05:20,240
project's output directory so the only
135
00:05:18,639 --> 00:05:23,680
thing that i need to do to add this
136
00:05:20,240 --> 00:05:24,800
missing dependency is add glad to this
137
00:05:23,680 --> 00:05:28,319
list
138
00:05:24,800 --> 00:05:30,560
and reconfigure the cache
139
00:05:28,319 --> 00:05:32,399
none of this is visual studio specific
140
00:05:30,560 --> 00:05:34,560
it all reproduced from the command line
141
00:05:32,399 --> 00:05:36,478
if you're using cmake and vc package
142
00:05:34,560 --> 00:05:39,439
which i'll take a closer look at in just
143
00:05:36,478 --> 00:05:42,319
a few minutes for more information on vc
144
00:05:39,439 --> 00:05:45,038
package you can check out aka dot ms
145
00:05:42,319 --> 00:05:46,800
slash vc package
146
00:05:45,038 --> 00:05:49,360
all right so it looks like steemit
147
00:05:46,800 --> 00:05:52,240
generation has finished and this time it
148
00:05:49,360 --> 00:05:54,639
was successful so as i scroll up in the
149
00:05:52,240 --> 00:05:56,720
cmake output window you can see that the
150
00:05:54,639 --> 00:05:58,319
installation of glad and its two
151
00:05:56,720 --> 00:06:00,319
dependencies took
152
00:05:58,319 --> 00:06:03,199
73 milliseconds
153
00:06:00,319 --> 00:06:06,080
to 65 milliseconds and the entire
154
00:06:03,199 --> 00:06:08,240
operation took less than five seconds
155
00:06:06,079 --> 00:06:10,800
and that's because i'm using vc package
156
00:06:08,240 --> 00:06:13,199
binary caching so the binaries that i'm
157
00:06:10,800 --> 00:06:15,360
downloading and installing locally are
158
00:06:13,199 --> 00:06:17,600
cached in github packages for other
159
00:06:15,360 --> 00:06:20,560
developers on my team to pull down on
160
00:06:17,600 --> 00:06:23,919
use on their local dev boxes and to use
161
00:06:20,560 --> 00:06:23,918
in my ci pipeline
162
00:06:24,240 --> 00:06:29,038
and before i check in these changes that
163
00:06:26,720 --> 00:06:31,520
i just made to vc package.vc
164
00:06:29,038 --> 00:06:34,478
package.json i'm going to quickly verify
165
00:06:31,519 --> 00:06:36,719
that those changes also work on linux so
166
00:06:34,478 --> 00:06:39,839
all i need to do is change my active
167
00:06:36,720 --> 00:06:43,199
target system in visual studio to a wsl
168
00:06:39,839 --> 00:06:46,239
distribution and reconfigure the cache
169
00:06:43,199 --> 00:06:48,560
and this is a really easy way to verify
170
00:06:46,240 --> 00:06:51,680
that any change that you make
171
00:06:48,560 --> 00:06:55,839
works on both windows and linux locally
172
00:06:51,680 --> 00:06:57,598
from visual studio using windows and wsl
173
00:06:55,839 --> 00:06:59,918
all right again it looks like cmake
174
00:06:57,598 --> 00:07:01,439
generation was successful so at this
175
00:06:59,918 --> 00:07:03,639
point i'm ready to check in those
176
00:07:01,439 --> 00:07:05,279
changes i made to vc package vc
177
00:07:03,639 --> 00:07:07,918
package.json
178
00:07:05,279 --> 00:07:09,279
so we added glad to our list of
179
00:07:07,918 --> 00:07:11,279
dependencies
180
00:07:09,279 --> 00:07:13,279
i will commit those changes and then
181
00:07:11,279 --> 00:07:16,239
push them to the remote
182
00:07:13,279 --> 00:07:18,318
so this project is using github actions
183
00:07:16,240 --> 00:07:20,478
and i've authored a workflow file that
184
00:07:18,319 --> 00:07:23,280
will automatically kick off a ci run on
185
00:07:20,478 --> 00:07:25,279
both windows and linux on push so that's
186
00:07:23,279 --> 00:07:26,799
getting started now and we'll come back
187
00:07:25,279 --> 00:07:29,198
and take a look at it in just a few
188
00:07:26,800 --> 00:07:29,199
minutes
189
00:07:29,279 --> 00:07:33,359
because see my generation was successful
190
00:07:31,759 --> 00:07:36,160
i can now leverage all of visual
191
00:07:33,360 --> 00:07:38,720
studio's cmake features so that's things
192
00:07:36,160 --> 00:07:40,800
like cmake targets view over here in the
193
00:07:38,720 --> 00:07:45,440
solution explorer which is a more
194
00:07:40,800 --> 00:07:47,918
cma-centric way of viewing your code
195
00:07:45,439 --> 00:07:51,279
in editor documentation for cmake which
196
00:07:47,918 --> 00:07:54,000
surfaces official cmake docs in the ide
197
00:07:51,279 --> 00:07:56,159
and language services for cmake so i can
198
00:07:54,000 --> 00:07:58,959
do things like right click and find all
199
00:07:56,160 --> 00:08:02,160
references go to definition or peak
200
00:07:58,959 --> 00:08:04,959
definition on cmake variables targets
201
00:08:02,160 --> 00:08:04,960
and functions
202
00:08:05,680 --> 00:08:09,759
as an existing visual studio customer
203
00:08:07,918 --> 00:08:11,918
you might already be familiar with the
204
00:08:09,759 --> 00:08:14,319
windows development experience so i'm
205
00:08:11,918 --> 00:08:17,038
going to continue to focus this demo on
206
00:08:14,319 --> 00:08:19,280
local development with wsl 2.
207
00:08:17,038 --> 00:08:21,519
so right now my active target system is
208
00:08:19,279 --> 00:08:23,918
a wsl 2 distro
209
00:08:21,519 --> 00:08:26,079
and when i build this project
210
00:08:23,918 --> 00:08:28,159
visual studio is actually making a copy
211
00:08:26,079 --> 00:08:30,318
of my source tree in the linux file
212
00:08:28,160 --> 00:08:33,200
system and building with native linux
213
00:08:30,319 --> 00:08:36,080
build tools like gcc or clang and the
214
00:08:33,200 --> 00:08:39,039
reason for this is that wsl 2 is a lot
215
00:08:36,080 --> 00:08:41,519
faster anywhere from 3 to 20 times
216
00:08:39,038 --> 00:08:43,679
faster when it's accessing source files
217
00:08:41,519 --> 00:08:45,839
in the linux file system rather than the
218
00:08:43,679 --> 00:08:48,319
windows file system which can lead to
219
00:08:45,839 --> 00:08:49,920
significant performance gains for you
220
00:08:48,320 --> 00:08:53,040
and this is all done using visual
221
00:08:49,919 --> 00:08:56,079
studio's native support for wsl 2 which
222
00:08:53,039 --> 00:08:58,159
is brand new in visual studio 2022 and
223
00:08:56,080 --> 00:09:01,759
will be used automatically anytime that
224
00:08:58,159 --> 00:09:03,439
you're targeting a wsl2 distribution
225
00:09:01,759 --> 00:09:05,679
when i start debugging i'll have the
226
00:09:03,440 --> 00:09:08,959
full suite of visual studio debugging
227
00:09:05,679 --> 00:09:10,639
features available to me backed by gdb
228
00:09:08,958 --> 00:09:12,399
and to help illustrate this i'm going to
229
00:09:10,639 --> 00:09:14,639
walk through a bug that i encountered
230
00:09:12,399 --> 00:09:16,399
when i was prepping for this demo
231
00:09:14,639 --> 00:09:18,639
so if you take a look at the solution
232
00:09:16,399 --> 00:09:21,360
explorer over to the right you can see
233
00:09:18,639 --> 00:09:23,919
that this project contains four targets
234
00:09:21,360 --> 00:09:26,000
including a physics library and a
235
00:09:23,919 --> 00:09:28,479
samples executable
236
00:09:26,000 --> 00:09:30,080
so i had samples running as a nice
237
00:09:28,480 --> 00:09:32,080
visual demo
238
00:09:30,080 --> 00:09:34,800
but when i went to run the project for a
239
00:09:32,080 --> 00:09:37,360
second time it behaved just like that
240
00:09:34,799 --> 00:09:39,838
and exit as soon as it was launched so
241
00:09:37,360 --> 00:09:41,519
it was time to start debugging
242
00:09:39,839 --> 00:09:44,640
the first thing that i did was look for
243
00:09:41,519 --> 00:09:46,720
the program's main function or the entry
244
00:09:44,639 --> 00:09:48,639
point to the program and as i was
245
00:09:46,720 --> 00:09:50,639
scrolling through main i got to this
246
00:09:48,639 --> 00:09:52,879
update loop that handles all of the
247
00:09:50,639 --> 00:09:54,799
input and rendering and the condition
248
00:09:52,879 --> 00:09:57,360
that is checked before this loop is
249
00:09:54,799 --> 00:09:59,439
executed is the return value of this
250
00:09:57,360 --> 00:10:02,079
window should close function which
251
00:09:59,440 --> 00:10:03,839
checks the close flag of the main window
252
00:10:02,078 --> 00:10:05,519
and because i'm seeing that main window
253
00:10:03,839 --> 00:10:07,279
closed on me i thought this would be a
254
00:10:05,519 --> 00:10:09,919
good place to set a break point and see
255
00:10:07,278 --> 00:10:11,278
what was happening so i'll set a break
256
00:10:09,919 --> 00:10:15,599
point
257
00:10:11,278 --> 00:10:15,600
press f5 to relaunch the debugger
258
00:10:15,839 --> 00:10:23,040
and now i can press f11 to step into
259
00:10:18,958 --> 00:10:24,879
this window should close function
260
00:10:23,039 --> 00:10:27,278
and this function is just checking if
261
00:10:24,879 --> 00:10:28,240
this window should close flag has been
262
00:10:27,278 --> 00:10:30,480
set
263
00:10:28,240 --> 00:10:32,799
so i can run the cursor down to this
264
00:10:30,480 --> 00:10:35,120
return statement and it looks like right
265
00:10:32,799 --> 00:10:37,759
now the value of windows should close is
266
00:10:35,120 --> 00:10:40,159
zero or false meaning this window should
267
00:10:37,759 --> 00:10:42,319
not close but because i am seeing that
268
00:10:40,159 --> 00:10:44,559
main window close on me i'm going to set
269
00:10:42,320 --> 00:10:47,440
a new data break point that will hit if
270
00:10:44,559 --> 00:10:50,639
the value of window should close changes
271
00:10:47,440 --> 00:10:53,120
so i'll go over to breakpoints add a new
272
00:10:50,639 --> 00:10:54,240
data break point for the address of
273
00:10:53,120 --> 00:10:55,919
window
274
00:10:54,240 --> 00:10:57,759
should close
275
00:10:55,919 --> 00:10:59,439
what's cool here is that i don't need to
276
00:10:57,759 --> 00:11:01,039
look at memory at all i can just
277
00:10:59,440 --> 00:11:02,480
reference the name of the variable
278
00:11:01,039 --> 00:11:03,919
directly
279
00:11:02,480 --> 00:11:06,240
press ok
280
00:11:03,919 --> 00:11:07,759
shift f11 to step out of this function
281
00:11:06,240 --> 00:11:11,200
back into main
282
00:11:07,759 --> 00:11:13,759
f5 to continue execution and sure enough
283
00:11:11,200 --> 00:11:16,640
our data breakpoint was hit so the value
284
00:11:13,759 --> 00:11:19,519
of window should close is now one or
285
00:11:16,639 --> 00:11:21,439
true this window should close
286
00:11:19,519 --> 00:11:23,600
so i wanted to take a look at the call
287
00:11:21,440 --> 00:11:24,800
stack to see what was calling this
288
00:11:23,600 --> 00:11:27,120
function
289
00:11:24,799 --> 00:11:28,719
so i can see that the program is
290
00:11:27,120 --> 00:11:31,519
polling for events
291
00:11:28,720 --> 00:11:33,519
processing events and in this case that
292
00:11:31,519 --> 00:11:35,919
event is a keyboard event and
293
00:11:33,519 --> 00:11:38,078
specifically the escape key so this
294
00:11:35,919 --> 00:11:39,679
program is behaving as if i had pressed
295
00:11:38,078 --> 00:11:41,519
the escape key
296
00:11:39,679 --> 00:11:43,278
to fast forward a little bit i did a bit
297
00:11:41,519 --> 00:11:45,519
more debugging and found out that the
298
00:11:43,278 --> 00:11:47,759
program was always remembering the last
299
00:11:45,519 --> 00:11:49,919
event from the previous session
300
00:11:47,759 --> 00:11:52,240
so the first thing i tried to do was
301
00:11:49,919 --> 00:11:54,559
process that stale event before this
302
00:11:52,240 --> 00:11:57,200
keyboard event handler was set up and
303
00:11:54,559 --> 00:11:59,518
that did not work but when i set a break
304
00:11:57,200 --> 00:12:01,759
point at that location to debug and take
305
00:11:59,519 --> 00:12:04,159
a look at what was happening the program
306
00:12:01,759 --> 00:12:06,000
did behave as expected which led me to
307
00:12:04,159 --> 00:12:08,319
believe it might be some sort of timing
308
00:12:06,000 --> 00:12:10,399
issue and perhaps that stale event was
309
00:12:08,320 --> 00:12:11,440
coming in just after the start of the
310
00:12:10,399 --> 00:12:13,839
program
311
00:12:11,440 --> 00:12:16,800
so what i ended up doing was adding just
312
00:12:13,839 --> 00:12:19,600
a half second sleep before processing
313
00:12:16,799 --> 00:12:21,199
that stale event so i'll uncomment out
314
00:12:19,600 --> 00:12:24,879
my solution
315
00:12:21,200 --> 00:12:26,800
remove the break points that i had set
316
00:12:24,879 --> 00:12:30,240
stop debugging
317
00:12:26,799 --> 00:12:33,039
and then relaunch by pressing f5 and
318
00:12:30,240 --> 00:12:35,360
this time instead of exiting immediately
319
00:12:33,039 --> 00:12:38,799
we'll be able to interact with samples
320
00:12:35,360 --> 00:12:41,039
and play with all of our physics demos
321
00:12:38,799 --> 00:12:41,838
now what we see here is actually pretty
322
00:12:41,039 --> 00:12:44,879
cool
323
00:12:41,839 --> 00:12:48,240
so this is a linux application running
324
00:12:44,879 --> 00:12:50,958
natively on windows with wslg the g
325
00:12:48,240 --> 00:12:53,120
stands for graphics and windows 11 and
326
00:12:50,958 --> 00:12:55,039
you might notice the linux space tiling
327
00:12:53,120 --> 00:12:56,720
up here in the corner which indicates
328
00:12:55,039 --> 00:12:58,958
that we are indeed running this in a
329
00:12:56,720 --> 00:13:01,440
native linux instance
330
00:12:58,958 --> 00:13:04,319
when i was debugging i had the full
331
00:13:01,440 --> 00:13:06,800
visual studio experience backed by gdb
332
00:13:04,320 --> 00:13:08,480
which shows that graphical expression
333
00:13:06,799 --> 00:13:10,000
that you just can't really get when
334
00:13:08,480 --> 00:13:11,759
you're debugging with gdb from the
335
00:13:10,000 --> 00:13:13,360
command line
336
00:13:11,759 --> 00:13:15,679
another thing i want to underscore is
337
00:13:13,360 --> 00:13:18,560
that nothing that i've done so far locks
338
00:13:15,679 --> 00:13:21,759
you into visual studio so i'm building
339
00:13:18,559 --> 00:13:24,319
with cmake vc package and gcc i'm
340
00:13:21,759 --> 00:13:26,480
debugging with gdb so there's nothing
341
00:13:24,320 --> 00:13:28,320
visual studio specific and this is a
342
00:13:26,480 --> 00:13:31,440
great option for teams who like to
343
00:13:28,320 --> 00:13:33,600
maintain a diverse set of tools
344
00:13:31,440 --> 00:13:35,279
and to take a closer look at that i'm
345
00:13:33,600 --> 00:13:37,120
going to hop on over to that github
346
00:13:35,278 --> 00:13:39,759
actions run where we reproduced our
347
00:13:37,120 --> 00:13:40,959
builds using the same tools in our ci
348
00:13:39,759 --> 00:13:43,759
pipeline
349
00:13:40,958 --> 00:13:45,838
so here's github actions here's my most
350
00:13:43,759 --> 00:13:47,679
recent run that was started six minutes
351
00:13:45,839 --> 00:13:50,000
ago
352
00:13:47,679 --> 00:13:52,319
it was successful on both windows and
353
00:13:50,000 --> 00:13:53,759
linux and if i take a closer look at
354
00:13:52,320 --> 00:13:56,560
that linux run
355
00:13:53,759 --> 00:13:59,000
the thing that i really want to show you
356
00:13:56,559 --> 00:14:01,439
is that i'm using the exact same cmg
357
00:13:59,000 --> 00:14:03,440
presets.json file to drive cmake
358
00:14:01,440 --> 00:14:06,079
generation and build that i was using
359
00:14:03,440 --> 00:14:08,240
locally so here i'm passing in the name
360
00:14:06,078 --> 00:14:10,879
of my configure preset and build preset
361
00:14:08,240 --> 00:14:12,639
to cmake which really ensures that your
362
00:14:10,879 --> 00:14:14,799
team can maintain that single source of
363
00:14:12,639 --> 00:14:16,959
truth that you can use to drive builds
364
00:14:14,799 --> 00:14:19,278
both locally from the ide like visual
365
00:14:16,958 --> 00:14:21,518
studio from the command line or from
366
00:14:19,278 --> 00:14:23,679
your ci pipeline
367
00:14:21,519 --> 00:14:25,679
in the same vein vc package is
368
00:14:23,679 --> 00:14:28,239
downloading and installing the exact
369
00:14:25,679 --> 00:14:30,319
same binaries that i was using in visual
370
00:14:28,240 --> 00:14:34,480
studio for local development when i was
371
00:14:30,320 --> 00:14:36,800
targeting both windows and wsl
372
00:14:34,480 --> 00:14:39,039
finally if you're not using cmake then
373
00:14:36,799 --> 00:14:41,439
visual studio has remote debugging tools
374
00:14:39,039 --> 00:14:44,319
that you can use to debug on both linux
375
00:14:41,440 --> 00:14:47,360
and mac so brand new in visual studio
376
00:14:44,320 --> 00:14:49,600
2022 is the ability to attach to a
377
00:14:47,360 --> 00:14:52,800
remote process and debug it with the
378
00:14:49,600 --> 00:14:54,959
lldb debugger from visual studio
379
00:14:52,799 --> 00:14:57,120
this feature is supported on both linux
380
00:14:54,958 --> 00:14:59,759
and mac but for the sake of the demo my
381
00:14:57,120 --> 00:15:01,600
process will be running on wsl
382
00:14:59,759 --> 00:15:04,639
so as i mentioned earlier with visual
383
00:15:01,600 --> 00:15:06,800
studio support for wsl 2 visual studio
384
00:15:04,639 --> 00:15:10,240
maintains a copy of your build sheet in
385
00:15:06,799 --> 00:15:12,958
the linux file system so over in ubuntu
386
00:15:10,240 --> 00:15:16,399
you can see that i'm working on wsl now
387
00:15:12,958 --> 00:15:19,679
this is the ubuntu 2004 distro i've
388
00:15:16,399 --> 00:15:23,919
navigated into that build directory
389
00:15:19,679 --> 00:15:23,919
i'm going to start ssh
390
00:15:25,679 --> 00:15:30,559
and launch samples
391
00:15:28,078 --> 00:15:32,399
so this is the exact same binary that we
392
00:15:30,559 --> 00:15:35,439
are building and debugging from visual
393
00:15:32,399 --> 00:15:37,679
studio just a few minutes ago
394
00:15:35,440 --> 00:15:39,120
back in vs you can use the same attached
395
00:15:37,679 --> 00:15:41,599
workflow that you might already be
396
00:15:39,120 --> 00:15:45,039
familiar with so debug attached to
397
00:15:41,600 --> 00:15:47,440
process we want connection type ssh
398
00:15:45,039 --> 00:15:49,198
the connection target is erica at
399
00:15:47,440 --> 00:15:51,120
localhost
400
00:15:49,198 --> 00:15:53,039
because i haven't added this connection
401
00:15:51,120 --> 00:15:56,560
to the connection manager
402
00:15:53,039 --> 00:15:58,958
i am being prompted to authenticate
403
00:15:56,559 --> 00:16:00,958
and then trust the authenticity of the
404
00:15:58,958 --> 00:16:02,559
connection
405
00:16:00,958 --> 00:16:04,319
and once it's done connecting then
406
00:16:02,559 --> 00:16:06,399
visual studio will prompt me with the
407
00:16:04,320 --> 00:16:09,839
list of all the processes that are
408
00:16:06,399 --> 00:16:12,000
running on that wsl distro so i want to
409
00:16:09,839 --> 00:16:13,839
attach to samples
410
00:16:12,000 --> 00:16:16,078
the last thing i need to do is say
411
00:16:13,839 --> 00:16:20,000
whether i'll be debugging with gdb or
412
00:16:16,078 --> 00:16:23,039
lldb so again support for lldb is brand
413
00:16:20,000 --> 00:16:24,958
new in visual studio 2022 but i could
414
00:16:23,039 --> 00:16:27,198
follow this exact same workflow with the
415
00:16:24,958 --> 00:16:29,359
gdb debugger
416
00:16:27,198 --> 00:16:32,000
so i will select that and then when i
417
00:16:29,360 --> 00:16:34,959
hit ok visual studio will attach to that
418
00:16:32,000 --> 00:16:36,639
process with the lldb debugger and when
419
00:16:34,958 --> 00:16:39,439
i press pause
420
00:16:36,639 --> 00:16:42,560
i will see the current line of execution
421
00:16:39,440 --> 00:16:45,199
as well as my variables the call stack
422
00:16:42,559 --> 00:16:47,119
and i'm ready to start debugging
423
00:16:45,198 --> 00:16:49,359
one thing that i want to emphasize about
424
00:16:47,120 --> 00:16:51,278
this workflow is that it doesn't matter
425
00:16:49,360 --> 00:16:53,519
how you build the binary that you're
426
00:16:51,278 --> 00:16:55,120
attaching to from visual studio so you
427
00:16:53,519 --> 00:16:58,879
can be building with a custom build
428
00:16:55,120 --> 00:17:01,198
script with make with xcode with cmake
429
00:16:58,879 --> 00:17:03,439
it does not matter you can still attach
430
00:17:01,198 --> 00:17:05,838
to it and debug it using the front end
431
00:17:03,440 --> 00:17:08,480
of the visual studio debugger backed by
432
00:17:05,838 --> 00:17:11,279
either gdb or lldb
433
00:17:08,480 --> 00:17:13,759
for example the office team at microsoft
434
00:17:11,279 --> 00:17:15,759
primarily uses windows and visual studio
435
00:17:13,759 --> 00:17:18,000
for their local development and they're
436
00:17:15,759 --> 00:17:20,078
excited to use this feature to remote
437
00:17:18,000 --> 00:17:22,240
debug mac failures
438
00:17:20,078 --> 00:17:23,918
previously they might sift through log
439
00:17:22,240 --> 00:17:26,400
files to try and understand what's
440
00:17:23,919 --> 00:17:28,480
happening or for a particularly bad
441
00:17:26,400 --> 00:17:30,960
issue they might spin up a mac machine
442
00:17:28,480 --> 00:17:33,360
for native debugging which is both time
443
00:17:30,960 --> 00:17:34,880
consuming and a less familiar debugging
444
00:17:33,359 --> 00:17:36,879
experience
445
00:17:34,880 --> 00:17:38,640
for more on information on this workflow
446
00:17:36,880 --> 00:17:42,640
including how to get started with the
447
00:17:38,640 --> 00:17:45,679
lldb debugger you can check out aka.ms
448
00:17:42,640 --> 00:17:47,919
lldb and for more information on other
449
00:17:45,679 --> 00:17:50,320
build system agnostic remote debugging
450
00:17:47,919 --> 00:17:52,559
workflows like debugging a linux core
451
00:17:50,319 --> 00:17:56,000
dump from visual studio you can check
452
00:17:52,558 --> 00:17:58,639
out our c plus plus team blog at aka dot
453
00:17:56,000 --> 00:18:00,480
msl cpp blog
454
00:17:58,640 --> 00:18:02,400
that pretty much wraps up all the new
455
00:18:00,480 --> 00:18:05,038
features that i wanted to show you today
456
00:18:02,400 --> 00:18:08,000
to quickly recap what we covered we used
457
00:18:05,038 --> 00:18:10,640
cmig presets and vc package to build a
458
00:18:08,000 --> 00:18:13,119
cmg project both with and without visual
459
00:18:10,640 --> 00:18:16,240
studio so our local builds targeting
460
00:18:13,119 --> 00:18:18,558
both windows and wsl can be reproduced
461
00:18:16,240 --> 00:18:20,960
in a ci pipeline or from the command
462
00:18:18,558 --> 00:18:22,000
line as we saw with our github actions
463
00:18:20,960 --> 00:18:24,400
workflow
464
00:18:22,000 --> 00:18:26,640
this can help your team ensure that you
465
00:18:24,400 --> 00:18:28,960
maintain that single source of truth and
466
00:18:26,640 --> 00:18:30,240
that you're not locked into any specific
467
00:18:28,960 --> 00:18:32,319
tools
468
00:18:30,240 --> 00:18:35,120
we also showed how the local visual
469
00:18:32,319 --> 00:18:37,599
studio studio development experience now
470
00:18:35,119 --> 00:18:40,159
applies to linux with visual studio's
471
00:18:37,599 --> 00:18:42,959
native support for wsl 2.
472
00:18:40,160 --> 00:18:45,360
it is just as easy to build and debug a
473
00:18:42,960 --> 00:18:47,679
linux gui application locally from
474
00:18:45,359 --> 00:18:49,439
visual studio as it is to build and
475
00:18:47,679 --> 00:18:51,280
debug for windows
476
00:18:49,440 --> 00:18:53,679
and finally no matter how you're
477
00:18:51,279 --> 00:18:56,079
building your cross-platform application
478
00:18:53,679 --> 00:18:58,798
visual studio offers the best debugging
479
00:18:56,079 --> 00:19:01,678
experience for debugging with gdb or
480
00:18:58,798 --> 00:19:03,679
lldb which can save a ton of time
481
00:19:01,679 --> 00:19:05,360
compared to using those same tools from
482
00:19:03,679 --> 00:19:07,360
the command line
483
00:19:05,359 --> 00:19:09,199
to get in contact with our team or to
484
00:19:07,359 --> 00:19:11,359
stay up to date with what's new for
485
00:19:09,200 --> 00:19:13,440
cross-platform developers you can check
486
00:19:11,359 --> 00:19:17,000
out our team blog which again can be
487
00:19:13,440 --> 00:19:17,000
reached at aka.ms.cppblog
488
00:19:17,440 --> 00:19:20,558
thanks for tuning in
35792
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.