Skip to content
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

enhanced the registry module to support pretty printing and string co… #877

Closed
wants to merge 3 commits into from

Conversation

esohel30
Copy link
Contributor

#869

This pull request adds pp and show functions to the Registry module to enable pretty-printing of the map contents for easier debugging and logging.

Changes:

Added pp Function:

The pp function formats the map's key-value pairs for pretty-printing.
Utilizes Format.fprintf for formatting and printing the map contents in a readable format.

Added show Function:

The show function converts the map to a string representation using the pp function.

Uses Format.asprintf to generate the string representation of the map.

Modified File:

registry.ml

The pull request is not fully done. Please provide any feedback on if I have the general understanding of the Issue. I will then implement the feedback and attempt to tackle the entire issue.

@facebook-github-bot
Copy link
Contributor

Hi @esohel30!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

Copy link
Contributor

@arthaud arthaud left a comment

Choose a reason for hiding this comment

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

That's the idea :)

Could we define this directly in source/interprocedural/fixpoint.ml, in the Registry module? That file defines a generic "interprocedural fixpoint", and the taint analysis is just an instantiation. Since your pp/show functions are generic, they can go there directly :)

Also please demonstrate that it works by pretty-printing a registry. You should be able do to that within a test. To clarify: you don't have to make it a test, just please demonstrate that it worked once, by showing some logs/stderr output.

let pp pp_value formatter map =
let pp_pairs formatter pairs =
let pp_pair formatter (key, value) =
Format.fprintf formatter "@[<hv 2>%a -> %a@]" Target.pp key pp_value value
Copy link
Contributor

Choose a reason for hiding this comment

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

We want to use Model.pp here instead of pp_value

Comment on lines 51 to 52
let show pp_value map =
Format.asprintf "%a" (pp pp_value) map
Copy link
Contributor

Choose a reason for hiding this comment

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

We can make this a bit more concise

Suggested change
let show pp_value map =
Format.asprintf "%a" (pp pp_value) map
let show =
Format.asprintf "%a" pp

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@esohel30 esohel30 closed this Jun 26, 2024
@arthaud arthaud mentioned this pull request Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants