Skip to content

Various stuff not merged correctly in #636.#638

Merged
kristoff3r merged 4 commits intoGallopsled:masterfrom
TethysSvensson:remove-stale-files
Jul 3, 2016
Merged

Various stuff not merged correctly in #636.#638
kristoff3r merged 4 commits intoGallopsled:masterfrom
TethysSvensson:remove-stale-files

Conversation

@TethysSvensson
Copy link
Copy Markdown
Contributor

No description provided.

@TethysSvensson
Copy link
Copy Markdown
Contributor Author

@zachriggle: I assume those files are no longer needed. Am I correct?

@TethysSvensson
Copy link
Copy Markdown
Contributor Author

This has sort of become a misc PR for fixing small stuff that was broken by #636. I don't know if all of it is correct though.

@TethysSvensson TethysSvensson changed the title Removed binjitsu files not identified as stale in #636. Various stuff not merged correctly in #636. Jul 3, 2016
@kristoff3r kristoff3r merged commit 3d5f859 into Gallopsled:master Jul 3, 2016
@TethysSvensson TethysSvensson deleted the remove-stale-files branch August 18, 2016 18:56
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