@@ -192,6 +192,38 @@ def test_breakpoint(self):
192192 self .assertEqual (dbg .ip , entry )
193193 dbg .quit_and_wait ()
194194
195+ def test_breakpoint_condition (self ):
196+ fpath = name_to_fpath ('helloworld' , self .arch )
197+ bv = load (fpath )
198+ dbg = DebuggerController (bv )
199+ self .assertNotIn (dbg .launch_and_wait (), [DebugStopReason .ProcessExited , DebugStopReason .InternalError ])
200+
201+ entry = dbg .data .entry_point
202+ dbg .add_breakpoint (entry )
203+
204+ arch_name = bv .arch .name
205+ if arch_name == 'x86' :
206+ reg1 , reg2 = '$eax' , '$ebx'
207+ elif arch_name == 'x86_64' :
208+ reg1 , reg2 = '$rax' , '$rbx'
209+ else :
210+ reg1 , reg2 = '$x0' , '$x1'
211+
212+ cond1 = f"{ reg1 } == 0x1234"
213+ self .assertTrue (dbg .set_breakpoint_condition (entry , cond1 ))
214+ self .assertEqual (dbg .get_breakpoint_condition (entry ), cond1 )
215+
216+ cond2 = f"{ reg2 } != 0"
217+ self .assertTrue (dbg .set_breakpoint_condition (entry , cond2 ))
218+ self .assertEqual (dbg .get_breakpoint_condition (entry ), cond2 )
219+
220+ self .assertTrue (dbg .set_breakpoint_condition (entry , "" ))
221+ self .assertEqual (dbg .get_breakpoint_condition (entry ), "" )
222+
223+ self .assertFalse (dbg .set_breakpoint_condition (0x12345678 , f"{ reg1 } == 0" ))
224+ self .assertEqual (dbg .get_breakpoint_condition (0x12345678 ), "" )
225+ dbg .quit_and_wait ()
226+
195227 def test_register_read_write (self ):
196228 fpath = name_to_fpath ('helloworld' , self .arch )
197229 bv = load (fpath )
0 commit comments