OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Apr 16, 2024 10:57 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Bochs debugger new feature: conditional breakpoint
PostPosted: Sat Jun 03, 2017 1:20 pm 
Offline
Member
Member

Joined: Fri Apr 04, 2008 6:43 am
Posts: 357
Hi,

I just merged new experimental feature to Bochs debugger you might find interesting.
The feature is ‘conditional continue’ and the syntax is:

> continue if <expression>

The continue will happen ONLY when expression is evaluated as TRUE.
For this reason new operators >, <, >=, <=, ==, != were added to the expression evaluation.
So now you could set a breakpoint in the beginning of function and write rc script which looks like:

Set breakpoint
- c ; reach bp
- c if rax < 10 ; actually it turns bp to conditional, do nothing if condition is false
- c if rax < 10 ; actually it turns bp to conditional, do nothing if condition is false
- c if rax < 10 ; actually it turns bp to conditional, do nothing if condition is false
- c if rax < 10 ; actually it turns bp to conditional, do nothing if condition is false
- c if rax < 10 ; actually it turns bp to conditional, do nothing if condition is false
- c if rax < 10 ; actually it turns bp to conditional, do nothing if condition is false
- c if rax < 10 ; actually it turns bp to conditional, do nothing if condition is false
- c if rax < 10 ; actually it turns bp to conditional, do nothing if condition is false
… how many false steps are expected ?
At the end you stopped on right break point!

Collecting comments about the extension and ways to improve it, probably apply to other Bochs commands

Thanks,
Stanislav


Last edited by stlw on Tue Aug 22, 2017 1:02 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Bochs debugger new feature: conditional continue
PostPosted: Sat Jun 03, 2017 1:32 pm 
Offline
Member
Member

Joined: Thu Jul 05, 2007 8:58 am
Posts: 223
I think a feature like this would be more useful if you could associate it with a specific breakpoint, both so you don't have to type it n times in a script, and also so that it is more useful when doing non-script-assisted debugging. Kind of like how the gdb cond command works. This also solves the problem that these expressions could get quite large if you have multiple breakpoints, and want some subset of them to have conditions.


Top
 Profile  
 
 Post subject: Re: Bochs debugger new feature: conditional continue
PostPosted: Sat Jun 03, 2017 1:42 pm 
Offline
Member
Member

Joined: Fri Apr 04, 2008 6:43 am
Posts: 357
davidv1992 wrote:
I think a feature like this would be more useful if you could associate it with a specific breakpoint, both so you don't have to type it n times in a script, and also so that it is more useful when doing non-script-assisted debugging. Kind of like how the gdb cond command works. This also solves the problem that these expressions could get quite large if you have multiple breakpoints, and want some subset of them to have conditions.


Yes, this would be next step.
I am still thinking how to hack this into the debugger.
Probably I will have to remember condition as a string together with breakpoint and in case of breakpoint hit 'throw in' into parser the condition and see how it is resolved.
And ignore breakpoint hit if condition is false ...
But for now it is much more complicated for me so I added smth which was trivial to add and can have immediate added value


Top
 Profile  
 
 Post subject: NEW: Bochs debugger new feature: conditional breakpoint
PostPosted: Tue Aug 22, 2017 12:53 pm 
Offline
Member
Member

Joined: Fri Apr 04, 2008 6:43 am
Posts: 357
I implemented conditional breakpoint support in Bochs debugger.
the operation is very simple: when setting instruction breakpoint you also could supply
Code:
lbreak address if "expression"

and the breakpoint will be triggered only if expression is true.
arbitrary expression can be accepted like: EAX > 100 & ECX < 10

Please test and reply if there any problems you may see.

Stanislav


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 757 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group