Skip to content

Explore structure with member offsets #13544

Closed as duplicate
Closed as duplicate

Description

@White-Owl

Feature Request

I'd like to have a command (probably in a Peek menu) which would open a window for a struct and show offsets of all struct members. Something similar to gdb's ptype /o command.

For example, for a code like:

typedef struct {
   char a;
   int b;
   char c[5];
} s1_t;

typedef struct __attribute__((packed)) {
   char a;
   int b;
   char c[5];
} s2_t;

int main() {
   s1_t s1;
   s2_t s2;
   return 0;
}

We can see offsets in gdb:

(gdb) ptype /o s1_t
type = struct {
/*      0      |       1 */    char a;
/* XXX  3-byte hole      */
/*      4      |       4 */    int b;
/*      8      |       5 */    char c[5];
/* XXX  3-byte padding   */

                               /* total size (bytes):   16 */
                             }
(gdb) ptype /o s2_t
type = struct {
/*      0      |       1 */    char a;
/*      1      |       4 */    int b;
/*      5      |       5 */    char c[5];

                               /* total size (bytes):   10 */
                             }
(gdb)

I would love to have something similar, but without compiling and running gdb

Activity

  1. sean-mcmanus commented on Apr 23, 2025

    @sean-mcmanus
    Contributor

    White-Owl You're requesting an IntelliSense language server feature, right?

    This is available in VS 2022, and we're tracking potentially adding something similar for VS Code at #13034 .

    Image

    Image

  2. locked and limited conversation to collaborators on Jun 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions