Discussion:
[Rcpp-devel] Debug Rcpp datatypes with lldb
Huelsmann, Till
2018-12-06 13:29:07 UTC
Permalink
Hello,

First of all, I really like Rccp and would like to thank you all for your work.
I try to debug an cpp file, which I source from R, using the lldb debuger.

sourceCpp("source.cpp")

Everything is woking fine, but I dont get how can I show the content of specific datatypes. Like NumericVector or CharackterVector.

E.g.:

(lldb) fr v myvec gives me:

(Rcpp::CharacterVector) myvec= {
Rcpp::PreserveStorage<Rcpp::Vector<4> > = (data = 0x000055555899e970)
cache = {
p = 0x00007fffffffc070
}
}

How it is possible to get the values of the vector in lldb?
I think, that the struct CharacterVector only stores the Memory address of the data.

I have the same problem with NumericVectors, which are stored as double.
If I tried to access them (format as double, 2072 bytes) but I didnŽt get the expected values:

(lldb) memory read –format f 0x000055555899e970
(llldb) memory read -s2072 -fu -c2072 0x000055555899e970 --force


Maybe I have a mistake. I would be very happy if someone could help me.
I've already posted this question on Stackoverflow, but have not received an answer.
See: https://stackoverflow.com/questions/53611600/debug-rcpp-with-lldb

Bests,
Till
Dirk Eddelbuettel
2018-12-06 14:34:01 UTC
Permalink
On 6 December 2018 at 13:29, Huelsmann, Till wrote:
| Hello,
|
| First of all, I really like Rccp and would like to thank you all for your work.

s/Rccp/Rcpp/

Rccp = Russian for USSR

Rcpp = R bindings for C++

A not uncommon typo ...

| I try to debug an cpp file, which I source from R, using the lldb debuger.
|
| sourceCpp("source.cpp")
|
| Everything is woking fine, but I dont get how can I show the content of specific datatypes. Like NumericVector or CharackterVector.
|
| E.g.:
|
| (lldb) fr v myvec gives me:
|
| (Rcpp::CharacterVector) myvec= {
| Rcpp::PreserveStorage<Rcpp::Vector<4> > = (data = 0x000055555899e970)
| cache = {
| p = 0x00007fffffffc070
| }
| }
|
| How it is possible to get the values of the vector in lldb?
| I think, that the struct CharacterVector only stores the Memory address of the data.
|
| I have the same problem with NumericVectors, which are stored as double.
| If I tried to access them (format as double, 2072 bytes) but I didn´t get the expected values:
|
| (lldb) memory read –format f 0x000055555899e970
| (llldb) memory read -s2072 -fu -c2072 0x000055555899e970 --force
|
|
| Maybe I have a mistake. I would be very happy if someone could help me.
| I've already posted this question on Stackoverflow, but have not received an answer.
| See: https://stackoverflow.com/questions/53611600/debug-rcpp-with-lldb

I answered it, and I have nothing more to add. Read "Writing R Extension",
twice or more times as it is dense. It explains a) how to launch a debugger
(and while most of us use gdb it applies equally to lldb) and then b) realize
that everything is a SEXP with is opaque.

Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
Serguei Sokol
2018-12-06 14:41:03 UTC
Permalink
Post by Dirk Eddelbuettel
| Hello,
|
| First of all, I really like Rccp and would like to thank you all for your work.
s/Rccp/Rcpp/
Rccp = Russian for USSR
Did you mean CCCP? ;)

Serguei.
Dirk Eddelbuettel
2018-12-06 14:50:53 UTC
Permalink
On 6 December 2018 at 15:41, Serguei Sokol wrote:
| Le 06/12/2018 à 15:34, Dirk Eddelbuettel a écrit :
| >
| > On 6 December 2018 at 13:29, Huelsmann, Till wrote:
| > | Hello,
| > |
| > | First of all, I really like Rccp and would like to thank you all for your work.
| >
| > s/Rccp/Rcpp/
| >
| > Rccp = Russian for USSR
| Did you mean CCCP? ;)

Yes, oops. Can't even get that right. My bad. But do have vivid memory of
seeing those jerseys on tv at international sports competitions growing up.

Apologies also to Till: I had replied to someone else on SO in the same week
about lldb / debugger use, not him.

The hint about the manual 'Writing R Extensions' still holds. No othr magic
bullet, sadly.

Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
Loading...