1 ##===-- breakwin.py ------------------------------------------*- Python -*-===##
3 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 # See https://llvm.org/LICENSE.txt for license information.
5 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 ##===----------------------------------------------------------------------===##
16 class BreakWin(cui
.ListWin
):
17 def __init__(self
, driver
, x
, y
, w
, h
):
18 super(BreakWin
, self
).__init
__(x
, y
, w
, h
)
23 def handleEvent(self
, event
):
24 if isinstance(event
, lldb
.SBEvent
):
25 if lldb
.SBBreakpoint
.EventIsBreakpointEvent(event
):
27 if isinstance(event
, int):
30 if event
== curses
.ascii
.NL
or event
== curses
.ascii
.SP
:
32 elif event
== curses
.ascii
.TAB
:
33 if self
.getSelected() != -1:
34 target
= self
.driver
.getTarget()
35 if not target
.IsValid():
37 i
= target
.GetBreakpointAtIndex(self
.getSelected()).id
38 self
.showDetails
[i
] = not self
.showDetails
[i
]
40 super(BreakWin
, self
).handleEvent(event
)
42 def toggleSelected(self
):
43 if self
.getSelected() == -1:
45 target
= self
.driver
.getTarget()
46 if not target
.IsValid():
48 bp
= target
.GetBreakpointAtIndex(self
.getSelected())
49 bp
.SetEnabled(not bp
.IsEnabled())
51 def deleteSelected(self
):
52 if self
.getSelected() == -1:
54 target
= self
.driver
.getTarget()
55 if not target
.IsValid():
57 bp
= target
.GetBreakpointAtIndex(self
.getSelected())
58 target
.BreakpointDelete(bp
.id)
61 target
= self
.driver
.getTarget()
62 if not target
.IsValid():
64 self
.win
.noutrefresh()
66 selected
= self
.getSelected()
68 for i
in range(0, target
.GetNumBreakpoints()):
69 bp
= target
.GetBreakpointAtIndex(i
)
72 text
= lldbutil
.get_description(bp
)
73 # FIXME: Use an API for this, not parsing the description.
74 match
= re
.search("SBBreakpoint: id = ([^,]+), (.*)", text
)
77 desc
= match
.group(2).strip()
79 text
= "%s: %s" % (id, desc
)
81 text
= "%s: (disabled) %s" % (id, desc
)
82 except ValueError as e
:
86 if self
.showDetails
.setdefault(bp
.id, False):
88 desc
= lldbutil
.get_description(
89 location
, lldb
.eDescriptionLevelFull
93 self
.setSelected(selected
)