-
Notifications
You must be signed in to change notification settings - Fork 274
Feature filter goto symbol table [blocks: #2649] #2680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature filter goto symbol table [blocks: #2649] #2680
Conversation
I had the need, to filter the output of the symbol table for a certain type of symbols. So, this commit adds an additional flag for goto-instrument and cbmc to filter the output of the show-symbol-table and list-symbol-table command. Further, this commit moves the commandflag defintion for show_symbol_table into its own macro. Then this new macro is included into cbmc_parse_options and goto_instrument_parse_options. The same is done for the help output. This commit keeps the --list-symbols flag for backwards compatibility, but also added --list-symbol-table with the same behavior, to align flag names with other show/list functions.
Thinking it might be better to do this by using the json-ui and filtering in a script, rather than implement a filtering mini language that will inevitably be less than complete? |
Yeah... I'm kind of with @smowton on this one... I'm not sure what value this gives above and beyond filtering things externally. |
Well as said, I just want to filter the printed symbols. CBMC already loads an internal representation of the symbols, so if I filter the internal representation before printing, I still keep all the nice output formatting and stuff existing, while I don't have to reload the transformed plaintext or JSON output into a new data model, do my filtering externally and then write formatting code for results. (Yes, I am aware that this is done with a few lines of python code, if using a JSON representation). Here is the story, I think that evolves, if I do this in external scripts: Regarding the completeness of the filter language: Apart from that, I haven't seen json-ui support for symbol tables, so I would have to write that first and that is not going to happen. It is up to you, to scope out the user experience you want to provide for CBMC. |
If I make a PR later this week for json-ui to do something sensible with the symbol table would that help? |
@mmuesly I see your issue and as someone who has written exactly the kind of scripts you're talking about (and then had to maintain them when someone changed the output!) I am sympathetic to your problem. The idea of the XML output (and later, the JSON output) was to give a low-pain, more reliable route for interfacing other tools by giving structured output and so skipping the parsing step. IMHO the text output is really for humans and at "human scale" ( @smowton @tautschnig and others may well disagree with this ). So I'm a little reluctant to support patches that do significant "text UI" work. Would having example / sample scripts in |
That sounds ideal -- proper (tm) JSON / XML / your-serialization-format-here output, and ship (and TEST / CI) some example scripts |
As long as there is the filter script somewhere shipped in the code base and still a CI test in place, I am happy to accept that instead. That said, I still don't see the value for doing this in the post ui processing, if I might filter the central data structure before converting it to a proper ui. This is not really a ui dependent functionality. I just want to cut down the data stream, that ends up in the output. It just effects the text ui right now, because there is missing ui support for other uis in this functionality in general right now. I would have build this in a cross functional ui filter otherwise following the DRY principal. That said, I still see room in this PR for code reduction and might offer to invest more time into reducing the code duplication in So stepping back from the ui output format discussion, the question might be reduced to: Do we want one filter in place filtering all uis and anyone can easily use his favorite ui, I would choose option one, but if you want to maintain option two, I am happy with that. As long as I have one out of the box working script for filtering at hand, whenever I need it, my requirements are met. |
For me the big difference is if we commit the filter that's set up for the particular needs of your workflow, then some second user comes along and says "I want a slightly different filter," then (a) we have to advise them to edit the cbmc source code to achieve that, which may be difficult if they're not a C++ programmer / are using a binary distribution / want to do something that's a pain in C++ but easy in languages oriented towards string processing, and (b) if we accept their filter too, we end up either committing a cornucopia of different rather specific filters, or implementing what amounts to a query language. It seems to me if a user can throw 5 lines of Python or a |
Thanks for the explanation. I can follow your argumentation. But there are two further points I want to make: Second, if your main concern is about different people suggesting different filters and you really see that a realistic scenario, why don't you create an api, that allows to load custom binary filter before outputting the goto program? That would be a really nice thing. |
Closing due to age (no further comment on PR content), please reopen with rebase on develop if you intent to continue this work. |
I had the desire to filter the output of a goto symbol table for some certain flags.
This simplifies the process, to determine which symbols are a good choice to pass to the memory-analyzer in #2649.
This PR allows, to use --filter-symbol-table together with --list-symbol-table or --show-symbol-table to filter the printed symbols by flags.
See the content of the
HELP_SHOW_SYMBOL_TABLE
macro for more context on allowed flags.