The api sets the red background only in the asm view, how i could also make it be visible in the pseudo code view? As seen in the picture line 267 isn’t getting colored.
I experimented a bit and it turned out that the format string must be $%X (uppercase).
import idaapi
def add_breakpoint(ea, lnnum):
"""
Adds a breakpoint at the specified address and line number.
:param ea: The address where the breakpoint should be set.
:param lnnum: The line number in the source code where the breakpoint should be set.
"""
fnc: idaapi.func_t = idaapi.get_func(ea)
if not fnc:
print("Function not found at address 0x%X" % ea)
return
b = idaapi.bpt_t()
# the line breakpoint is set at the start of the function
b.set_src_bpt("$%X" % fnc.start_ea, lnnum)
idaapi.add_bpt(b)
ea = idaapi.get_screen_ea()
lnnum = 8
add_breakpoint(ea, lnnum)