* break on a external source file
@ 2007-09-21 22:39 costin_c
2007-09-22 1:10 ` Daniel Jacobowitz
0 siblings, 1 reply; 6+ messages in thread
From: costin_c @ 2007-09-21 22:39 UTC (permalink / raw)
To: gdb
How can I tell to gdb to put a breakpoint on a given line in C++
source file, located in directory situated other than current one ?
$cat -n main.cc
1 #include <dir/print.h>
2 int
3 main(int argc, char **argv)
4 {
5 Print P(100);
6 P.print();
7 return 0;
8 }
$ cat -n dir/print.h
1 #ifndef PRINT_H
2
3 class Print
4 {
5 private:
6 int val;
7 public:
8 Print(int v);
9 void print();
10 };
11
12 #endif
$ cat -n dir/print.cc
1 #include <print.h>
2 #include <iostream>
3
4 Print::Print(int v)
5 {
6 val=v+v;
7 };
8
9 void Print::print()
10 {
11 std::cout<<val<<std::endl;
12 }
g++ -g -I. -Idir dir/print.cc main.cc -o print
gdb print
(gdb) break dir/print.cc:6
Breakpoint 1 at 0x8048637: file dir/print.cc, line 6.
(gdb) break main.cc:6
Breakpoint 2 at 0x804871c: file main.cc, line 6.
(gdb)
(gdb) info break
Num Type Disp Enb Address What
1 breakpoint keep y 0x08048637 in Print at dir/print.cc:6
2 breakpoint keep y 0x0804871c in main at main.cc:6
breakpoint already hit 1 time
(gdb) run
Starting program: /home/user/print
Failed to read a valid object file image from memory.
Breakpoint 2, main () at main.cc:6
6 P.print();
(gdb) cont
Continuing.
200
Program exited normally.
In dir/print.cc:6 program is not interrupted by break, only at
breakpoint from main.cc:6.
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: break on a external source file
2007-09-21 22:39 break on a external source file costin_c
@ 2007-09-22 1:10 ` Daniel Jacobowitz
2007-09-22 13:52 ` costin_c
2007-09-22 15:37 ` Claus Baumgartner
0 siblings, 2 replies; 6+ messages in thread
From: Daniel Jacobowitz @ 2007-09-22 1:10 UTC (permalink / raw)
To: costin_c; +Cc: gdb
On Sat, Sep 22, 2007 at 01:21:31AM +0300, costin_c wrote:
> How can I tell to gdb to put a breakpoint on a given line in C++
> source file, located in directory situated other than current one ?
You're doing it right. The problem doesn't have to do with that, but
with this:
> 4 Print::Print(int v)
> 5 {
> 6 val=v+v;
> 7 };
That's a constructor. This is a known bug in GDB, for which Vladimir
Prus has recently posted patches.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: break on a external source file
2007-09-22 1:10 ` Daniel Jacobowitz
@ 2007-09-22 13:52 ` costin_c
2007-09-22 14:08 ` Daniel Jacobowitz
2007-09-22 15:37 ` Claus Baumgartner
1 sibling, 1 reply; 6+ messages in thread
From: costin_c @ 2007-09-22 13:52 UTC (permalink / raw)
To: costin_c, gdb
On 9/22/07, Daniel Jacobowitz <drow@false.org> wrote:
> On Sat, Sep 22, 2007 at 01:21:31AM +0300, costin_c wrote:
> > How can I tell to gdb to put a breakpoint on a given line in C++
> > source file, located in directory situated other than current one ?
>
> You're doing it right. The problem doesn't have to do with that, but
> with this:
> > 4 Print::Print(int v)
> > 5 {
> > 6 val=v+v;
> > 7 };
>
> That's a constructor. This is a known bug in GDB, for which Vladimir
> Prus has recently posted patches.
>
For line 11 form Print::print() in works fine
9 void Print::print()
10 {
11 std::cout<<val<<std::endl;
12 }
break dir/print.cc:11
Breakpoint 1 at 0x80486d0: file dir/print.cc, line 11.
(gdb) info break
Num Type Disp Enb Address What
1 breakpoint keep y 0x080486d0 in Print::print() at dir/print.cc:11
(gdb) r
Starting program: /home/user/print
Failed to read a valid object file image from memory.
Breakpoint 1, Print::print (this=0xbfb2c340) at dir/print.cc:11
11 std::cout<<val<<std::endl;
(gdb) n
200
12 }
(gdb) n
main () at main.cc:7
7 return 0;
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: break on a external source file
2007-09-22 1:10 ` Daniel Jacobowitz
2007-09-22 13:52 ` costin_c
@ 2007-09-22 15:37 ` Claus Baumgartner
2007-09-23 2:36 ` Daniel Jacobowitz
1 sibling, 1 reply; 6+ messages in thread
From: Claus Baumgartner @ 2007-09-22 15:37 UTC (permalink / raw)
To: gdb
Daniel Jacobowitz wrote:
> On Sat, Sep 22, 2007 at 01:21:31AM +0300, costin_c wrote:
>> How can I tell to gdb to put a breakpoint on a given line in C++
>> source file, located in directory situated other than current one ?
>
> You're doing it right. The problem doesn't have to do with that, but
> with this:
>> 4 Print::Print(int v)
>> 5 {
>> 6 val=v+v;
>> 7 };
>
> That's a constructor. This is a known bug in GDB, for which Vladimir
> Prus has recently posted patches.
>
Hi,
Are these patches already committed?
BR,
Claus
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-09-22 15:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-21 22:39 break on a external source file costin_c
2007-09-22 1:10 ` Daniel Jacobowitz
2007-09-22 13:52 ` costin_c
2007-09-22 14:08 ` Daniel Jacobowitz
2007-09-22 15:37 ` Claus Baumgartner
2007-09-23 2:36 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox