hilda 2.0.1__py3-none-any.whl → 2.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
hilda/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '2.0.1'
16
- __version_tuple__ = version_tuple = (2, 0, 1)
15
+ __version__ = version = '2.0.2'
16
+ __version_tuple__ = version_tuple = (2, 0, 2)
hilda/cli.py CHANGED
@@ -54,10 +54,10 @@ def attach(name: str, pid: int, startup_files: Optional[List[str]] = None) -> No
54
54
  @click.argument('exec_path')
55
55
  @click.option('--argv', multiple=True, help='Command line arguments to pass to the process')
56
56
  @click.option('--envp', multiple=True, callback=parse_envp, help='Environment variables in the form KEY=VALUE')
57
- @click.option('--stdin', type=Path, help='Redirect stdin from this file path')
58
- @click.option('--stdout', type=Path, help='Redirect stdout to this file path')
59
- @click.option('--stderr', type=Path, help='Redirect stderr to this file path')
60
- @click.option('--cwd', type=Path, help='Set the working directory for the process')
57
+ @click.option('--stdin', type=str, help='Redirect stdin from this file path')
58
+ @click.option('--stdout', type=str, help='Redirect stdout to this file path')
59
+ @click.option('--stderr', type=str, help='Redirect stderr to this file path')
60
+ @click.option('--cwd', type=str, help='Set the working directory for the process')
61
61
  @click.option('--flags', type=click.INT, default=0, help='Launch flags (bitmask)')
62
62
  @click.option('--stop-at-entry', is_flag=True, help='Stop the process at the entry point')
63
63
  @startup_files_option
hilda/common.py CHANGED
@@ -1,5 +1,14 @@
1
1
  from datetime import datetime
2
2
  from typing import Any, List, Mapping, Tuple, Union
3
3
 
4
+ import inquirer3
5
+ from inquirer3.themes import GreenPassion
6
+
4
7
  CfSerializable = Union[
5
8
  Mapping[str, Any], List, Tuple[Any, ...], str, bool, float, bytes, datetime, None]
9
+
10
+
11
+ def selection_prompt(options_list: List):
12
+ question = [inquirer3.List('choice', message='choose device', choices=options_list, carousel=True)]
13
+ result = inquirer3.prompt(question, theme=GreenPassion(), raise_keyboard_interrupt=True)
14
+ return result['choice']
hilda/exceptions.py CHANGED
@@ -1,7 +1,7 @@
1
1
  __all__ = ['HildaException', 'SymbolAbsentError', 'EvaluatingExpressionError', 'CreatingObjectiveCSymbolError',
2
2
  'ConvertingToNsObjectError', 'ConvertingFromNSObjectError', 'DisableJetsamMemoryChecksError',
3
3
  'GettingObjectiveCClassError', 'AccessingRegisterError', 'AccessingMemoryError',
4
- 'BrokenLocalSymbolsJarError', 'AddingLldbSymbolError', 'LLDBException']
4
+ 'BrokenLocalSymbolsJarError', 'AddingLldbSymbolError', 'LLDBException', 'InvalidThreadIndexError']
5
5
 
6
6
 
7
7
  class HildaException(Exception):
@@ -70,3 +70,8 @@ class BrokenLocalSymbolsJarError(HildaException):
70
70
  class AddingLldbSymbolError(HildaException):
71
71
  """ Raise when failing to convert a LLDB symbol to Hilda's symbol. """
72
72
  pass
73
+
74
+
75
+ class InvalidThreadIndexError(HildaException):
76
+ """ Raise when thread idx invalid """
77
+ pass
hilda/hilda_client.py CHANGED
@@ -30,10 +30,11 @@ from tqdm import tqdm
30
30
  from traitlets.config import Config
31
31
 
32
32
  from hilda import objective_c_class
33
- from hilda.common import CfSerializable
33
+ from hilda.common import CfSerializable, selection_prompt
34
34
  from hilda.exceptions import AccessingMemoryError, AccessingRegisterError, AddingLldbSymbolError, \
35
35
  BrokenLocalSymbolsJarError, ConvertingFromNSObjectError, ConvertingToNsObjectError, CreatingObjectiveCSymbolError, \
36
- DisableJetsamMemoryChecksError, EvaluatingExpressionError, HildaException, SymbolAbsentError
36
+ DisableJetsamMemoryChecksError, EvaluatingExpressionError, HildaException, InvalidThreadIndexError, \
37
+ SymbolAbsentError
37
38
  from hilda.lldb_importer import lldb
38
39
  from hilda.objective_c_symbol import ObjectiveCSymbol
39
40
  from hilda.registers import Registers
@@ -510,7 +511,7 @@ class HildaClient:
510
511
  if options.get('name', False):
511
512
  name = options['name']
512
513
 
513
- log_message = f'🚨 #{bp.id} 0x{symbol:x} {name}'
514
+ log_message = f'🚨 #{bp.id} 0x{symbol:x} {name} - Thread #{self.thread.idx}:{hex(self.thread.id)}'
514
515
 
515
516
  if 'regs' in options:
516
517
  log_message += '\nregs:'
