From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id 3C7F419C0029 for ; Tue, 20 Oct 2015 03:23:00 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id F2FD6B5D832 for ; Tue, 20 Oct 2015 03:49:48 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id EA034952439 for ; Tue, 20 Oct 2015 03:49:48 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id AA677120477; Tue, 20 Oct 2015 03:49:46 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id CF47D12041F for ; Tue, 20 Oct 2015 03:49:42 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=jtyQALwozmS78XbhMQsUKtxZqzY=; b=CBBMIHuvBRq4M2o/cC AEEhkm96mGvQJSE2Nxu+Ss3k4JTipkjs3nynvDtfYI6fzC2lTynITZVB9fyzr65X 1jW5aAzBUqIn9TIpY7vmekOL8HxmMBEm2krRH1fBVZhsHRguJmQz1ID6rqfE349W TAVBGWXb+SAf8PYgkQP98LvCA= Received: by filter0819p1mdw1.sendgrid.net with SMTP id filter0819p1mdw1.19772.56253B412F 2015-10-19 18:49:37.254799058 +0000 UTC Received: from herokuapp.com (ec2-54-82-127-134.compute-1.amazonaws.com [54.82.127.134]) by ismtpd0003p1iad1.sendgrid.net (SG) with ESMTP id 92qxGV5DSGGAfD4l0Ur-4w Mon, 19 Oct 2015 18:49:37.147 +0000 (UTC) Date: Mon, 19 Oct 2015 18:49:37 +0000 From: yosy101@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 45744 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11599 X-Redmine-Issue-Author: yosiat X-Redmine-Sender: yosiat 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/Ymy4QrNMhiuLXJG8OTL2vJD1yS4CdcaaYM6SyRGK2F3MtDfaTtsXm1HALlRmYk o0VMOe5b5pEVLq1CCiJpEIpKDC/BOCyS27n04CNDz+l3VmvvU+uVI+K+f4SNTGV/PZ7eW/odg7qzux WhbvT0b5lnPiC4KPq61frCGz0XRhQdy7kbmC X-ML-Name: ruby-core X-Mail-Count: 71119 Subject: [ruby-core:71119] [Ruby trunk - Feature #11599] Dump entries of hash in ObjectSpace 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: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #11599 has been updated by Yosi Attias. File objspace_dump.patch added Yosi Attias wrote: > Nobuyoshi Nakada wrote: > > That distinction makes no sense. > > Non-special-const objects (including `String`) are always shown in pointer reference form. > > That `"0x007f8f3c8baf88"` is the content of a string but not the pointer, then it never appears with your patch. > > Oh.. I understand what you are saying, I will fix that! > Just to make sure I understand your position, you say this distinction is not needed, and in case of this hash: > > ~~~ > > str_key = "Hello world".freeze > hash = {} > hash[:a] = 1 > hash[str_key] = -1 > ~~~ > > You want the result to be: > > ~~~ > > { > "address": "0x007fa3d28c2dc8", > "type": "HASH", > "class": "0x007fa3d30af400", > "size": 2, > "entries": [ > { > "key": ":a", > "value": "0x00000000000003" > }, > { > "key": "\"Hello world\"", > "value": "0xffffffffffffffff" > } > ], > "references": [ > "0x007fa3d28b1230" > ], > "memsize": 232, > "flags": { > "wb_protected": true > } > } > ~~~ > > If so, I have one question: > The addresses of the values - "0x00000000000003" / "0xffffffffffffffff", dosen't exist in the dump result - because we don't dump numerics in the dump, and how I can know what is the dump result? > > Or you want the value logic to be: > 1. If this is special const: write the inspected value of it > 2. If this is not a special const: write it's address Hi, I have added to reflect the new logic: * If the key/value are special consts - I write the "to_s" value of them (:a => "a", 1 => "1") * If the key/value are not special consts - they pointer reference will be written And I have removed the "is_key_address" and "is_value_address" ---------------------------------------- Feature #11599: Dump entries of hash in ObjectSpace https://bugs.ruby-lang.org/issues/11599#change-54487 * Author: Yosi Attias * Status: Open * Priority: Normal * Assignee: ---------------------------------------- Hi, *This is my first c code contribution :)* I am helping developing heap-analyzer (github.com/tenderlove/heap-analyzer), and currently the dumps lacks of "type metadata" information, like: * Hash entries - the keys and value * Array items - the items of the array etc. In the included patch, I have changed the dump of hash to add entries of hash. For example, given the next hash: ~~~ruby hash = { int_key: 1, str_key: "This is my string", inner_hash: { b: 2 } } ~~~ The dump result (ObjectSpace.dump(hash)) will be: ~~~json { "address": "0x007fbc01110340", "type": "HASH", "class": "0x007fbc0109b400", "size": 3, "entries": [ { "is_key_address": false, "key": ":int_key", "is_value_address": false, "value": "1" }, { "is_key_address": false, "key": ":str_key", "is_value_address": true, "value": "0x007fbc01110390" }, { "is_key_address": false, "key": ":inner_hash", "is_value_address": true, "value": "0x007fbc01110368" } ], "references": [ "0x007fbc01110390", "0x007fbc01110368" ], "memsize": 232, "flags": { "wb_protected": true } } ~~~ As you can see, I have the "entries" array, where each entry contains: "is_key_address", "is_value_address" - if the key/value are special consts the inspected value will be printed in the "key"/"value" properties, other their address will be print. Hope you will accept the patch (and I can submit another one for arrays), Yosi. ---Files-------------------------------- objspace_dump_hash_entries.patch (4.8 KB) objspace_dump.patch (4.53 KB) -- https://bugs.ruby-lang.org/