-
Notifications
You must be signed in to change notification settings - Fork 867
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
Some enhancements about pwndbg.gdblib.config
#1315
Conversation
* Support all parameter-class * Use `get_show_string` to render better output when using `show <param>` * Show more information when using `help set <param>` and `help show <param>` if we create a config with `help_docstring` parameter. Some examples of the updates included in this commit: 1. `gdb.PARAM_AUTO_BOOLEAN` with `help_docstring` In Python script: ``` pwndbg.gdblib.config.add_param( "test", None, "test", "on == AAAA\noff == BBBB\nauto == CCCC", gdb.PARAM_AUTO_BOOLEAN, scope="test", ) ``` In GDB: ``` pwndbg> show test The current value of 'test' is 'auto' pwndbg> set test on Set test to 'on' pwndbg> set test off Set test to 'off' pwndbg> set test auto_with_typo "on", "off" or "auto" expected. pwndbg> show test The current value of 'test' is 'off' pwndbg> set test auto Set test to 'auto' pwndbg> show test The current value of 'test' is 'auto' pwndbg> help show test Show test on == AAAA off == BBBB auto == CCCC pwndbg> help set test Set test on == AAAA off == BBBB auto == CCCC ``` 2. `gdb.PARAM_AUTO_BOOLEAN` with `help_docstring` In Python script: ``` pwndbg.gdblib.config.add_param( "test", "A", "test", "A == AAAA\nB == BBBB\nC == CCCC", gdb.PARAM_ENUM, ["A", "B", "C"], scope="test", ) ``` In GDB: ``` pwndbg> show test The current value of 'test' is 'A' pwndbg> set test B Set test to 'B' pwndbg> set test C Set test to 'C' pwndbg> set test D Undefined item: "D". pwndbg> show test The current value of 'test' is 'C' pwndbg> help show test Show test A == AAAA B == BBBB C == CCCC pwndbg> help set test Set test A == AAAA B == BBBB C == CCCC ```
Codecov Report
@@ Coverage Diff @@
## dev #1315 +/- ##
==========================================
- Coverage 55.04% 55.03% -0.01%
==========================================
Files 156 156
Lines 19397 19410 +13
Branches 1804 1809 +5
==========================================
+ Hits 10677 10683 +6
- Misses 8276 8278 +2
- Partials 444 449 +5
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it 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.
Thanks for doing this and thanks for adding so many comments :) It was very easy to review.
): | ||
# Note: This is really weird, according to GDB docs, 0 should mean "unlimited" for gdb.PARAM_UINTEGER and gdb.PARAM_INTEGER, but somehow GDB sets the value to `None` actually :/ | ||
# And hilarious thing is that GDB won't let you set the default value to `None` when you construct the `gdb.Parameter` object with `gdb.PARAM_UINTEGER` or `gdb.PARAM_INTEGER` lol | ||
# Maybe it's a bug of GDB? |
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.
Let's consider reporting this upstream if we can.
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.
Ok, I sent it to the mailing list of GDB now.
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.
Link the discussion in a comment reply to this PR pls
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.
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.
https://sourceware.org/pipermail/gdb/2022-October/050398.html
Update: https://sourceware.org/pipermail/gdb/2022-October/050426.html
If I didn't misunderstand something, seems like the value in Python to represent unlimited
will only be None
instead of some integers in the future.
So we'll probably need to update the code here, the tests' params, and _value_to_gdb_native()
to fit the new API in the future.
986f51e
to
2921927
Compare
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.
LGTM, will let @disconnect3d take a look and merge.
def __init__( | ||
self, | ||
name, | ||
default, | ||
docstring, | ||
help_docstring=None, | ||
param_class=None, | ||
enum_sequence=None, | ||
scope="config", | ||
): |
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.
Maybe we should also add the *
in here to force keyword params starting from help_docstring
?
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.
That probably makes sense, 👍.
Btw one note: docstring
and help_docstring
is not so obvious I guess? I already merged this but noticed this only now. Maybe we should rename docstring
to set_show_doc
?
* Add `*`: pwndbg#1315 (comment) * Use `set_show_doc` instead of `docstring`: pwndbg#1315 (comment)
* Add `*`: pwndbg#1315 (comment) * Use `set_show_doc` instead of `docstring`: pwndbg#1315 (comment)
…lated to config (#1388) * Add a config for the `vis_heap_chunks` command After this commit, we can use `set default-visualize-chunk-number <number>` to set the default value of the `count` argument of the `vis_heap_chunks` command. * Add a test for `default-visualize-chunk-number` * Refactor some code related to config * Add `*`: #1315 (comment) * Use `set_show_doc` instead of `docstring`: #1315 (comment)
Summary about this PR:
Support all parameter-class when create a GDB parameter
Use
get_show_string
to render better output when usingshow <param>
(although GDB 12.x will do similar things by default, this function just makes sure every version can have that kind of output)Show more information when using
help set <param>
andhelp show <param>
if we create a config withhelp_docstring
parameter.Here are some examples of the updates included in this PR:
gdb.PARAM_AUTO_BOOLEAN
withhelp_docstring
In Python script:
In GDB:
gdb.PARAM_AUTO_BOOLEAN
withhelp_docstring
In Python script:
In GDB: