xref: /llvm-project/lldb/test/API/functionalities/data-formatter/embedded-summary/main.c (revision f22cff7675f7f64aa52204f4426f5047cc75fbb9)
1*f22cff76SAdrian Prantl void puts(const char *);
2*f22cff76SAdrian Prantl 
3*f22cff76SAdrian Prantl #define LLDBSUMMARY __attribute__((section("__TEXT,__lldbsummaries"), used))
41a650fdeSDave Lee 
51a650fdeSDave Lee struct Player {
61a650fdeSDave Lee   char *name;
71a650fdeSDave Lee   int number;
81a650fdeSDave Lee };
91a650fdeSDave Lee 
10*f22cff76SAdrian Prantl LLDBSUMMARY unsigned char _Player_type_summary[] =
11*f22cff76SAdrian Prantl     "\x01"                         // version
121a650fdeSDave Lee     "\x25"                         // record size
131a650fdeSDave Lee     "\x07"                         // type name size
141a650fdeSDave Lee     "Player\0"                     // type name
151a650fdeSDave Lee     "\x1c"                         // summary string size
161a650fdeSDave Lee     "${var.name} (${var.number})"; // summary string
171a650fdeSDave Lee 
18*f22cff76SAdrian Prantl struct Layer {
19*f22cff76SAdrian Prantl   char *name;
20*f22cff76SAdrian Prantl   int number;
21*f22cff76SAdrian Prantl };
22*f22cff76SAdrian Prantl 
23*f22cff76SAdrian Prantl LLDBSUMMARY unsigned char _padding[] = "\x00\x00";
24*f22cff76SAdrian Prantl 
25*f22cff76SAdrian Prantl // Near copy of the record for `Player`, using a regex type name (`^Layer`).
26*f22cff76SAdrian Prantl LLDBSUMMARY unsigned char _Layer_type_summary[] =
27*f22cff76SAdrian Prantl     "\x01"                         // version
28*f22cff76SAdrian Prantl     "\x25"                         // record size
29*f22cff76SAdrian Prantl     "\x07"                         // type name size
30*f22cff76SAdrian Prantl     "^Layer\0"                     // type name
31*f22cff76SAdrian Prantl     "\x1c"                         // summary string size
32*f22cff76SAdrian Prantl     "${var.name} (${var.number})"; // summary string
33*f22cff76SAdrian Prantl 
341a650fdeSDave Lee int main() {
351a650fdeSDave Lee   struct Player player;
361a650fdeSDave Lee   player.name = "Dirk";
371a650fdeSDave Lee   player.number = 41;
38*f22cff76SAdrian Prantl   struct Layer layer;
39*f22cff76SAdrian Prantl   layer.name = "crust";
40*f22cff76SAdrian Prantl   layer.number = 3;
411a650fdeSDave Lee   puts("break here");
421a650fdeSDave Lee   return 0;
431a650fdeSDave Lee }
44