Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling in debug mode should turn on caml_record_backtrace by default #5855

Open
vicuna opened this Issue Dec 14, 2012 · 9 comments

Comments

Projects
None yet
2 participants
@vicuna
Copy link
Collaborator

vicuna commented Dec 14, 2012

Original bug ID: 5855
Reporter: thelema
Assigned to: @mshinwell
Status: assigned (set by @mshinwell on 2016-12-08T09:59:32Z)
Resolution: open
Priority: normal
Severity: feature
Version: 4.00.1
Category: runtime system and C interface
Related to: #6728
Monitored by: @chambart

Bug description

At the moment, the OCAMLRUNPARAM=b and compiling in debug mode with '-g' are orthogonal. Is there any reason that programs compiled with '-g' shouldn't have 'b' enabled by default?

Steps to reproduce

Compile a program with -g and set OCAMLRUNPARAM="", and see the lack of backtraces.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Dec 14, 2012

Comment author: @ygrek

-g adds debug information which can be useful without wasting time recording backtraces of all exceptions, e.g. for sampling profiling.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Feb 10, 2013

Comment author: @gasche

I came to submit the exact same feature wish, which has been suggested to me by a programmer unfamiliar with OCaml, which was surprised -g did not activate stack printing by default. Given the documentation of the -g flag, this is a reasonable expectation:

-g Record debugging information for exception backtrace

As ygrek says, there are other uses of -g that don't need or want the corresponding overhead, but I think we should make the common case the simpler to use, and let expert with other use cases use OCAMLRUNPARAM="b=0".

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Feb 11, 2013

Comment author: @chambart

Something like that would improve a lot average bug report when classical users are not necessarily familiar with
OCaml and you can't expect user to come back providing more informations. This kind of situation is common on
linux distribution bug trackers.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Feb 11, 2013

Comment author: @gasche

(Eating a previous suggestion about treating unhandled exceptions differently from the others. Indeed, with dynamically filtering exception handlers, it's impossible to know which exceptions will be handled by the stack of existing handlers without executing them, at which point the stack is already discarded unless b=1.)

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Jun 19, 2013

Comment author: @damiendoligez

What is the best way to implement this?

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Jun 20, 2013

Comment author: @ygrek

I am against this behavior change. When this gets implemented suddenly all -g enabled libraries experience a performance hit. Running with OCAMLRUNPARAM=b=0 is not an option, how do you expect this to happen - wrap every program start in shell script? OCaml is different from other languages wrt exceptions, so it is not unreasonable to expect another behavior of -g. The arguments like "same feature wish, which has been suggested to me by a programmer unfamiliar with OCaml" are not valid, programmers unfamiliar with OCaml will find many strange things to complain about - polymorphic variants, labeled arguments (just had to deal with this one today), etc, etc - it is not a valid reason to change anything. OCaml is different, starting with syntax - because it has some objective reasons behind this decisions. The cost of printing backtrace is different - that's why it is not enabled by default. Why should we adopt the practice from other systems where it has totally different performance cost? If this is getting to be implemented I am strongly for another option, -gg or whatever, not changing the semantics of current option.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Jun 20, 2013

Comment author: @jhjourdan

One solution could be to activate it only when linking the final executable with -g...

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Dec 16, 2013

Comment author: @damiendoligez

I'd rather add a new option -gg than introduce a subtle difference in -g used for compiling or linking.

@vicuna

This comment has been minimized.

Copy link
Collaborator Author

vicuna commented Dec 8, 2016

Comment author: @mshinwell

Compile-time flags for debugging-related options will need revising in the light of the GDB work that will hopefully be merged in time for 4.05. We could consider having this kind of backtrace control as one of those options, perhaps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.