From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 2E818211B3 for ; Wed, 5 Dec 2018 07:24:11 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 7D5CE120BD9; Wed, 5 Dec 2018 16:24:08 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 1B261120DE1 for ; Wed, 5 Dec 2018 16:24:05 +0900 (JST) Received: by filter0090p3iad2.sendgrid.net with SMTP id filter0090p3iad2-26856-5C077D12-11 2018-12-05 07:24:02.334454609 +0000 UTC m=+132284.887527104 Received: from herokuapp.com (ec2-54-147-211-227.compute-1.amazonaws.com [54.147.211.227]) by ismtpd0039p1iad2.sendgrid.net (SG) with ESMTP id G0mBEGbDRm2g3gBD7ddW1Q for ; Wed, 05 Dec 2018 07:24:02.266 +0000 (UTC) Date: Wed, 05 Dec 2018 07:24:03 +0000 (UTC) From: ko1@atdot.net To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 65695 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 15287 X-Redmine-Issue-Author: ko1 X-Redmine-Issue-Assignee: ko1 X-Redmine-Sender: ko1 X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS5xBzB6J93GnlcSm85aXYdHDqO1PRJhOf/85V 2apuvS9ANPJS9VRbwbm5dY45Tbt8NxupbO8f2/sQuHSyZjN/aIRBLaPrnPnZUEekqNLstbqiI4bT6E U4WqCNHnLecnMjIU8iLav4PQUVtnEk1SWXDj X-ML-Name: ruby-core X-Mail-Count: 90302 Subject: [ruby-core:90302] [Ruby trunk Feature#15287] New TracePoint events to support loading features X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #15287 has been updated by ko1 (Koichi Sasada). Matz agreed about naming of "script_compiled". If others especially English natives have ideas, please tell me. If no, I'll commit "script_compiled" event some days later. ---- I'm reconsidering "method_added" event because there are several other points we change the class/module methods. We already has several hooks provided by method hook: ```C rb_define_private_method(rb_cClass, "inherited", rb_obj_dummy, 1); rb_define_private_method(rb_cModule, "included", rb_obj_dummy, 1); rb_define_private_method(rb_cModule, "extended", rb_obj_dummy, 1); rb_define_private_method(rb_cModule, "prepended", rb_obj_dummy, 1); rb_define_private_method(rb_cModule, "method_added", rb_obj_dummy, 1); rb_define_private_method(rb_cModule, "method_removed", rb_obj_dummy, 1); rb_define_private_method(rb_cModule, "method_undefined", rb_obj_dummy, 1); ``` Maybe other events we want to introduce. But (this is internal reason) we don't have enough bits to represent them. There are several ideas: * (1) add all events above (change internal) * (2) add one event (`extended`, for example) and add new method to recognize which kind of extension Ruby did (for example, `tp.extension_type #=> :undef`) Maybe we have no time to conclude this spec so I think it is difficult to introduce this feature (method_added) in Ruby 2.6. ---------------------------------------- Feature #15287: New TracePoint events to support loading features https://bugs.ruby-lang.org/issues/15287#change-75409 * Author: ko1 (Koichi Sasada) * Status: Open * 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/