@@ -524,7 +525,7 @@ class HildaClient:
524
525
  value = hilda.symbol(hilda.evaluate_expression(name))
525
526
  log_message += f'\n\t{name} = {hilda._monitor_format_value(fmt, value)}'
526
527
 
527
- if options.get('force_return', False):
528
+ if options.get('force_return', None) is not None:
528
529
  hilda.force_return(options['force_return'])
529
530
  log_message += f'\nforced return: {options["force_return"]}'
530
531
 
@@ -533,7 +534,7 @@ class HildaClient:
533
534
  hilda.finish()
534
535
  hilda.bt()
535
536
 
536
- if options.get('retval', False):
537
+ if options.get('retval', None) is not None:
537
538
  # return from function
538
539
  hilda.finish()
539
540
  value = hilda.evaluate_expression('$arg1')
@@ -880,6 +881,16 @@ class HildaClient:
880
881
  spec.loader.exec_module(m)
881
882
  return m
882
883
 
884
+ def set_selected_thread(self, idx: Optional[int] = None) -> None:
885
+ if idx is None:
886
+ thread = selection_prompt(self.process.threads)
887
+ else:
888
+ try:
889
+ thread = [t for t in self.process.threads if t.idx == idx][0]
890
+ except IndexError:
891
+ raise InvalidThreadIndexError()
892
+ self.process.SetSelectedThread(thread)
893
+
883
894
  def unwind(self) -> bool:
884
895
  """ Unwind the stack (useful when get_evaluation_unwind() == False) """
885
896
  return self.thread.UnwindInnermostExpression().Success()
hilda/launch_lldb.py CHANGED
@@ -70,9 +70,22 @@ class LLDBListenerThread(Thread, ABC):
70
70
  logger.debug(f'Process Exited with status {self.process.GetExitStatus()}')
71
71
  self.should_quit = True
72
72
  elif state == lldb.eStateRunning and last_state == lldb.eStateStopped:
73
- logger.debug("Process Continued")
73
+ logger.debug('Process Continued')
74
74
  elif state == lldb.eStateStopped and last_state == lldb.eStateRunning:
75
75
  logger.debug('Process Stopped')
76
+ for thread in self.process:
77
+ frame = thread.GetFrameAtIndex(0)
78
+ stop_reason = thread.GetStopReason()
79
+ logger.debug(f'tid = {hex(thread.GetThreadID())} pc = {frame.GetPC()}')
80
+ if stop_reason not in [lldb.eStopReasonSignal, lldb.eStopReasonException,
81
+ lldb.eStopReasonBreakpoint,
82
+ lldb.eStopReasonWatchpoint, lldb.eStopReasonPlanComplete,
83
+ lldb.eStopReasonTrace,
84
+ lldb.eStopReasonSignal]:
85
+ continue
86
+ self.process.SetSelectedThread(thread)
87
+ break
88
+
76
89
  last_state = state
77
90
 
78
91
 
@@ -114,7 +127,7 @@ class LLDBAttachName(LLDBListenerThread):
114
127
  return self.debugger.CreateTargetWithFileAndArch(None, None)
115
128
 
116
129
  def _create_process(self) -> lldb.SBProcess:
117
- logger.debug(f'Attaching to {self.name}')
130
+ logger.debug(f'Attaching to {self.proc_name}')
118
131
  return self.target.AttachToProcessWithName(self.listener, self.proc_name, self.wait_for, self.error)
119
132
 
120
133
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hilda
3
- Version: 2.0.1
3
+ Version: 2.0.2
4
4
  Summary: LLDB wrapped and empowered by iPython's features
5
5
  Author-email: doronz88 <doron88@gmail.com>, matan <matan1008@gmail.com>, netanel cohen <netanelc305@protonmail.com>
6
6
  Maintainer-email: doronz88 <doron88@gmail.com>, matan <matan1008@gmail.com>, netanel cohen <netanelc305@protonmail.com>
@@ -51,6 +51,7 @@ Requires-Dist: construct
51
51
  Requires-Dist: pymobiledevice3
52
52
  Requires-Dist: keystone-engine
53
53
  Requires-Dist: tabulate
54
+ Requires-Dist: inquirer3
54
55
  Provides-Extra: test
55
56
  Requires-Dist: pytest ; extra == 'test'
56
57
 
@@ -370,6 +371,10 @@ Here is a gist of methods you can access from `p`:
370
371
  - Import & reload given python module (intended mainly for external snippets)
371
372
  - `unwind`
372
373
  - Unwind the stack (useful when get_evaluation_unwind() == False)
374
+ - `set_selected_thread`
375
+ - sets the currently selected thread, which is used in other parts of the program, such as displaying disassembly or
376
+ checking registers.
377
+ This ensures the application focuses on the specified thread for these operations.
373
378
 
374
379
  ## Magic functions
375
380
 
@@ -3,13 +3,13 @@ gifs/ui.png,sha256=iaRwNZ9qVWUkUe2TJb_6VPsTu--7HrElA2duWiyZ-Oc,131
3
3
  gifs/xpc_print_message.gif,sha256=i5S8Y9bJm9n-NtOipFTAC8_jUR4uZCM4sOap_ccJX0k,939935
