4

According to the answers on this stackoverflow post, in Visual Studio, the debugger watch window can show multiple values of an array by using this syntax: arrName,20.

Is there a similar way to easily show multiple values from a pointer and the following memory addresses in the Visual Studio Code debugger?

As an example, here is the struct I'm working with:

struct student *students = malloc(NUM_STUDENTS * sizeof *students);

I can show individual values using students[idx], but trying to use the given Visual Studio syntax doesn't work.

enter image description here

Nathan Perkins
  • 131
  • 3
  • 7

2 Answers2

3

you can use *some_pointer@3 in vs code monitor to show the value that pointer pointed.

Changyuan Chen
  • 308
  • 1
  • 3
  • 10
2

Looks like you are asking the Visual Studio -> lldb version of this gdb -> lldb question:

View array in LLDB: equivalent of GDB's '@' operator in Xcode 4.1

There are a bunch of "by hand" answers in that question, which were necessary at the time the question was asked, but for the past couple of years lldb has had built-in functionality for this (which is given in one of the answers):

(lldb) parray 20 <Expression resulting in a pointer to your array>
Jim Ingham
  • 25,260
  • 2
  • 55
  • 63
  • 1
    I don't see how this answers the question. First of all there's a type (should be `parray` rather than `parry`). Second, you can use this command in the Debug Console tab of VS Code (when the debugger is lldb, evidently), but this doesn't help with watching an array in the watch window. – swineone Oct 18 '20 at 01:12