Yasumasa, > Can we use VLA (Variable Length Arrays) ?
Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn) Target: x86_64-apple-darwin14.5.0 Thread model: posix Compiles it just fine. -Dmitry On 2016-01-18 16:09, Yasumasa Suenaga wrote: > Hi Dmitry, > >> 1. It might be better to have one jcmd to run both java and native java >> agent. If agent library name ends with ".jar" we can assume it's java >> agent. > > Okay, I'll try it. > >> if (_libpath.value() == NULL) { >> error ... >> } > > I will add it. > However, I note you that _libpath is given mandatory flag. > http://mail.openjdk.java.net/pipermail/serviceability-dev/2016-January/018661.html > > >> char options[option_len]; > > Can we use VLA (Variable Length Arrays) ? > I'm worried that several C++ compiler cannot compile this code. > http://clang.llvm.org/compatibility.html#vla > > > Thanks, > > Yasumasa > > > On 2016/01/18 19:38, Dmitry Samersoff wrote: >> Yasumasa, >> >> 1. It might be better to have one jcmd to run both java and native java >> agent. If agent library name ends with ".jar" we can assume it's java >> agent. >> >> 2. Please get rid of malloc/free and check _libpath.value() for NULL at >> ll. 295 and below. >> >> >> if (_libpath.value() == NULL) { >> error ... >> } >> >> if (_option.value() == NULL) { >> JvmtiExport::load_agent_library("instrument", >> "false", _libpath.value(), output()); >> return; >> } >> >> size_t option_len = \ >> strlen(_libpath.value()) + strlen(_option.value()) + 1; >> >> char options[option_len]; >> >> .... >> >> -Dmitry >> >> >> On 2016-01-15 16:33, Yasumasa Suenaga wrote: >>> Hi, >>> >>> I added permissions and tests in new webrev: >>> http://cr.openjdk.java.net/~ysuenaga/JDK-8147388/webrev.01/ >>> >>> Two tests (LoadAgentDcmdTest, LoadJavaAgentDcmdTest) work fine. >>> >>> >>> Thanks, >>> >>> Yasumasa >>> >>> >>> On 2016/01/15 17:20, Staffan Larsen wrote: >>>> This is a good improvement overall. >>>> >>>> The new diagnostic commands need to have proper permissions set: >>>> >>>> static const JavaPermission permission() { >>>> JavaPermission p = >>>> {"java.lang.management.ManagementPermission", >>>> “control", NULL}; >>>> return p; >>>> } >>>> >>>> And as David said: tests! See hotspot/test/serviceability/dcmd/jvmti. >>>> >>>> Thanks, >>>> /Staffan >>>> >>>>> On 14 jan. 2016, at 15:00, Yasumasa Suenaga <yasue...@gmail.com> >>>>> wrote: >>>>> >>>>> Hi all, >>>>> >>>>> We can use Attach API to attach JVMTI agent to live process. >>>>> However, we have to write Java code for it. >>>>> >>>>> If we can attach JVMTI agents through jcmd, it is very useful. >>>>> So I want to add two new diagnostic commands: >>>>> >>>>> * JVMTI.agent_load: Load JVMTI native agent. >>>>> * JVMTI.javaagent_load: Load JVMTI java agent. >>>>> >>>>> I maintain two JVMTI agents - HeapStats [1] and JLivePatcher [2]. >>>>> [1] is native agent, [2] is java agent. >>>>> They provide a program for attaching to live process. >>>>> >>>>> I guess that various JVMTI agents provide own attach mechanism like >>>>> them. >>>>> I think that we should provide general way to attach. >>>>> >>>>> I've uploaded webrev. Could you review it? >>>>> http://cr.openjdk.java.net/~ysuenaga/JDK-8147388/webrev.00/ >>>>> >>>>> I'm jdk9 committer, however I cannot access JPRT. >>>>> So I need a sponsor. >>>>> >>>>> >>>>> Thanks, >>>>> >>>>> Yasumasa >>>>> >>>>> >>>>> [1] http://icedtea.classpath.org/wiki/HeapStats >>>>> [2] https://github.com/YaSuenag/jlivepatcher (in Japanese) >>>> >> >> -- Dmitry Samersoff Oracle Java development team, Saint Petersburg, Russia * I would love to change the world, but they won't give me the sources.