Line numbers in stack traces
Richard A. O'Keefe
ok@REDACTED
Wed Aug 10 03:09:45 CEST 2005
Informed that
The [Erlang] virtual machine has no information about line numbers.
David Hopwood <david.nospam.hopwood@REDACTED> asked
Isn't that a design limitation of the virtual machine code format?
I think language VMs should be designed to allow this at least in a
debugging mode.
There are a number of assumptions hidden here:
(1) all VM code comes from source code
(2) all source code is hand-written
(3) therefore all VM code *has* line numbers
which it is simply incompetent of the VM not to retain.
(4) the relationship between source lines and VM code is easy to maintain.
Since Erlang/OTP provides several ways to generate and manipulate source
code, (1) and (2) are false. Even in C, macros place serious limits on
the utility of line numbers: a single "function call" in a line may
expand to hundreds of tokens which cannot be stepped into, and the line
where the error *is* may be in a completely different file from the
reported line. Erlang macros are regrettably similar to C macros.
Then we mustn't forget things like YECC and code generators like ASN.1
(see 'asn1') and CORBA interfaces (see 'ic').
While this is not yet a major consideration for Erlang, consider the
fact that compilers for functional programming languages tend to do
*major* restructuring, starting with in-line expansion, simplification,
reordering, and progressing to things like deforestation (which is
certainly applicable to Erlang). The practical consequence of this is
that a few bytes of code (BEAM or other VM or HiPE-generated native
code) may contain bits of many different functions, so that line number
information would overwhelm actual useful code.
I'd rather see a QuickCheck for Erlang; is there one?
More information about the erlang-questions
mailing list