mirror of https://github.com/pwndbg/pwndbg.git
fix errno command (#1112)
* fix errno command * fix isort * try to fix CI * Update test_command_errno.pypull/1114/head
parent
9755a40d7b
commit
42f32d7cc7
@ -0,0 +1,48 @@
|
||||
import gdb
|
||||
|
||||
import pwndbg
|
||||
import pwndbg.memory
|
||||
import pwndbg.regs
|
||||
import tests
|
||||
|
||||
# We use the heap_vis binary as it enforces pthreads and so will have TLS on all distros
|
||||
REFERENCE_BINARY = tests.binaries.get("heap_vis.out")
|
||||
|
||||
|
||||
def test_command_errno(start_binary):
|
||||
"""
|
||||
Tests the errno command display
|
||||
"""
|
||||
start_binary(REFERENCE_BINARY)
|
||||
|
||||
# Since start_binary does 'starti' which stops on the very first instruction
|
||||
# the errno is not yet an available symbol, because the libc library it is
|
||||
# defined in is not yet loaded
|
||||
result = "".join(gdb.execute("errno", to_string=True).splitlines())
|
||||
assert (
|
||||
result
|
||||
== "Could not determine error code automatically: neither `errno` nor `__errno_location` symbols were provided (was libc.so loaded already?)"
|
||||
)
|
||||
|
||||
gdb.execute("break main")
|
||||
gdb.execute("continue")
|
||||
|
||||
result = gdb.execute("errno", to_string=True)
|
||||
assert result == "Errno 0: OK\n"
|
||||
|
||||
gdb.execute("set *(int*)&errno=11")
|
||||
result = gdb.execute("errno", to_string=True)
|
||||
assert result == "Errno 11: EAGAIN\n"
|
||||
|
||||
gdb.execute("set *(int*)&errno=111")
|
||||
result = gdb.execute("errno", to_string=True)
|
||||
assert result == "Errno 111: ECONNREFUSED\n"
|
||||
|
||||
result = gdb.execute("errno 8", to_string=True)
|
||||
assert result == "Errno 8: ENOEXEC\n"
|
||||
|
||||
result = gdb.execute("errno 123", to_string=True)
|
||||
assert result == "Errno 123: ENOMEDIUM\n"
|
||||
|
||||
result = gdb.execute("errno 250", to_string=True)
|
||||
assert result == "Errno 250: Unknown error code\n"
|
||||
Loading…
Reference in new issue