This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
conditional breakpoints for strings
- From: Anitha Boyapati <anithab at sankhya dot com>
- To: gdb at sourceware dot org
- Date: Wed, 24 Oct 2007 12:27:38 +0530 (IST)
- Subject: conditional breakpoints for strings
Hi,
Here's a sample program in C++ being debugged in GDB. It tries to stop if
string matches "hello" in a breakpoint. Now I am getting a segmentation
fault. But the same works fine for numerical comparisions(the code is
slightly changed as int i = 10 and a conditional BP is set if i==10). Is
this a bug or did I do something wrong ?
gdb --version
GNU gdb Red Hat Linux (5.3.90-0.20030710.40rh)
This GDB was configured as "i386-redhat-linux-gnu".
-----------------------------------------------------
(gdb) li
1 #include <iostream>
2
3 using namespace std;
4
5 int main() {
6 string s("hello");
7 return 1;
8 }
(gdb) b hello.cc:7
Breakpoint 1 at 0x80486b0: file hello.cc, line 7.
(gdb) condition 1 ( s == "hello" )
(gdb) r
Starting program: /home/anithab/util/hello
Segmentation fault
--
Regards,
Anitha B
@S A N K H Y A