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

Fix repeat command alias nearpc #2096

Closed

Conversation

jetchirag
Copy link
Contributor

Fixes #2095

Adds condition to check if repeat is set for any of the command in nearpc as the main command and aliases share different objects.

Signed-off-by: Chirag Aggarwal <[email protected]>
Copy link

codecov bot commented Mar 26, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 59.68%. Comparing base (83d8d95) to head (cb70de1).
Report is 12 commits behind head on dev.

❗ Current head cb70de1 differs from pull request most recent head 7a04ec8. Consider uploading reports for the commit 7a04ec8 to get more accurate results

Files Patch % Lines
pwndbg/commands/nearpc.py 50.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2096      +/-   ##
==========================================
- Coverage   59.68%   59.68%   -0.01%     
==========================================
  Files         191      191              
  Lines       24429    24434       +5     
  Branches     2422     2424       +2     
==========================================
+ Hits        14581    14583       +2     
- Misses       9064     9066       +2     
- Partials      784      785       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@disconnect3d
Copy link
Member

Hmm I think that ideally, we want to do this properly so that not only nearpc works fine, but other commands that would have aliases and be repeated too.

Not sure if we have such commands now, but we may in the future.

@gsingh93
Copy link
Member

Will probably need to change something around here:

if number not in Command.history:
Command.history[number] = command
return False

Ideally, we would only have a single command regardless of the number of aliases. But to do that I think we would need to hook GDB's command parsing look up that single command if any aliases were passed in there. I haven't looked into exactly how it would work, but I'm guessing the added complexity and bugs we'll introduce the future are probably not worth it.

@disconnect3d
Copy link
Member

disconnect3d commented Mar 28, 2024 via email

@gsingh93
Copy link
Member

Yes, I think that should work as long as from_tty=True.

@disconnect3d
Copy link
Member

@jetchirag can u update this accordingly?

@jetchirag
Copy link
Contributor Author

jetchirag commented Apr 9, 2024 via email

@jetchirag
Copy link
Contributor Author

@disconnect3d

u seems to already be registered as alias in gdb, rest are working fine.

for alias in self.aliases:
            alias_command = f"alias {alias} = {function.__name__}"
            gdb.execute(alias_command)
gdb.error: Alias already exists: u

@disconnect3d
Copy link
Member

Yeah it seems its fully controlled via GDB... its weird we can overwrite it as a command but not as an alias.

https://github.com/bminor/binutils-gdb/blob/3f3014cb00fabe1e340b277016a2f161ca297c71/gdb/infcmd.c#L3273-L3280

Let's close this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Repeat doesn't work with nearpc alias = u
3 participants