4
4
  hilda/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  hilda/__main__.py,sha256=KWRqvukK4wraxCMtvH5nO25mFXLO5aWXa7z_VfAtbO8,90
6
- hilda/_version.py,sha256=llBMh-GtSPemevJ46pFdqzJYvqrJ0mS-b_e99BsAPEQ,411
7
- hilda/cli.py,sha256=0keoM7FLQXiF-J65ftRUtLnYtyyRpGez6xNZ3tZIXZA,3329
8
- hilda/common.py,sha256=fxlVTyRP2AmKCnE6FdgnGJVoG-OBq7Tw6TrBQ_xgszI,194
9
- hilda/exceptions.py,sha256=spH9i27nLm71-SR5Nb028cBVD81qAS6qRfoC2XVoGls,2014
6
+ hilda/_version.py,sha256=ld-j3TUpFlKQqUdd5gCrvB3csNXi_lXdKFr5cuIfSdk,411
7
+ hilda/cli.py,sha256=XCL9vD4zWkK2GHnkeBXZ5AC08iC4rtHYBydgi6SzGJI,3325
8
+ hilda/common.py,sha256=VFtpOH9IRqbu6lONM6Hz-PxcdJfktgS3akJv5UCHO0s,523
9
+ hilda/exceptions.py,sha256=a2EGckJ66ArG2LZJVnUz91gRkqQyc9AEtbS_mfZuI3s,2141
10
10
  hilda/hilda_ascii_art.html,sha256=-9YCjAKdGbjtdd6uoKrxkkcJq7j16r4dGka2bZ27b4o,120119
11
- hilda/hilda_client.py,sha256=TksJu9vdukY5cZQQh0qrY-siwXU3gVYkvEIaMBqQeAs,43486
12
- hilda/launch_lldb.py,sha256=SIBv-uGbp1mgJU96H9gBNU5ahiTwzRwpCiR5RGJ1xVE,7149
11
+ hilda/hilda_client.py,sha256=QQowZuvTu0Z9heGaBmLoKqjRa7BdjezEnkx15Jt-y7Y,43997
12
+ hilda/launch_lldb.py,sha256=OeZjIILxt6lVQdZnD67E2QHfEK2XU_B-HTa5ZI0NTkw,7920
13
13
  hilda/lldb_entrypoint.py,sha256=vTiClzfiTtjorlxEfIsI-W657KEGobx74qDhaZ8nPhM,1007
14
14
  hilda/lldb_importer.py,sha256=LrIQnigDG3wgmIPXya67oBlWubkDgV-rEpzfWNEYCoc,553
15
15
  hilda/objective_c_class.py,sha256=Xyw7FucNVcu8NqhB0Gy-OjaN_2DmCywn6pjUEwyd1Hk,11760
@@ -46,9 +46,9 @@ hilda/snippets/macho/macho_load_commands.py,sha256=OsajG2xWuRwhYhj9f-lnUiNe43Yum
46
46
  hilda/ui/colors.json,sha256=f-ITquY3IInQreviTy23JfmxfJrGM1_MivACf1GKGqM,262
47
47
  hilda/ui/ui_manager.py,sha256=BmzI1sBx0PYCQDlB9Al7wsTEAMJxaJ7NW0DS4C7g5-0,2265
48
48
  hilda/ui/views.py,sha256=1u_eZzw7wAEP1bm_-9nkqgGhMSX__woiUuoBgnsAKVM,7843
49
- hilda-2.0.1.dist-info/LICENSE,sha256=M-LVJ0AFAYB82eueyl8brh-QLPe-iLNVgbCi79-3TDo,1078
50
- hilda-2.0.1.dist-info/METADATA,sha256=BExnYkqJD8IDK4klLR0g5GXN209FCxll3B-G6oMBl60,23606
51
- hilda-2.0.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
52
- hilda-2.0.1.dist-info/entry_points.txt,sha256=9n3O3j6V3XnVR_GcFqCWNgRAbalfukTSW2WvghsLVmA,46
53
- hilda-2.0.1.dist-info/top_level.txt,sha256=TVD7l1WkE1noT866YqPFhiQnjYCYZM5Xz54v_3EYpnI,11
54
- hilda-2.0.1.dist-info/RECORD,,
49
+ hilda-2.0.2.dist-info/LICENSE,sha256=M-LVJ0AFAYB82eueyl8brh-QLPe-iLNVgbCi79-3TDo,1078
50
+ hilda-2.0.2.dist-info/METADATA,sha256=agMwzWcpALitue6mJodwdAa3VHvhvfNdlOAKd3GIukk,23891
51
+ hilda-2.0.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
52
+ hilda-2.0.2.dist-info/entry_points.txt,sha256=9n3O3j6V3XnVR_GcFqCWNgRAbalfukTSW2WvghsLVmA,46
53
+ hilda-2.0.2.dist-info/top_level.txt,sha256=TVD7l1WkE1noT866YqPFhiQnjYCYZM5Xz54v_3EYpnI,11
54
+ hilda-2.0.2.dist-info/RECORD,,
File without changes
File without changes