LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 05: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 05:17 PM.
 
Old 07-12-2009, 07: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, 02:52 PM   #3
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
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, 12: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, 01:32 PM   #5
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,784

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
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



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 09:29 AM
Debugging with gdb & kdevelop, trying to display array of cvmlib CocoFr Programming 0 06-12-2008 11:16 AM
KDevelop and debugging aikempshall Programming 11 12-05-2005 09:13 AM
Visual Debugging and Linux Kernel Debugging Igor007 Programming 0 09-30-2005 10:33 AM
is *- -p = '\n' valid? can i set \n char to a pointer? feetyouwell Programming 1 10-01-2004 01:09 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:26 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration