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

Implement LoggerType#dump #85

Merged
merged 8 commits into from Jan 30, 2018
Merged

Implement LoggerType#dump #85

merged 8 commits into from Jan 30, 2018

Conversation

david942j
Copy link
Collaborator

@david942j david942j commented Jan 25, 2018

Implement #62

libc = 0xdead000
stack = 0xbeef000
log.dump libc.hex, stack.hex
# [DUMP] libc.hex = "0xdead000", stack.hex = "0xbeef000"

Hacky methods are used:

  1. Get the source code from file (using gem method_source)
  2. Parse the source code to Sexp (using ruby_parser)
  3. Traverse the sexp to find the block/arguments when calling dump
  4. Convert the sexp of block/arguments back to Ruby code (using gem ruby2ruby)
  5. Show the result

Therefore, some unusual usages will fail, such as:

  • log.dump(&a_proc) # nil will be logged
  • log.dump { 1 }; log.dump { 2 } # will log 1 two times

Two new dependencies are added:

  • method_source
  • ruby2ruby

This change is Reviewable

# This method do the following things:
# 1. Get the source code from file (using gem `method_source`)
# 2. Parse the source code to Sexp using `ruby_parser`
# 3. Traverse the sexp and find the block argument when calling `:dump`
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

to find

# This method doesn't work in a REPL shell.
#
# @note
# The source code in block will be parsed using +ruby_parser+,
Copy link
Collaborator

Choose a reason for hiding this comment

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

will be parsed by using +ruby_parser+

@hanhanW
Copy link
Collaborator

hanhanW commented Jan 26, 2018

Support log.dump(x+y) instead of log.dump('x+y') would have better user experience.

@hanhanW
Copy link
Collaborator

hanhanW commented Jan 30, 2018

:lgtm:

@hanhanW hanhanW merged commit 867091f into master Jan 30, 2018
@hanhanW hanhanW deleted the feature/log.dump branch January 30, 2018 12:53
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.

None yet

2 participants