mmap command: update return value message (#1954)

Updates the mmap return value message from just "0x1234" to "mmap syscall returned 0x1234"
pull/1960/head
Disconnect3d 2 years ago committed by GitHub
parent dfd5f95b56
commit 0c61ed5d27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -250,4 +250,4 @@ using the address {aligned_addr:#x} instead.\
int(offset),
)
print(f"{pointer:#x}")
print(f"mmap syscall returned {pointer:#x}")

@ -38,7 +38,9 @@ def test_mmap_executes_properly(start_binary):
)
# Check basic private+anonymous page mmap.
ptr = int(gdb.execute(f"mmap 0x0 {page_size}", to_string=True), 0)
output = gdb.execute(f"mmap 0x0 {page_size}", to_string=True)
assert output.startswith("mmap syscall returned ")
ptr = int(output.split(" returned ")[1].rstrip(), 16)
assert not is_mmap_error(ptr)
assert has_correct_perms(ptr, "rwx")
@ -49,12 +51,11 @@ def test_mmap_executes_properly(start_binary):
if page is None:
break
base_addr = page.end
ptr = int(
gdb.execute(
f"mmap {base_addr:#x} {page_size} 7 MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE", to_string=True
),
0,
output = gdb.execute(
f"mmap {base_addr:#x} {page_size} 7 MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE", to_string=True
)
assert output.startswith("mmap syscall returned ")
ptr = int(output.split(" returned ")[1].rstrip(), 16)
assert not is_mmap_error(ptr)
assert has_correct_perms(ptr, "rwx")
assert ptr == base_addr
@ -65,7 +66,9 @@ def test_mmap_executes_properly(start_binary):
# Retrieve the file descriptor number and map it to memory.
fd_num = int(gdb.newest_frame().read_var("fd"))
ptr = int(gdb.execute(f"mmap 0x0 16 PROT_READ MAP_PRIVATE {fd_num} 0", to_string=True), 0)
output = gdb.execute(f"mmap 0x0 16 PROT_READ MAP_PRIVATE {fd_num} 0", to_string=True)
assert output.startswith("mmap syscall returned ")
ptr = int(output.split(" returned ")[1].rstrip(), 16)
assert not is_mmap_error(ptr)
assert has_correct_perms(ptr, "r")

Loading…
Cancel
Save