LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-11-2009, 06:15 PM   #1
onufry
LQ Newbie
 
Registered: Jul 2005
Posts: 10

Rep: Reputation: 0
kdevelop, debugging - how to set a valid condition for a watchpoint?


Hello,

I have a problem with debugging in kdevelop. I'm unable to set valid condition in the watchpoints condition field (the bottom breakpoint section). I tried everything that seemed sane to me:
a > 10.
(a > 10.)
if(a > 10.)
if a > 10.

'a' is the variable I have watchpoint for.

And as result I got all possible stops for any change of the variable in question.

I would be grateful for any help.
Onufry

Last edited by onufry; 07-11-2009 at 06:17 PM.
 
Old 07-12-2009, 08:30 AM   #2
onufry
LQ Newbie
 
Registered: Jul 2005
Posts: 10

Original Poster
Rep: Reputation: 0
ok - got sth working "around".

I put some code like:

Code:
if(a>10.){
//printf or sth done with 'a' so the compiler doesn't optimize by cuting out if statement
//line brakepoint
}


maybe this "watch for change" idea is completly wrong for floats. I tried in gdb (in the corect scoope):

Code:
awatch a 
cond 1 a>10.0
And it did not work. I got 'hit' every time even before 'a' made past 10.

Best regards,
Onufry
 
Old 07-12-2009, 03:52 PM   #3
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 2,517

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
It looks like gdb ignores conditions on watchpoints. I think this could be a bug given the following paragraph from the gdb manual:
Quote:
Conditions are also accepted for watchpoints; you may not need them, since a watchpoint is inspecting the value of an expression anyhow--but it might be simpler, say, to just set a watchpoint on a variable name, and specify a condition that tests whether the new value is an interesting one.
You can use commands to simulate a condition:
Code:
commands <watchpoint number>
 silent
 if a > 10
  printf "hit watchpoint\na = %f\n", a
 else
  continue
 end
end
 
Old 07-17-2009, 01:54 PM   #4
onufry
LQ Newbie
 
Registered: Jul 2005
Posts: 10

Original Poster
Rep: Reputation: 0
The solution with "commands" did not do anything at all (it only switched off printing "sth changed to a" in gdb) . I think there may be two problems:
1. sth is wrong with gdb (I am using gdb-6.8-r1)
or
2. I do sth horribly wrong somewhere else while debugging - for example: while setting a breakpoint ;]

the crude solution i used in the first place (by putting additional code inside the program) somehow worked - i have done what i had to do.

But thanks anyway.

Best regards,
onufry
 
Old 07-17-2009, 02:32 PM   #5
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian
Posts: 2,517

Rep: Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856Reputation: 856
Quote:
1. sth is wrong with gdb (I am using gdb-6.8-r1)
Code:
$ gdb --version
GNU gdb 6.8-debian
I'd be surprised if that's the problem.

Anyways I thought of another workaround: you can do
Code:
 watch (a > 10)? a : 0
Basically have the watched expression not change unless the condition is true.
 
  


Reply

Tags
debugging, kdevelop


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Effective debugging or improving ones debugging skills Ajit Gunge Programming 3 05-22-2009 10:29 AM
Debugging with gdb & kdevelop, trying to display array of cvmlib CocoFr Programming 0 06-12-2008 12:16 PM
KDevelop and debugging aikempshall Programming 11 12-05-2005 10:13 AM
Visual Debugging and Linux Kernel Debugging Igor007 Programming 0 09-30-2005 11:33 AM
is *- -p = '\n' valid? can i set \n char to a pointer? feetyouwell Programming 1 10-01-2004 02:09 AM


All times are GMT -5. The time now is 03:25 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration