From ripley at stats.ox.ac.uk  Tue May  6 15:00:10 2008
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Tue, 6 May 2008 14:00:10 +0100 (BST)
Subject: [Rd] a R_PV problem
In-Reply-To: <48201AE8.2060501@stats.uwo.ca>
References: <bc33365a0805060002w316d0c92mf2598adfd076ef07@mail.gmail.com>
	<48201AE8.2060501@stats.uwo.ca>
Message-ID: <alpine.LFD.1.10.0805061347010.20354@gannet.stats.ox.ac.uk>

>From the C code:

/* Ditto, but only for objects, for use in debugging */

so R_PV only prints for 'objects' (that is those with an S3 class, and if 
properly formed, those with an S4 class).  I doubt a set of names has a 
class: to print those, use Rf_PrintValue.

I am not sure why one would want to confine attention to 'objects', but 
the code has been that way 'for ever' (8 years).

On Tue, 6 May 2008, Duncan Murdoch wrote:

> On 06/05/2008 3:02 AM, pseudo wrote:
>> Dear all,
>> 
>> When using gdb to debug my C code, I use R_PV to show the content of
>> SEXP variables:
>>
>>   SEXP sexp; // it is a data.frame
>>   SEXP colNames = getAttrib(sexp, R_NameSymbol);
>> 
>> A strange thing is that after halting the program:
>>
>>   (gdb) p R_PV(colNames)
>> 
>> does not show the content of colNames. I am positive my code is right
>> because if I insert "PrintValue(colNames);" in the c code, it will
>> print the right value. My debug result shows that the variable
>> "colNames" failed the "isObject" call. I am not sure whether this is a
>> new feature or bug. Anyone can help?
>
> Are you sure that getAttrib has been called?  Depending on the optimization 
> level under which your code was compiled, instructions may be re-ordered. 
> gdb may show the instruction pointer after that line, even though that line 
> hasn't been run yet.
>
> Duncan Murdoch
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] a R_PV problem
Prof Brian Ripley