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

Add on_changed setting hook #1090

Merged
merged 2 commits into from
Apr 23, 2024
Merged

Add on_changed setting hook #1090

merged 2 commits into from
Apr 23, 2024

Conversation

hugsy
Copy link
Owner

@hugsy hugsy commented Apr 22, 2024

Description

This PR fixes some issues in the setting loading process resulting in the default value always being taken for gef-extras scripts (as underlined by hugsy/gef-extras#107

GefSetting now offers the possibility to trigger a callback, on_changed which behaves just like on_write but only if the value was changed.

Checklist

  • My code follows the code style of this project.
  • My change includes a change to the documentation, if required.
  • If my change adds new code, adequate tests have been added.
  • I have read and agree to the CONTRIBUTING document.

@hugsy hugsy self-assigned this Apr 22, 2024
@hugsy hugsy added this to the 2024.05 milestone Apr 22, 2024
Copy link

🤖 Coverage update for 071046a 🟢

Old New
Commit 13af366 071046a
Score 71.6374% 71.6374% (0)

@hugsy
Copy link
Owner Author

hugsy commented Apr 22, 2024

As an example, gef.extras_plugin_dir was added as on_changed, allowing extras plugins to be loaded at anytime:

$ gdb -q -nx
(gdb) source ~/code/gef/gef.py
GEF for linux ready, type `gef' to start, `gef config' to configure
89 commands loaded and 5 functions added for GDB 12.1 in 0.00ms using Python engine 3.10
gef➤  gef config gef.debug True
gef➤  gef config gef.extra_plugins_dir ~/code/gef-extras/scripts                                                                             [=] in __invoke_changed_hooks("gef.extra_plugins_dir"), setting.value='' -> new_value='~/code/gef-extras/scripts', changing=True
[=] Loading extra plugins from directory=PosixPath('/home/hugsy/code/gef-extras/scripts')
[=] Loading '/home/hugsy/code/gef-extras/scripts/assemble.py'
[=] Loading '/home/hugsy/code/gef-extras/scripts/bincompare.py'
[=] Loading '/home/hugsy/code/gef-extras/scripts/bytearray.py'
[=] Loading '/home/hugsy/code/gef-extras/scripts/capstone.py'                                                                                                                                                                                                                     [=] Loading '/home/hugsy/code/gef-extras/scripts/ftrace.py'
[=] Loading '/home/hugsy/code/gef-extras/scripts/ida_interact.py'                                                                            [=] Loading '/home/hugsy/code/gef-extras/scripts/peekpointers.py'                                                    
[...]
[=] Loading '/home/hugsy/code/gef-extras/scripts/syscall_args/syscall-tables/X86_64.py'
[+] 42 extra commands added in 0.39 seconds

Copy link

🤖 Coverage update for fddba95 🔴

Old New
Commit 13af366 fddba95
Score 71.6374% 71.5933% (-0.0441)

Copy link

🤖 Coverage update for fddba95 🟢

Old New
Commit 13af366 fddba95
Score 71.6374% 71.6374% (0)

@hugsy hugsy requested a review from therealdreg April 22, 2024 20:31
@therealdreg
Copy link
Sponsor Collaborator

LGFM! @hugsy

@hugsy hugsy merged commit 6667af6 into main Apr 23, 2024
6 checks passed
@hugsy hugsy deleted the add_on_changed_setting_hook branch April 23, 2024 01:09
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.

None yet

2 participants