Skip to content

Commit

Permalink
hilda_client: Add set_selected_thread
Browse files Browse the repository at this point in the history
  • Loading branch information
netanelc305 committed Jun 9, 2024
1 parent 2127284 commit 472e0de
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
9 changes: 9 additions & 0 deletions hilda/common.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
from datetime import datetime
from typing import Any, List, Mapping, Tuple, Union

import inquirer3
from inquirer3.themes import GreenPassion

CfSerializable = Union[
Mapping[str, Any], List, Tuple[Any, ...], str, bool, float, bytes, datetime, None]


def selection_prompt(options_list: List):
question = [inquirer3.List('choice', message='choose device', choices=options_list, carousel=True)]
result = inquirer3.prompt(question, theme=GreenPassion(), raise_keyboard_interrupt=True)
return result['choice']
9 changes: 7 additions & 2 deletions hilda/hilda_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from traitlets.config import Config

from hilda import objective_c_class
from hilda.common import CfSerializable
from hilda.common import CfSerializable, selection_prompt
from hilda.exceptions import AccessingMemoryError, AccessingRegisterError, AddingLldbSymbolError, \
BrokenLocalSymbolsJarError, ConvertingFromNSObjectError, ConvertingToNsObjectError, CreatingObjectiveCSymbolError, \
DisableJetsamMemoryChecksError, EvaluatingExpressionError, HildaException, SymbolAbsentError
Expand Down Expand Up @@ -510,7 +510,7 @@ def callback(hilda, frame, bp_loc, options):
if options.get('name', False):
name = options['name']

log_message = f'🚨 #{bp.id} 0x{symbol:x} {name}'
log_message = f'🚨 #{bp.id} 0x{symbol:x} {name} - Thread #{self.thread.idx}:{hex(self.thread.id)}'

if 'regs' in options:
log_message += '\nregs:'
Expand Down Expand Up @@ -880,6 +880,11 @@ def import_module(self, filename: str, name: Optional[str] = None) -> Any:
spec.loader.exec_module(m)
return m

def set_selected_thread(self, idx: int = None):
if idx is None:
idx = selection_prompt(self.process.threads).idx
self.process.SetSelectedThread(self.process.threads[idx - 1])

def unwind(self) -> bool:
""" Unwind the stack (useful when get_evaluation_unwind() == False) """
return self.thread.UnwindInnermostExpression().Success()
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ objc_types_decoder
construct
pymobiledevice3
keystone-engine
tabulate
tabulate
inquirer3

0 comments on commit 472e0de

Please sign in to comment.