-
Notifications
You must be signed in to change notification settings - Fork 273
Adding initial version of goto-inspect
.
#7673
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
Conversation
How different is this to just using |
Apologies, I hadn't seen #7674, will discuss there. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## develop #7673 +/- ##
===========================================
+ Coverage 78.42% 78.55% +0.13%
===========================================
Files 1674 1689 +15
Lines 191935 192964 +1029
===========================================
+ Hits 150521 151582 +1061
+ Misses 41414 41382 -32
☔ View full report in Codecov by Sentry. |
Please take a look at #7415, which is the most recent new tool that was added and is much more complete in what it takes to add a new tool. |
Hi Michael (@tautschnig), latest commit should have everything that has been asked. Let me know if this is closer to what you envisioned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks reasonable to me, aside from a few minor issues.
src/goto-inspect/CMakeLists.txt
Outdated
install(TARGETS goto-inspect DESTINATION ${CMAKE_INSTALL_BINDIR}) | ||
|
||
# # Man page | ||
# if(NOT WIN32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch - it shouldn't be commented out.
It was in the first commit, when we didn't have a man page at first, but now we do.
CMakeLists.txt
Outdated
goto-harness | ||
goto-inspect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: duplication
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
// This just sets up the defaults (and would interpret options such as --32). | ||
config.set(cmdline); | ||
|
||
// Normally we would register language front-ends here but as goto-harness |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should "goto-harness" here be "goto-inspect"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this was a copy-paste fail.
I used the code under src/goto-harness
as the base for a lot of what you're seeing here, but it seems like I forgot to update some of the references.
Will have another look myself, just to make sure.
306ea84
to
075630b
Compare
@@ -0,0 +1,33 @@ | |||
.TH GOTO-INSPECT "2" "May 2023" "goto-inspect-5.81.0" "User Commands" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not worth pinning a date/version here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reference leads me to believe that the date is necessary in the title line.
It does look like the date we have though doesn't align with the proposed format in the reference I linked. I'm not sure how the tools behave if I leave it with an empty date, but it seems to be diverging from the expected format too much IMO.
doc/man/goto-inspect.1
Outdated
.BR goto-cc (1) | ||
.BR goto-instrument (1) | ||
.SH COPYRIGHT | ||
2023, Fotis Koutoulakis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copyright is Diffblue I believe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right - I copied and hastily changed this from a previous one, so I've made a number of mistakes.
I'm fixing now.
// Before we do anything else, positional arguments needs to be > 1. | ||
// (i.e. a filename has been given). | ||
if(cmdline.args.size() < 1) | ||
{ | ||
help(); | ||
throw invalid_command_line_argument_exceptiont{ | ||
"failed to supply a goto-binary name", | ||
"<input goto-binary> <inspection-option>"}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it should be > 2
and < 2
since we require a binary name and another option?
Maybe we also need a code path before this to response to the --help
option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it should be > 2 and < 2 since we require a binary name and another option?
Yes, changed to > 2
. With the current implementation, if just a binary is given, the behaviour is that the tool doesn't appear to do anything. It's reasonable in my opinion, but not very helpful, as it doesn't indicate to the user whether it succeeded or failed, or what.
Maybe we also need a code path before this to response to the --help option.
We don't need to do that, as it's handled already by the base class parse_options_baset::main()
, where it's checking for h
or help
before calling doit()
.
// No options was passed in - erroneously? | ||
return CPROVER_EXIT_INCORRECT_TASK; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The failure for lack of an option should be caught/reported earlier as in comment above, so this code path should perhaps be unreachable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be unreachable - I have added a lengthier comment addressing why the value is there, in order not to confuse people. Let me know if it now makes more sense.
@@ -63,7 +63,14 @@ int goto_inspect_parse_optionst::doit() | |||
return CPROVER_EXIT_SUCCESS; | |||
} | |||
|
|||
// No options was passed in - erroneously? | |||
// If an option + binary was provided, the program will have exited gracefully | |||
// through different a different branch. If we hit the code below, it means |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"different a different" -> "a different"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
2aaaac2
to
b79bfaa
Compare
May I suggest that you consider the user interface. In particular, consider swapping the order of the command line arguments. All command line tools that I can think of have the order "action" and then "file name". E.g., think |
Hi @kroening, I'm working on adding tests (didn't want to commit to writing tests before there's conclusion that the approach is not objectionable to people) and during the authoring of tests I have discovered some issues with the interface that led me to rethink the approach. Will update the PR as soon as my current change is stable and the interface is smoother. |
ac8c34a
to
13997e0
Compare
Hi @kroening, I've had some more time to play around with this, and it doesn't have any particular dependency on the order of arguments, i.e. both: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The individual commits are not very clean. I suggest to squash them as they all fix up earlier commits of the same PR.
|
||
if( | ||
cmdline.isset("show-goto-functions") || | ||
cmdline.isset("list-goto-functions")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This alias is not configured in GOTO_INSPECT_OPTIONS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
c7e67aa
to
5cffca7
Compare
Squashed the commits down to one. |
I got thrown off by your comment "Yes, changed to > 2" -- this is outdated? |
5cffca7
to
ac30b42
Compare
Hi @kroening,
Yes. Thomas had asked if I can tighten the error checking there, which I initially did by checking that the At that point, I changed it to check that we always get one positional argument (based on the fact that the tool, for now, operates on one goto-binary at a time) before we do anything, and dispatches to various inspection options based on them being set and the above precondition (at least 1 positional argument, i.e. 1 goto-binary filename) holds. If the positional argument doesn't correspond to a goto-binary, we get an error that the program failed to read a goto-binary. |
ac30b42
to
52b31f5
Compare
This allows to inspect a goto-binary (this means showing the goto-functions, for now at least). The reason this binary is helpful is that different tools (CBMC, goto-instrument, etc) perform instrumentation before showing the goto-functions, and there's a need to be able to inspect certain properties of a goto-binary without doing instrumentation.
52b31f5
to
7724092
Compare
This allows to inspect a goto-binary (this means showing the goto-functions, for now at least).
The reason this binary is helpful is that different tools (CBMC, goto-instrument, etc) perform instrumentation before showing the goto-functions, and there's a need to be able to inspect certain properties of a goto-binary without doing instrumentation.