Skip to content

Commit

Permalink
hilda_client: Set breakpoint on selected thread
Browse files Browse the repository at this point in the history
  • Loading branch information
netanelc305 committed Jun 6, 2024
1 parent 9a1ea54 commit ad8cb4d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions hilda/hilda_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@
from pathlib import Path
from typing import Any, Callable, List, Optional, Union

import hexdump
import IPython
import hexdump
from IPython.core.magic import register_line_magic # noqa: F401
from humanfriendly import prompts
from humanfriendly.terminal.html import html_to_ansi
from IPython.core.magic import register_line_magic # noqa: F401
from pygments import highlight
from pygments.formatters import TerminalTrueColorFormatter
from pygments.lexers import XmlLexer
Expand Down Expand Up @@ -524,7 +524,7 @@ def callback(hilda, frame, bp_loc, options):
value = hilda.symbol(hilda.evaluate_expression(name))
log_message += f'\n\t{name} = {hilda._monitor_format_value(fmt, value)}'

if options.get('force_return', False):
if options.get('force_return', None) is not None:
hilda.force_return(options['force_return'])
log_message += f'\nforced return: {options["force_return"]}'

Expand All @@ -533,7 +533,7 @@ def callback(hilda, frame, bp_loc, options):
hilda.finish()
hilda.bt()

if options.get('retval', False):
if options.get('retval', None) is not None:
# return from function
hilda.finish()
value = hilda.evaluate_expression('$arg1')
Expand Down Expand Up @@ -638,11 +638,13 @@ def bp(self, address_or_name: Union[int, str], callback: Optional[Callable] = No
for bp_id, bp in breakpoints:
if address_or_name == bp.address:
self.remove_hilda_breakpoint(bp_id)

thread_id = self.process.GetSelectedThread().GetThreadID()
if isinstance(address_or_name, int):
bp = self.target.BreakpointCreateByAddress(address_or_name)

elif isinstance(address_or_name, str):
bp = self.target.BreakpointCreateByName(address_or_name)
bp.SetThreadID(thread_id)

if condition is not None:
bp.SetCondition(condition)
Expand Down

0 comments on commit ad8cb4d

Please sign in to comment.