This is the mail archive of the
mailing list for the GDB project.
Re: basic gdb usage question
On Monday 25 June 2007 21:12, Eli Zaretskii wrote:
> > From: Matt Funk <firstname.lastname@example.org>
> > Date: Mon, 25 Jun 2007 17:08:34 -0600
> > I am just starting to use gdb and so have a lot to learn.
> > So i want to set the breakpoint in file A at line M under condition X.
> > However, another condition that needs to be met before breaking is in
> > file B with condition Y.
> > condition X: the value of a local variable is (say) 2.
> > condition Y: the value of a variable is (say) 3.
> > Is this possible to set multiple conditions for one breakpoint?
> A condition could be complex: var1 == 2 && var2 == 3. Would that do
> the job?
> > I thought
> > about setting two breakpoints but that would not do what i need it to do.
> Why not? You could set the second breakpoint from the commands
> defined for the first breakpoint. Would this do what you want?
Not sure what you mean by 'setting a breakpoint from the commands
defined for the first breakpoint' to be honest. Can you point me to somewhere
in the docs where it mentions how to do this?
> > Along the same lines, is it then possible to create a condition that
> > references a variable outside the local scope?
> AFAIK, only if it has global scope in its file. You can use the
> FILE:VARIABLE syntax.
Ah, ok. So it is not possible to reference a member of class A while being in
a method of class B? Also, it doesn't seem to allow me to reference a public
member of class A in a method of class A. Should it, or am I simply being
ignorant about something?
> Btw, I'd be eager to know which ones of the answers above cannot be
> found in the user's manual. That will help us improve the docs.
Well, i didn't see the links to the expressions section the first time around.
Sorry. However, it still didn't help. I'm still curious why the command :
(gdb) break myfile_1.cpp:70 if ('myfile_1.cpp'::myvar == 4)
Junk at the end of arguments
Regardless of whether i am in the right scope or not, this error messages
seems to me to say that my syntax is crap. But I thought that the expression
in the parenthesis is the file:variable syntax that is also in the docs in
the Expressions section and which is permissable?
A way to improve the docs would be to give many (and diverse) examples of how
to set breakpoints. Maybe ranging from very simple to pretty complex
Anyway, thanks for all the help and work though.