Skip to content

Builder imported itself#637

Merged
kristoff3r merged 1 commit intoGallopsled:masterfrom
TethysSvensson:remove-self-import
Jul 3, 2016
Merged

Builder imported itself#637
kristoff3r merged 1 commit intoGallopsled:masterfrom
TethysSvensson:remove-self-import

Conversation

@TethysSvensson
Copy link
Copy Markdown
Contributor

No description provided.

@kristoff3r kristoff3r merged commit 5c5e797 into Gallopsled:master Jul 3, 2016
@TethysSvensson TethysSvensson deleted the remove-self-import branch August 18, 2016 18:56
Kyle-Kyle pushed a commit to Kyle-Kyle/pwntools that referenced this pull request Apr 25, 2021
…led#637)

TLDR:
1. We read registers from `newest_frame` instead of `selected_frame` for GDB>=7.9.
2. We have two ways to fetch registers - `regs.__getitem__` and
`regs.__getattr__` - one of them didn't invalidate cache and so after
fixing 1st, we still shown the old register after switching frames.
Kyle-Kyle pushed a commit to Kyle-Kyle/pwntools that referenced this pull request Apr 25, 2021
* Fix source code display

Fixes and simplifies source code display in `context code`. The
reasoning below.

---

It turns out that we determine the source code line for known code in a
tricky and buggy way. It is wrong when we are deep inside many calls and
we go to upper frame via e.g. `up` and then display the `context code`.

And this also occurs after applying the PR Gallopsled#637 before/after this fix.

We also do `except` all exceptions happening in the source code
retrieval which makes it hard to spot potential bugs in this code path.

This commit removes the `except` path and checks for particular edge
cases where we wouldn't have sources available.

---

Also note the `FileNotFoundError` path - in this case the debug symbols
have a source file path there, but it hasn't been found by us. It might
be because the program (or anything else) removed it OR maybe we debug
remotely etc (not sure if this is the case).

This being said, we could potentially inform the users about that BUT...
GDB already does that by itself - maybe in a bit vague way, as it does
it before us displaying the context e.g.:

```
pwndbg> r
Starting program: /home/dc/pwndbg/a.out

Program received signal SIGSEGV, Segmentation fault.
0x000055555555460a in foo () at ./a.c:2
2	./a.c: No such file or directory.
LEGEND: STACK | HEAP | CODE | DATA | RWX | RODATA
// (the rest of the context here)
```

But I am fine with that for now - and I am not sure if we could even
suppress this warning (oh, maybe this string comes to us into prompt
hook/event? I don't know)

* Fix wrong code line if source startswith newlines

For some reason the `pygments.hightlight` remove newlines at start.
We need to preserve them in order to keep proper code lines.

* Use lexer's stripnl=False
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.

2 participants