é対話çããã㬠YouDebug
ãã°ä¿®æ£ã¯ããã°ã©ãã®ä»äºã®ä¸ã¤ã§ããããã®ãã¡ã®ããªãã®æéã¯åé¡ãåç¾ãããã¨ã«è²»ãããã¾ãã
çç¶ãããã°ã®å
¨å®¹ãæ¨å¯ã§ããæãããã®ã§ãããå¤ãã®å ´åã«ã¯ãæå
ã§åé¡ãåç¾ããæ´ãªããã¼ã¿ãéãããã¨ã«ãã£ã¦å§ãã¦ãã°ãç解ãããããã§ããããããç°å¢ã«ä¾åããåé¡ãªã©ã¯åç¾ãé£ããå ´åãããã¾ããã©ããããããã§ããããã
ãã®ã³ã°ã¨ããã®ãããè¡ããã解決ã»äºé²çã§ãããããããã¬ãèµ°ããã¦å¤æ°xã®å¤ãæãã¦ãããã°ããã®ã«ï¼ãã¨æã£ãäºãããã®ã¯ç§ã ãã§ã¯ãªãã¨æãã¾ãããã®ã³ã°ã¨ç°ãªãããããã¬ã¯äºãããã°ã©ã ã«é害çºçãäºæããã³ã¼ããåãè¾¼ãã§ããå¿ è¦ã¯ããã¾ãããã¾ããå¼ã³åºãå ã®ãã¼ã«ã«å¤æ°ãã¢ã¯ã»ã¹ããããä»»æã®å¼ãè©ä¾¡ãããããããã¯å¤æ°ã®å¤ãå¤æ´ãããã¨ãã§ãã¦ãã¾ãã¾ããå½ããåã§ãããé害åæãã¼ã«ã¨ãã¦ã¯ãããã¬ã¯ãã£ã¨å¼·åã ããã§ãã
ã§ã¯ãªãã¦ã¼ã¶ã¼ããããã¬ã使ããªããã¨ããã¨ãããããã¾ãã«é£ããããã§ããããã§ããã®åé¡ã解決ããããã«ãYouDebugãéçºãã¾ããã
YouDebugã¯ãããã¬ã§ããã¨åæã«ãããã¬ã§ã¯ããã¾ãããYouDebugã¯ãJava Platform Debug Architectureä¸ã«ä½ããã¦ããã®ã§ãä»ã®ããã»ã¹ã«ã¢ã¿ããããããå¤æ°ãåç §ããããã¬ã¼ã¯ãã¤ã³ããè¨å®ãããã¨ããããã¬ãã§ããå ¨ã¦ã®äºãã§ãã¾ãããããã£ãæå³ã§ã¯ãYouDebugã¯ãããã¬ã§ãã
ããããYouDebugã«ã¯å¯¾è©±æ§ããªããã½ã¼ã¹ã³ã¼ããå¿ è¦ããã¾ãããããã°ã©ããGUIã¨ãã¦ã¹ã使ã£ã¦é§åãããããã«ãYouDebugã¯DSLã©ã¤ã¯ãªGroovyã¹ã¯ãªããã使ã£ã¦é§åããã¾ããããã«ãã£ã¦ãããã°ã©ã ã«é¢ããç¥èãæã¡ã¹ã¯ãªãããæ¸ã人ã¨ãããã°ã©ã ã«é¢ããç¥èãæããã¹ã¯ãªãããèµ°ããã人ã¨ã®åæ¥ãå¯è½ã«ãªãããã§ããã¾ããGroovyã使ããã¨ã§ãã¹ã¯ãªããã®è¨è¿°ãç°¡æ½ã«ãã¤ã¤ããJavaããã°ã©ãã«éåæãªã使ã£ã¦ããããããã«ãªã£ã¦ããã¨æãã¾ãã
ä¾ãã°ã次ã®ããã°ã©ã ãè¦ã¦ã¿ã¾ãããã
public class SubStringTest {
public static void main(String[] args) {
String s = someLengthComputationOfString();
System.out.println(s.substring(5));
}private static String someLengthComputationOfString() {
...;
}
}
ã¦ã¼ã¶ã¼ã®ä¸äººãããã®ããã°ã©ã ãStringIndexOutOfRangeExceptionã§æ»ãã§ããã¨å ±åãã¦ãã¾ãã:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1949)
at java.lang.String.substring(String.java:1916)
at com.acme.SubStringTest.main(SubStringTest.java:7)
s.substring(5)ãåãã¦ããªããã ãªã¨ããäºã¯ãããã¾ãããã§ã¯å¤æ°sã¯ä½ãæãã¦ããã®ã§ããããï¼ããã調ã¹ãããã«ãï¼è¡ç®ã«ãã¬ã¼ã¯ãã¤ã³ããã»ãããã¦sã表示ãã¾ãããã
breakpoint("com.acme.SubStringTest",7) {
println "s="+s;
}
ã¦ã¼ã¶ã¼ã¯ãã¾ãããã°ã©ã ã次ã®ããã«èµ°ããã¾ã
$ java -agentlib:jdwp=transport=dt_socket,server=y,address=5005 com.acme.SubStringTest
Listening for transport dt_socket at address: 5005
次ã«ãYouDebugã次ã®ããã«èµ°ããã¾ããYouDebugã¯å¯¾è±¡ã®ããã»ã¹ã«ã¢ã¿ããããsã®å¤ã表示ããã¾ãã
$ java -jar youdebug.jar -socket 5005 SubStringMonitor.ydb
s=test
YouDebugã®æ©è½ã®è©³ç´°ã«ã¤ãã¦ã¯ã¦ã¼ã¶ã¼ã¬ã¤ããåç §ãã¦ãã ããããã¦ã³ãã¼ãã¯ãã¡ããã½ã¼ã¹ã³ã¼ãã¯ãã¡ãã§ãã
追è¨
http://d.hatena.ne.jp/masanobuimai/20091109#1257769475 ã§ãææé ãããã°ãä¿®æ£ãã¦1.2ãå ¬éãã¾ãããè¥å¹²ã®éäºæã®å¤æ´ãå«ã¾ãã¦ãã¾ããä¸è¨ã®ãã¦ã³ãã¼ããªã³ã¯ã¯1.2ããã¦ã³ãã¼ããã¾ãã