Fix TUI context sections display after #2743 (#2764)

We're now using `writelines` to output the context data which wasn't implemented
for the CallOutput redirection layer. Add a smoke test for that output redirection.

Refs #2654
pull/2770/head
peace-maker 9 months ago committed by GitHub
parent fa3fdf7552
commit 61a91fee31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -204,6 +204,9 @@ class CallOutput:
def write(self, data) -> None:
self.func(data)
def writelines(self, lines_iterable) -> None:
self.func("".join(lines_iterable))
def flush(self):
try:
return self.func.flush()

@ -9,6 +9,7 @@ import pwndbg.aglib.memory
import pwndbg.aglib.regs
import pwndbg.commands
import pwndbg.commands.canary
import pwndbg.commands.context
import tests
REFERENCE_BINARY = tests.binaries.get("reference-binary.out")
@ -555,3 +556,31 @@ def test_context_history_search(start_binary):
# Search in non-existing section
search_result = gdb.execute("ctxsearch 'Hello World' nonexistent", to_string=True)
assert "Section 'nonexistent' not found in context history." in search_result
def test_context_output_redirection(start_binary):
start_binary(REFERENCE_BINARY)
# Test CallOutput redirection
def receive_output(output):
receive_output.context_output = output
receive_output.context_output = ""
pwndbg.commands.context.contextoutput(
"regs",
receive_output,
clearing=True,
banner="top",
width=80,
)
gdb.execute("start")
out = gdb.execute("ctx", to_string=True)
assert "REGISTERS" not in out
assert "STACK" in out
assert "REGISTERS" in receive_output.context_output
assert "STACK" not in receive_output.context_output
pwndbg.commands.context.resetcontextoutput("regs")

Loading…
Cancel
Save