0

I would like to print a struct and then be able to copy/ paste the output into some of my code for setting up unit tests.

ie something like

typedef struct FOO{
   int array[5];
   const char * string;
   char stringBuff[5];
} FOO;

FOO a = {.array = {1,2,3,4,5},
    .string = "TEST",
    .stringBuff = {"test"}
};

then in LLDB get something like

print a
    FOO a = {.array = {1,2,3,4,5},
    .string = "TEST",
    .stringBuff = {"test"}
};
Sam P
  • 681
  • 5
  • 19
  • Did you already see this: [Type Summary](https://lldb.llvm.org/use/variable.html#type-summary)? – Scheff's Cat Feb 06 '20 at 18:02
  • I did, not sure how to change the format so that A. Each field gets a comma after it. B. Arrays drop the indexes. C. Structures, and arrays use {} around their initalizer. D. field names get period in front of them. – Sam P Feb 06 '20 at 18:54
  • You can implement a type summary in Python, at which point you can get all the values from all the struct children and format them however you want. – Jim Ingham Feb 06 '20 at 19:27
  • I wouldn't do it as a summary at that point, however, since summaries are suppose to be on one line, etc... I'd make a python command "format_variable" or something like that, and do the job there. – Jim Ingham Feb 06 '20 at 21:01

0 Answers0