首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用OpenJ9 Xtrace选项转储方法参数的内容

如何使用OpenJ9 Xtrace选项转储方法参数的内容
EN

Stack Overflow用户
提问于 2019-03-22 08:26:02
回答 1查看 236关注 0票数 3

背景:

我想在Eclipse上记录用户活动,例如,用户克隆了哪些git存储库,何时发生了合并冲突,等等。

我想出了使用OpenJ9 -Xtrace选项。首先,为了测试OpenJ9 -Xtrace选项功能,我使用OpenJ9:创建了以下选项,并将这些选项添加到eclipse.ini以记录克隆的git存储库。

代码语言:javascript
复制
-Xtrace:none,maximal={mt{entry},mt{exit},mt{exception}},methods={org/eclipse/jgit/api/CloneCommand.setURI(),org/eclipse/jgit/api/CloneCommand.call()},output="C:\tmp\mytrace.trc"
-Xjit:exclude={org/eclipse/jgit/api/CloneCommand.setURI*|org/eclipse/jgit/api/CloneCommand.call*}
  • org/eclipse/jgit/api/CloneCommand.setURI()是一种在EGit/JGit中为克隆存储库设置URI的方法。
  • org/eclipse/jgit/api/CloneCommand.call()是克隆指定存储库的方法。

然后,我使用-clean选项启动了Eclipse,克隆了一个存储库,并退出了Eclipse。我用mytrace.trc命令转换了traceformat,并在mytrace.trc.fmt中获得了这个输出

代码语言:javascript
复制
                Trace Formatted Data 

Time (UTC)          Thread ID          Tracepoint ID       Type        Tracepoint Data
07:56:41.541990300 *0x0000000001fafe00 mt.0                Entry      >org/eclipse/jgit/api/CloneCommand.setURI(Ljava/lang/String;)Lorg/eclipse/jgit/api/CloneCommand; bytecode method, this = 0x7f9788a98
07:56:41.541991900  0x0000000001fafe00 mt.6                Exit       <org/eclipse/jgit/api/CloneCommand.setURI(Ljava/lang/String;)Lorg/eclipse/jgit/api/CloneCommand; bytecode method
07:56:41.542010000  0x0000000001fafe00 mt.0                Entry      >org/eclipse/jgit/api/CloneCommand.call()Lorg/eclipse/jgit/api/Git; bytecode method, this = 0x7f9788a98
07:56:46.512616000  0x0000000001fafe00 mt.6                Exit       <org/eclipse/jgit/api/CloneCommand.call()Lorg/eclipse/jgit/api/Git; bytecode method
07:56:47.631399600  0x0000000001fafe00 dg.262              Debug       ***** Thread termination - trace purged *****

这个输出显示setURI()方法有一个参数(Ljava/lang/String;),但是没有JGit克隆的URI。

问题:

如何使用OpenJ9 Xtrace选项转储方法参数的内容?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-06-17 15:52:29

如何使用OpenJ9 Xtrace选项转储方法参数的内容?

您的选项只启用entry、exit和exception方法跟踪跟踪点。方法参数在不同的跟踪点下打印。如果使用这个选项,则应该会看到包含参数的附加跟踪条目。

不过是,虽然原始参数的值显示在跟踪中,但是当参数是一个对象时,您将只看到该对象在Java堆上的地址。例如,当跟踪对*.println()的调用时,您将看到如下所示:

代码语言:javascript
复制
15:31:13.710 0x33acc00              mt.18       - this: java/io/PrintStream@00000000FFF04AE0 method arguments: (java/lang/String@00000000E0002768)

我的理解是,这种限制是由于Xtrace引擎的体系结构以及解析对象(例如storing )并将它们存储在跟踪缓冲区中所带来的性能影响。

虽然地址对于在Java堆中定位感兴趣的对象非常有用,例如,当使用Eclipse内存分析器查看相关的系统转储时,Xtrace无法提供您想要的功能。

另一种方法是使用Java在运行时修改(工具) org/eclipse/jgit/api/CloneCommand类,以便向.setURI()方法中添加日志代码。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55295557

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档