From: costin_c <costin.cosoveanu@gmail.com>
To: gdb@sourceware.org
Subject: break on a external source file
Date: Fri, 21 Sep 2007 22:39:00 -0000 [thread overview]
Message-ID: <dadde8860709211521p3a25b22do719acd23b463c4b7@mail.gmail.com> (raw)
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.
next reply other threads:[~2007-09-21 22:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-21 22:39 costin_c [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dadde8860709211521p3a25b22do719acd23b463c4b7@mail.gmail.com \
--to=costin.cosoveanu@gmail.com \
--cc=gdb@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox