public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* GDB for R?
@ 2018-11-29  2:45 Andrew Hoerner
  2018-11-29 14:32 ` Joel Brobecker
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Hoerner @ 2018-11-29  2:45 UTC (permalink / raw)
  To: gdb

Dear Folks--

I would very much like to know if there is any appreciable probability that
there will be a GDB debugger for the R language in a time frame of months
to single-digit years. I’d also like to know if there is pretty clearly no
such probability.

It seems clear to me that GDB is vastly more powerful than any R debugging
facility in widespread use.

I do not believe that there is anyone in the R community currently working
on this, and I have asked in several places. Still, I don’t know anything
at all about nearly all R projects currently under development. I have
found instances and tutorials on using GDB on C and C++ code, functions,
and libraries that are incorporated into or called by R, which I believe
suggests the possibility of substantial interest and uptake, though this
might be reduced by the relatively small proportion of R users who are
professional programmers.

The draft 2nd edition of Hadley Wickham’s Advanced R, Chapter 20 on
debugging, states “The worst scenario is that your code might crash R
completely, leaving you with no way to interactively debug your code. This
indicates a bug in the underlying C code. This is hard to debug. Sometimes
an interactive debugger, like gdb, can be useful, but describing how to use
it is beyond the scope of this book."

Warmest regards, Andrew Hoerner

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GDB for R?
  2018-11-29  2:45 GDB for R? Andrew Hoerner
@ 2018-11-29 14:32 ` Joel Brobecker
  2018-11-29 14:41   ` Pedro Alves
  0 siblings, 1 reply; 5+ messages in thread
From: Joel Brobecker @ 2018-11-29 14:32 UTC (permalink / raw)
  To: Andrew Hoerner; +Cc: gdb

Hi Andrew,

> I would very much like to know if there is any appreciable probability that
> there will be a GDB debugger for the R language in a time frame of months
> to single-digit years. I’d also like to know if there is pretty clearly no
> such probability.

To the best of my knowledge, I haven't heard any rumours about adding
R support to GDB. But maybe others have heard something?

-- 
Joel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GDB for R?
  2018-11-29 14:32 ` Joel Brobecker
@ 2018-11-29 14:41   ` Pedro Alves
  2018-11-30  1:22     ` Andrew Hoerner
  2018-12-01  4:09     ` GDB for R? Some info on current use of GDB with R Andrew Hoerner
  0 siblings, 2 replies; 5+ messages in thread
From: Pedro Alves @ 2018-11-29 14:41 UTC (permalink / raw)
  To: Joel Brobecker, Andrew Hoerner; +Cc: gdb

On 11/29/2018 02:32 PM, Joel Brobecker wrote:
> Hi Andrew,
> 
>> I would very much like to know if there is any appreciable probability that
>> there will be a GDB debugger for the R language in a time frame of months
>> to single-digit years. I’d also like to know if there is pretty clearly no
>> such probability.
> 
> To the best of my knowledge, I haven't heard any rumours about adding
> R support to GDB. But maybe others have heard something?

I haven't either.

I don't know much about how R works.  E.g., does it compile down to native
code?  Or to some byte code that is JIT compiled at run time?  Or is
it fully interpreted?

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GDB for R?
  2018-11-29 14:41   ` Pedro Alves
@ 2018-11-30  1:22     ` Andrew Hoerner
  2018-12-01  4:09     ` GDB for R? Some info on current use of GDB with R Andrew Hoerner
  1 sibling, 0 replies; 5+ messages in thread
From: Andrew Hoerner @ 2018-11-30  1:22 UTC (permalink / raw)
  To: palves; +Cc: brobecker, gdb

With respect to the inner workings of R I am far from being an expert,
but here is my understanding and a few links.

The vast majority of core R functions are themselves written either in
C or in R, so all the code is in some sense C at the base. But the
vast majority of R users never deal with the C-level code, even when
debugging.

Core R code has been byte-compiled since 2011. In early 2017, (R
3.4.0) R got a JIT compiler (applied primarily to functions and loops)
in R code run interactively or through scripts, usually with no
intervention on the part of the user. Under older versions of R, and
also still for code the JIT algorithm doesn't like, R code is parsed
and the parse tree run by an AST interpreter. This is still true, but
more and more code is run under the byte compiler. The byte compiler
itself is written almost entirely in R
.
Formerly, package authors had the option of byte-compiling their
package when installed. As of R 3.5.0, released in April of this year,
all R packages are byte-compiled . The dominant languages for package
code are R and C++, in that order, but among the 13,000 or so
contributed packages you will find a bit of everything.

Although most R code is now run as byte code, R's debugging facilities
are all entirely based on the AST, bypassing the byte-code.

A description of the byte compiler is here:
homepage.cs.uiowa.edu/~luke/R/compiler/compiler.pdf

A nice overview of the language: strengths, weaknesses, peculiarities.
http://r.cs.purdue.edu/pub/ecoop12.pdf

R manuals are here: https://cran.r-project.org/
Click the "Manuals" link at the left-hand edge under Documentation. I
suspect that the most useful for your purposes will be either "The R
Language Definition" or "R Internals."

Warmest regards, Andrew

On Thu, Nov 29, 2018 at 9:41 AM Pedro Alves <palves@redhat.com> wrote:
>
> On 11/29/2018 02:32 PM, Joel Brobecker wrote:
> > Hi Andrew,
> >
> >> I would very much like to know if there is any appreciable probability that
> >> there will be a GDB debugger for the R language in a time frame of months
> >> to single-digit years. I’d also like to know if there is pretty clearly no
> >> such probability.
> >
> > To the best of my knowledge, I haven't heard any rumours about adding
> > R support to GDB. But maybe others have heard something?
>
> I haven't either.
>
> I don't know much about how R works.  E.g., does it compile down to native
> code?  Or to some byte code that is JIT compiled at run time?  Or is
> it fully interpreted?
>
> Thanks,
> Pedro Alves

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: GDB for R? Some info on current use of GDB with R
  2018-11-29 14:41   ` Pedro Alves
  2018-11-30  1:22     ` Andrew Hoerner
@ 2018-12-01  4:09     ` Andrew Hoerner
  1 sibling, 0 replies; 5+ messages in thread
From: Andrew Hoerner @ 2018-12-01  4:09 UTC (permalink / raw)
  To: palves; +Cc: Joel Brobecker, gdb

There is actually a fairly extensive discussion of GDB in the R Manual
"Writing R Extensions" (available at
https://cran.r-project.org/doc/manuals/), all in section 4 on
debugging. A lot of this discussion is over my head, but I think it is
mainly about debugging compiled code or non-R code called by R. At
least, no discussion of R debugging features I have ever seen before
mentions use of GDB as an option. So I suppose I should make clear
that my inquiry is about using GDB for debugging R code, not
"connected to R" code.

All of the references to GDB are under either subhead 4.3, "Checking
memory access," or section 4.4, "Debugging compiled code."
Here are the subject headings that contain explicit references to GDB:
4.3.2 Using valgrind
4.3.3 Using the Address Sanitizer
4.3.4 Using the Undefined Behaviour Sanitizer
4.4    Debugging compiled code
4.4.1 Finding entry points in dynamically loaded code
4.4.2 Inspecting R objects when debugging
On Thu, Nov 29, 2018 at 9:41 AM Pedro Alves <palves@redhat.com> wrote:
>
> On 11/29/2018 02:32 PM, Joel Brobecker wrote:
> > Hi Andrew,
> >
> >> I would very much like to know if there is any appreciable probability that
> >> there will be a GDB debugger for the R language in a time frame of months
> >> to single-digit years. I’d also like to know if there is pretty clearly no
> >> such probability.
> >
> > To the best of my knowledge, I haven't heard any rumours about adding
> > R support to GDB. But maybe others have heard something?
>
> I haven't either.
>
> I don't know much about how R works.  E.g., does it compile down to native
> code?  Or to some byte code that is JIT compiled at run time?  Or is
> it fully interpreted?
>
> Thanks,
> Pedro Alves

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-12-01  4:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-29  2:45 GDB for R? Andrew Hoerner
2018-11-29 14:32 ` Joel Brobecker
2018-11-29 14:41   ` Pedro Alves
2018-11-30  1:22     ` Andrew Hoerner
2018-12-01  4:09     ` GDB for R? Some info on current use of GDB with R Andrew Hoerner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).