From: ko1@...
Date: 2018-12-10T21:11:57+00:00
Subject: [ruby-core:90410] [Ruby trunk Feature#15287] New TracePoint events to support loading features

Issue #15287 has been updated by ko1 (Koichi Sasada).


Eregon (Benoit Daloze) wrote:
> How about #source_code or #source or #eval_script instead?

I named `eval_script` because we can not get source code other than `*eval` methods (not by `require` and `load`).

> instruction_sequence already implies "compiled" so I think the prefix is not needed there too

We can get ISeq only on `compiled_script` event. `#instruction_sequence` seems too general for me, and for example, I'm afraid that users can misused at `call/return` event (method's ISeq).
This is why I named `raised_exception`, not `exception` (on `raise` event). Not `value` but `returned_value` (on `return` event).

But `instruction_sequence` and `eval_script` (`evaled_script`?) can be enough long to detect specific methods for `script_compiled`.


----------------------------------------
Feature #15287: New TracePoint events to support loading features
https://bugs.ruby-lang.org/issues/15287#change-75559

* Author: ko1 (Koichi Sasada)
* Status: Closed
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Target version: 2.6
----------------------------------------
# Abstract

I propose the following new TracePoint events:

* `loaded` (invoked after `require`/`load`)
* `method_added` (invoked after method definition)

# Background

Sometimes we need to hook loading iseq. For example, checking loading files and so on.
Also we want to know what kind of methods are defined.

For both purpose, we can use some hook methods such as `Module#method_added` and so on.
However, defining methods we can override this features.
So that if we have two tools/libraries using this feature, they can be conflicted.

# Proposal

Introduce new TracePoint events:

* `loaded` (invoked after `require`/`load`)
* `method_added` (invoked after method definition)

Also the following methods can be added:

* Active only `loaded` event:
  * `TracePoint#loaded_feature` returns feature name.
  * `TracePoint#loaded_iseq` returns `RubyVM::InstructionSequence` object (MRI only, internal feature)

# Optional proposal

Add `class_added` alias name for `class` event.




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>