From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19383 invoked by alias); 31 May 2007 22:48:13 -0000 Received: (qmail 19310 invoked by uid 22791); 31 May 2007 22:48:12 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 31 May 2007 22:48:03 +0000 Received: (qmail 3954 invoked from network); 31 May 2007 22:48:01 -0000 Received: from unknown (HELO localhost) (jimb@127.0.0.2) by mail.codesourcery.com with ESMTPA; 31 May 2007 22:48:01 -0000 To: "Ray Bejjani" Cc: gdb@sourceware.org Subject: Re: Turning off printing of char pointer contents References: From: Jim Blandy Date: Thu, 31 May 2007 22:48:00 -0000 In-Reply-To: (Ray Bejjani's message of "Thu, 31 May 2007 15:38:12 -0700") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-05/txt/msg00188.txt.bz2 "Ray Bejjani" writes: > I'm trying to turn off printing the contents of char pointers. I'm use > GDB to debug an embedded app remotely. In some instances the pointers > are left uninitialised and can point to sections of memory that cause > system crashes when accessed (or they cause external hardware to > change state when read). I am using DDD on top of GDB but I can > reproduce the issue with GDB as well. GDB seems to treat C strings in > a special manner, attempting to print the contents until it sees an > null terminator or hit the limit set by the "print elements" setting. > My system crashes when this happens. > Unfortunately, doing a set print elements 0 is interpreted as no > limit. Are there any other settings I can use to suppress this > feature? In particular, I would like it to treat char (or unsigned > char) pointers like it does other pointers where it doesn't attempt to > dereference them. I would still like to be able to display/print the > contents of strings when needed but only on demand. Failing that, > where in the code should I look to try and force this to not happen? Have you looked at "Memory region attributes" in the GDB manual? You can define memory regions, and then use 'set mem inaccessible-by-default' to tell GDB not to touch memory regions you haven't defined.