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? Thanks, Gang Liang
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
2008/5/6 pseudo <gumpleon at gmail.com>: [...]> 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.Have you tried: p Rf_PrintValue(colNames) from the gdb prompt? A. -- Antonio, Fabio Di Narzo Ph.D. student at Department of Statistical Sciences University of Bologna, Italy
On Tue, May 6, 2008 at 5:23 AM, Antonio, Fabio Di Narzo <antonio.fabio at gmail.com> wrote:> 2008/5/6 pseudo <gumpleon at gmail.com>: > [...] > > > 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. > Have you tried: > p Rf_PrintValue(colNames) > from the gdb prompt? >Yes, I also tried "p Rf_PrintValue(colNames)", the outcome is the same. I can step in the r-base-core and what I found is that the "isObject" returns false.> A. > -- > Antonio, Fabio Di Narzo > Ph.D. student at > Department of Statistical Sciences > University of Bologna, Italy >