Comments (5)
so the current code relies on the user using an hexadecimal address and doesn't handle breakpoints set on a function.
Yeah that is not good. We could try to resolve the bp.location
, but maybe check for Breakpoint.locations
and use it if we can. If we can get the bp
number, then using info breakpoints
might be easy, but we probably don't want to run commands and parse its output too often, because it can slow down single-stepping (since it runs on every context print).
from gef.
For info breakpoints
why do you want the bp
number first ? I was thinking about a simple regex such as:
breakpoints = gdb.execute("info breakpoints", to_string=True)
bp_locations = re.findall(r'0x[0-9a-f]+', breakpoints)
For parsing bp.location
I can start working on it, but I haven't figured out yet how to find the address of a symbol without relying on commands and it will never be perfect, because we have no way of parsing something like b *$rip
.
So far I have sketched something like this:
if GDB_VERSION >= (13, 1):
bp_locations = [location.address for b in breakpoints for location in b.locations if location is not None]
else:
bp_locations = [self.parse_location(b.location) for b in breakpoints if b.location is not None]
@lru_cache()
def parse_location(self, location: str) -> int:
exact = False
if location.startswith("*"):
location = location[1:].strip() # Remove leading spaces
if location.startswith("0x"):
return int(location, 16)
elif location.isdigit():
return int(location)
exact = True
location = location.split("+") # Can a symbol have a
if len(location) == 2:
symbol, offset = map(lambda x: x.strip(), location)
else:
symbol, offset = location[0], 0
base_address = self.parse_symbol(symbol, exact=exact)
def parse_symbol(self, symbol: str, exact=True) -> int:
#TODO
from gef.
For info breakpoints why do you want the bp number first ? I
So that you can info breakpoint NUMBER
so we know which line to parse. I was thinking if we wanted to look for a specific one.
For registers, that is tough, since the register value basically becomes irrelevant immediately after it's set.
I think that we should use hasattr
instead of checking the GDB_VERSION
, since it better guards against some distros maybe having patches that add the feature early or don't have it in 13.1.
What is your part with b.locations
? Why would a breakpoint have more than one location, and from what I see, that attribute is not set.
from gef.
I think that we should use
hasattr
instead of checking theGDB_VERSION
, since it better guards against some distros maybe having patches that add the feature early or don't have it in 13.1.
I didn't think about these cases. Okay 👍
What is your part with
b.locations
? Why would a breakpoint have more than one location, and from what I see, that attribute is not set.
I'm still on version 12.1 so I was looking for a docker to test it and for now I only sketched it based on the documentation. "Variable: Breakpoint.locations. Get the most current list of breakpoint locations that are inserted for this breakpoint". You may end up with a breakpoint in multiple locations if you set it on a line of the source code.
Regarding what to do now, I looked at the performances of info breakpoints
and I saw how slow it is, making context take twice as long and getting slower with each additional breakpoint. I don't feel like I can handle the parsing though. Do I still test the code for b.locations
and try to push a patch for those who have the new versions of gdb or do we wait to have something that works for everyone ?
from gef.
Thank you for testing the speed. I say we add just the hasattr, and basically behave better if we can.
from gef.
Related Issues (20)
- [Bug] Weird memory mapping with rr replay HOT 3
- [Bug] pyenv site_packages_dir assertion fails when setting multiple python versions in pyenv HOT 5
- [Bug] GEF installation error with GDB 8.2 with Python3.6 bindings HOT 3
- [Bug] read_cstring length can be set so that it reads into an unmapped region HOT 1
- [Bug] Missing update of local `/proc/{pid}/maps` in remote session when new shared library is loaded HOT 5
- [Bug] cant open under ubuntu 16.0.4 python 3.6 HOT 2
- Question about pyenv HOT 6
- [Docs] Add `pre-commit` documentation
- sth. about function and UI HOT 1
- gef for windows HOT 2
- The Gef Frame Is small HOT 2
- [Bug] AssertionError HOT 5
- Possible GEF `dereference` issue with `gef-remote` HOT 3
- Add support for LLDB HOT 1
- [Bug] GEF supports Python 3.6+ but uses f-string debugging only introduced in Python 3.8+, breaking compatibility
- [Bug] vmmap command 'offset' column actually shows size HOT 1
- [Bug] SyntaxError: unterminated triple-quoted string literal HOT 1
- display bug , after some commands ,there will be a wrong display HOT 9
- Python Exception <class 'RuntimeError'>: No session started HOT 5
- Alpine dependencies HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gef.