Tuesday, December 30, 2014
Wednesday, November 26, 2014
Thursday, November 20, 2014
Friday, October 31, 2014
Q
Chinese proverb, ''Leader is best when people barely know he exists."
Gem of Java: BTrace; Debugging production code on the fly
But the question is now how do u debug? Generally the loggers we kept are in-sufficient or in production they disabled debug, info levels of log4j; now how? or say we forgot logging a variable.. now how to debug the issue?
wouldnt it be nice if i have an agent sitting outside the main JVM and printing out the variable i wanted? is it possible? the answer is YES!!!
BTrace is the gem in Java-s Crown. So it works like this
- The original JVM runs on some PID
- The Btrace program runs outside and connects to this pid; printing ur variable as u wanted
package my; import services.reports.ReportContext; import com.insideview.industryProfiles.IndustryProfile; import com.insideview.industryProfiles.IndustrySic; import com.sun.btrace.BTraceUtils; import com.sun.btrace.annotations.BTrace; import com.sun.btrace.annotations.Kind; import com.sun.btrace.annotations.Location; import com.sun.btrace.annotations.OnMethod; import com.sun.btrace.annotations.Return; @BTrace(unsafe=true) public class Tracer { @OnMethod( clazz="services.reports.company.CompanyIndustryProfile", method="appendSection", location=@Location(Kind.RETURN)) public static void operate(@Return ReportContext rc ){ IndustryProfile industryProfile = (IndustryProfile) (rc.get("industryProfile")); BTraceUtils.printFields(industryProfile); BTraceUtils.println(); IndustrySic sic = industryProfile.getSic(); BTraceUtils.printFields(sic); } }
In the dowloaded package, open the btrace file located in bin folder and in the end change to the below. The line is to the end of the file
-Dcom.sun.btrace.debug=true
[jboss@iv build]$ ../bin/btrace -cp "btrace-agent.jar:btrace-boot.jar:btrace-client.jar:velocity-1.7-dep.jar:company.jar" 26009 Tracer.java
DEBUG: btrace debug mode is set DEBUG: btrace unsafe mode is set DEBUG: accepting classpath btrace-agent.jar:btrace-boot.jar:btrace-client.jar:velocity-1.7-dep.jar:commpany.jar DEBUG: assuming default port 2020 DEBUG: compiling Tracer.java DEBUG: compiled Tracer.java DEBUG: attaching to 8995 DEBUG: checking port availability: 2020 DEBUG: attached to 8995 DEBUG: loading /tmp/btrace/build/btrace-agent.jar DEBUG: agent args: port=2020,debug=true,unsafe=true,systemClassPath=/usr/jdk1.6.0_29/lib/tools.jar,probeDescPath=. DEBUG: loaded /tmp/btrace/build/btrace-agent.jar DEBUG: registering shutdown hook DEBUG: registering signal handler for SIGINT DEBUG: submitting the BTrace program DEBUG: opening socket to 2020 DEBUG: sending instrument command DEBUG: entering into command loop DEBUG: received com.sun.btrace.comm.OkayCommand@566711b0 DEBUG: received com.sun.btrace.comm.RetransformationStartNotification@8ba6621 DEBUG: received com.sun.btrace.comm.OkayCommand@5870501 DEBUG: received com.sun.btrace.comm.MessageCommand@2e2b5ba8 {industryDescription=null, industryId=564,abc=xyx,etc=etc], sizeStructureDescription=etc_etc} DEBUG: received com.sun.btrace.comm.MessageCommand@26284112 DEBUG: received com.sun.btrace.comm.MessageCommand@1cc81850 $$$$$$$$$$$DEBUG: received com.sun.btrace.comm.MessageCommand@14b43af3 {id=7375, description=CBI Services, }
Issues to lookout
- If u havent changed btrace file, ran the above process and then modifed the unsafe to true on running the btrace u see VerificationError.
- As said here it happens because the 1st run made the target JVM to mark any unsafe to false
- for this u will have to restart the target m/c
Tuesday, October 28, 2014
Monday, October 27, 2014
Fxing: Blogspot redirecting to neo-counter
Very recently i discovered my blog getting redircted to neo-counter webpage on opening it.
This was disgusting; The is what i had done to get rid of this redirect
This was disgusting; The is what i had done to get rid of this redirect
- opened and logged into http://blogspot.com
- select ur blog, go to ur layout
- now see if u have neo-counter in ur gadgets and remove it; thats it!
Neo-counter used to give the stats on how many pple visited my website from a given country. NOt sure why its redirecting me to their site; however with these steps i could get rid of it.
Now save and load ur blogger page. Happy blogging
Wednesday, July 30, 2014
Friday, July 25, 2014
Thursday, July 24, 2014
Sunday, May 18, 2014
Wednesday, May 7, 2014
Friday, March 28, 2014
Sunday, March 23, 2014
Friday, March 7, 2014
Sunday, February 9, 2014
Sunday, January 26, 2014
Friday, January 24, 2014
Q
All birds find shelter during a rain. But Eagle aviods rain by flying above the Clouds. Problems are common, but attitude makes the difference!!
Thursday, January 23, 2014
Subscribe to:
Posts (Atom)