From 8c643361eeba94b7b831ad95b70969d962034345 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Mon, 27 Aug 2018 16:39:43 -0500 Subject: qapi: Add comments to aid debugging generated introspection We consciously chose in commit 1a9a507b to hide QAPI type names from the introspection output on the wire, but added a command line option -u to unmask the type name when doing a debug build. The unmask option still remains useful to some other forms of automated analysis, so it will not be removed; however, when it is not in use, the generated .c file can be hard to read. At the time when we first introduced masking, the generated file consisted only of a monolithic C string, so there was no clean way to inject any comments. Later, in commit 7d0f982b, we switched the generation to output a QLit object, in part to make it easier for future addition of conditional compilation. In fact, commit d626b6c1 took advantage of this by passing a tuple instead of a bare object for encoding the output of conditionals. By extending that tuple, we can now interject strategic comments. For now, type name debug aid comments are only output once per meta-type, rather than at all uses of the number used to encode the type within the introspection data. But this is still a lot more convenient than having to regenerate the file with the unmask operation temporarily turned on - merely search the generated file for '"NNN" =' to learn the corresponding source name and associated definition of type NNN. The generated qapi-introspect.c changes only with the addition of comments, such as: | @@ -14755,6 +15240,7 @@ | { "name", QLIT_QSTR("[485]"), }, | {} | })), | + /* "485" = QCryptoBlockInfoLUKSSlot */ | QLIT_QDICT(((QLitDictEntry[]) { | { "members", QLIT_QLIST(((QLitObject[]) { | QLIT_QDICT(((QLitDictEntry[]) { Signed-off-by: Eric Blake Message-Id: <20180827213943.33524-3-eblake@redhat.com> Reviewed-by: Markus Armbruster [Rebased, update to qapi-code-gen.txt corrected] Signed-off-by: Markus Armbruster --- docs/devel/qapi-code-gen.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'docs') diff --git a/docs/devel/qapi-code-gen.txt b/docs/devel/qapi-code-gen.txt index 304c12d0ae..53eaf01f34 100644 --- a/docs/devel/qapi-code-gen.txt +++ b/docs/devel/qapi-code-gen.txt @@ -1428,6 +1428,7 @@ Example: { "name", QLIT_QSTR("MY_EVENT"), }, {} })), + /* "0" = q_obj_my-command-arg */ QLIT_QDICT(((QLitDictEntry[]) { { "members", QLIT_QLIST(((QLitObject[]) { QLIT_QDICT(((QLitDictEntry[]) { @@ -1441,6 +1442,7 @@ Example: { "name", QLIT_QSTR("0"), }, {} })), + /* "1" = UserDefOne */ QLIT_QDICT(((QLitDictEntry[]) { { "members", QLIT_QLIST(((QLitObject[]) { QLIT_QDICT(((QLitDictEntry[]) { @@ -1460,6 +1462,7 @@ Example: { "name", QLIT_QSTR("1"), }, {} })), + /* "2" = q_empty */ QLIT_QDICT(((QLitDictEntry[]) { { "members", QLIT_QLIST(((QLitObject[]) { {} -- cgit v1.2.3