From: "Chun, Eric Y" <eric.y.chun@intel.com>
To: "gdb@sourceware.org" <gdb@sourceware.org>
Subject: Conditional Breakpoints with Pointers
Date: Mon, 04 May 2015 21:12:00 -0000 [thread overview]
Message-ID: <64E3233B30622847B1E5ED56D2C1DBF00CACDC9F@FMSMSX108.amr.corp.intel.com> (raw)
in gdb, how do i set a conditional breakpoint depending on value of pointer keeping in mind that i have to check if pointer is null before dereferencing pointer?
here is an example of code i'm trying to debug:
#include <iostream>
using namespace std;
int main () {
int *i[10];
int *j = NULL;
int k;
i[4] = new int;
*i[4] = 8;
for (k=0; k < 10; k++) {
j = i[k];
}
return 0;
}
i set conditional breakpoint at line "j=i[k]" but i got a seg fault:
(gdb) b 14 if j && *j == 8
(gdb) r
Starting program: /nfs/blahblah/a.out
Failed to read a valid object file image from memory.
Program received signal SIGSEGV, Segmentation fault.
does anybody know why there is a segfault?
next reply other threads:[~2015-05-04 21:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-04 21:12 Chun, Eric Y [this message]
2015-05-04 21:48 ` Philippe Waroquiers
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=64E3233B30622847B1E5ED56D2C1DBF00CACDC9F@FMSMSX108.amr.corp.intel.com \
--to=eric.y.chun@intel.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