Skip to content

Commit

Permalink
Fix Qemu user/kernel mode detection
Browse files Browse the repository at this point in the history
  • Loading branch information
clubby789 committed Oct 22, 2022
1 parent 809f85c commit a5b62eb
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -3350,15 +3350,15 @@ def is_qemu() -> bool:
def is_qemu_usermode() -> bool:
if not is_qemu():
return False
response = gdb.execute('maintenance packet QOffsets', to_string=True, from_tty=False)
response = gdb.execute('maintenance packet qOffsets', to_string=True, from_tty=False)
return "Text=" in response


@lru_cache()
def is_qemu_system() -> bool:
if not is_qemu():
return False
response = gdb.execute('maintenance packet QOffsets', to_string=True, from_tty=False)
response = gdb.execute('maintenance packet qOffsets', to_string=True, from_tty=False)
return 'received: ""' in response


Expand Down Expand Up @@ -10191,8 +10191,12 @@ def maps(self) -> List[Section]:

def __parse_maps(self) -> List[Section]:
"""Return the mapped memory sections"""
if is_qemu_system():
return list(self.__parse_info_mem())
try:
if is_qemu_system():
return list(self.__parse_info_mem())
except gdb.error:
# Target may not support this command
pass
try:
return list(self.__parse_procfs_maps())
except FileNotFoundError:
Expand Down Expand Up @@ -10496,13 +10500,9 @@ def auxiliary_vector(self) -> Optional[Dict[str, int]]:
return None
if is_qemu_system():
return None

if not self._auxiliary_vector:
auxiliary_vector = {}
try:
auxv_info = gdb.execute("info auxv", to_string=True)
except gdb.error:
auxv_info = None
auxv_info = gdb.execute("info auxv", to_string=True)
if not auxv_info or "failed" in auxv_info:
err("Failed to query auxiliary variables")
return None
Expand Down

0 comments on commit a5b62eb

Please sign in to comment.