Skip to content

irep_idt pretty printer improvements #4942

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

Merged
merged 9 commits into from
Jul 25, 2019
Merged

Conversation

NathanJPhillips
Copy link
Contributor

This updates the irep_idt pretty printers to include the dstring number and to cope better with uninitialised dstrings or optimised-out values. It also makes the installation script more resilient for people who already have the libstd pretty printers installed.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

Copy link
Contributor

@JohnDumbell JohnDumbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some good changes

except:
return ""
return "Exception evaluating dstringt"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think showing the exception is useful to anyone unless they're debugging the pretty printers, better to just leave it blank so it doesn't show anything at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might be right. Though a blank string may be confusing to the user?

Copy link
Contributor

@JohnDumbell JohnDumbell Jul 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I tested it before it wasn't a blank string but no value to be printed, might've changed a little with the type also changing, but that'd be the best result.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, dropped that commit

imports.add(lines[line_no][len("import "):].strip())
lines.pop(line_no)
else:
if lines[line_no].startswith('cbmc_printers_folder = '):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull the string out into a variable if you're using it for an anchor to detect the first line:

script_start_anchor = "cbmc_printers_folder = "

lines = [ line.rstrip() for line in file ]
line_no = 0
imports = { "os", "sys" }
while line_no < len(lines):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was reluctant to put this in originally as if you had a .gdbinit file you already knew enough to apply this directly. You might want to save a backup.gdbinit somewhere just in case things are detected incorrectly and you make unwanted modifications to the file that can't be got back.

return "<Optimized out>"
return value
return "{}: <Optimized out>".format(string_no)
return "{}: \"{}\"".format(string_no, value.string().replace("\0", "").replace("\"", "\\\""))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced showing the number has any value when you have the string representation, for all intents and purposes it's just a string, no point confusing people new to it.

Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: 0b1648f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/120253808

@codecov-io
Copy link

Codecov Report

Merging #4942 into develop will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4942      +/-   ##
===========================================
- Coverage    69.26%   69.26%   -0.01%     
===========================================
  Files         1307     1307              
  Lines       108089   108087       -2     
===========================================
- Hits         74868    74866       -2     
  Misses       33221    33221
Impacted Files Coverage Δ
src/util/fresh_symbol.cpp 100% <0%> (ø) ⬆️
src/goto-programs/show_symbol_table.cpp 90.66% <0%> (+0.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 69a9528...0b1648f. Read the comment docs.

@NathanJPhillips
Copy link
Contributor Author

@JohnDumbell isn't sure displaying the dstringt number is helpful in which case I can drop that commit. Does anyone else have any opinions in either direction?

Make it:
* able to detect when it has already been run
* able to add script to existing file without breaking existing printers
* add new script before existing printers that might clash with it (such as the C++ ones)
* executable
Adjust the display_hint type and the formatting to show string as before except after the number
@NathanJPhillips NathanJPhillips force-pushed the feature/irep_idt_pretty branch from 0b1648f to 2eca2b1 Compare July 24, 2019 18:05
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: 2eca2b1).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/120505314

@peterschrammel
Copy link
Member

peterschrammel commented Jul 25, 2019

I don't think showing the number would be confusing (practice will show whether it's useful, though).

@NathanJPhillips NathanJPhillips merged commit 58301ff into develop Jul 25, 2019
@NathanJPhillips NathanJPhillips deleted the feature/irep_idt_pretty branch July 25, 2019 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants