Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在LLDB中打印可以在C代码中使用的结构_C_Lldb - Fatal编程技术网

如何在LLDB中打印可以在C代码中使用的结构

如何在LLDB中打印可以在C代码中使用的结构,c,lldb,C,Lldb,我希望打印一个结构,然后能够将输出复制/粘贴到我的一些代码中,以设置单元测试 例如 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"} }; print a FOO a = {.array = {1

我希望打印一个结构,然后能够将输出复制/粘贴到我的一些代码中,以设置单元测试

例如

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"}
};
print a
    FOO a = {.array = {1,2,3,4,5},
    .string = "TEST",
    .stringBuff = {"test"}
};
然后在LLDB中得到

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"}
};
print a
    FOO a = {.array = {1,2,3,4,5},
    .string = "TEST",
    .stringBuff = {"test"}
};

您已经看到了吗:?我看到了,不知道如何更改格式以便A.每个字段后面都有一个逗号。B.数组删除索引。结构和数组在其初始化器周围使用{}。D.字段名前面有句号。您可以在Python中实现类型摘要,在这一点上,您可以从所有结构子项中获取所有值,并按照您的意愿对其进行格式化。但是,在这一点上,我不会将其作为摘要来做,因为摘要假定在一行上,等等。。。我会制作一个python命令“format_variable”或类似的东西,然后在那里完成这项工作。