偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

詳解C語(yǔ)言動(dòng)態(tài)跟蹤工具ProbeVue如何調(diào)試Java應(yīng)用程序

開發(fā) 后端
在AIX 6.1中引入的ProbeVue是一個(gè)動(dòng)態(tài)跟蹤工具。本文詳解C語(yǔ)言動(dòng)態(tài)跟蹤工具ProbeVue如何調(diào)試Java應(yīng)用程序,解釋探測(cè)幾種Java函數(shù)的語(yǔ)言語(yǔ)法以及訪問(wèn)函數(shù)參數(shù)的方法。還討論編寫Vue腳本的要點(diǎn)和限制。

在51CTO的Unix操作系統(tǒng)開發(fā)中我們介紹過(guò)AIX6 的安全新特性。 AIX 6.1 中引入的 ProbeVue 是一個(gè)動(dòng)態(tài)跟蹤工具。它最初的設(shè)計(jì)目的是動(dòng)態(tài)地跟蹤 C 應(yīng)用程序和系統(tǒng)中的系統(tǒng)調(diào)用。隨著時(shí)間的推移,它現(xiàn)在支持調(diào)試Java應(yīng)用程序,還支持獲取實(shí)時(shí)轉(zhuǎn)儲(chǔ)和基本系統(tǒng)調(diào)用。本文討論 ProbeVue 對(duì) Java 的支持。

ProbeVue 具有以下特性:

◆跟蹤鉤子不需要作為源代碼的組成部分預(yù)先編譯。

◆ProbeVue 適用于 32/64 位內(nèi)核和應(yīng)用程序,不需要做任何修改。

◆在通過(guò) ProbeVue 放置跟蹤鉤子之前,它們并不存在。

◆可以立即查看跟蹤活動(dòng)捕捉的跟蹤數(shù)據(jù),可以作為終端輸出顯示它們,或者保存到文件中供以后查看。

◆跟蹤鉤子可以應(yīng)用于任何函數(shù)的入口或出口(當(dāng)前對(duì)于系統(tǒng)調(diào)用只支持出口探測(cè)點(diǎn))。

◆當(dāng)探測(cè)類型為入口時(shí),可以探測(cè)傳遞給函數(shù)的參數(shù),這要求在 Vue 腳本的開頭或通過(guò)頭文件定義函數(shù)原型。

◆通過(guò)在出口點(diǎn)應(yīng)用跟蹤鉤子并指定函數(shù)原型,可以探測(cè)函數(shù)的退出/返回值。

◆可以使用 ProbeVue 進(jìn)行性能分析和問(wèn)題調(diào)試。

使用 ProbeVue 的前提條件

◆AIX V6.10 和更高版本

◆文件集:不需要特殊的文件集,基本操作系統(tǒng)附帶所需的文件集。

◆在嘗試探測(cè)之前需要啟用 ProbeVue 特性,可以使用 SMIT 啟用它。

Vue 腳本語(yǔ)法

◆探測(cè) Java 函數(shù)

  1. @@uftjava:PID:*:"fully qualified function name":entry  

◆探測(cè) Java 庫(kù)例程:與 Java 函數(shù)相同。

命令語(yǔ)法

單獨(dú)啟動(dòng) Java 應(yīng)用程序和 ProbeVue

◆Java 應(yīng)用程序

  1. 對(duì)于 32 位:java -agentlib:probevuejava <additional parameters> myjavaapp  
  2. 對(duì)于 64 位:java -agentlib:probevuejava64 <additional parameters> myjavaapp  
  3.  

◆ProbeVue

  1. ProbeVue <additional arguments> myscript.e <script arguments> 
  2.  

作為 ProbeVue 的子進(jìn)程啟動(dòng) Java 應(yīng)用程序

◆對(duì)于 32 位:probevue -X <path of java> -A "-agentlib:probevuejava <additional parameters> my javaapp" myscript.e

◆對(duì)于 64 位:probevue -X <path of java> -A "-agentlib:probevuejava64 <additional parameters> my javaapp" myscript.e

基本探測(cè)示例

基本探測(cè)示例:myjava.java

  1. import java.lang.reflect.*;  
  2. import java.util.*;  
  3. import java.lang.*;  
  4.  
  5. class myclass1  
  6. {  
  7.         int i;  
  8.         float f;  
  9.         double d;  
  10.         boolean b;  
  11.         String s;  
  12.         public myclass1(int j)  
  13.         {  
  14.                 i=j;  
  15.         }  
  16.         public void set_i(int j)  
  17.                 {  
  18.                         i=j;  
  19.                 }  
  20.         public void set_f(float j)  
  21.                 {  
  22.                         f=j;  
  23.                 }  
  24.         public void set_d(double j)  
  25.                 {  
  26.                         d=j;  
  27.                 }  
  28.         public void set_b(boolean j)  
  29.                 {  
  30.                         b=j;  
  31.                 }  
  32.         public void set_s(String j)  
  33.                 {  
  34.                         s=j;  
  35.                 }  
  36.         public  void print_i()  
  37.                 {  
  38.                         System.out.println("Value of Integer i:"+i);  
  39.                         System.out.println("Value of Float f:"+f);  
  40.                         System.out.println("Value of Double d:"+d);  
  41.                         System.out.println("Value of Boolean b:"+b);  
  42.                         System.out.println("Value of String s:"+s);  
  43.                 }  
  44. }  
  45. public class myjava  
  46. {  
  47.         public static void main(String args[]) throws java.lang.InterruptedException  
  48.         {  
  49.                 Thread.sleep(60);  
  50.                 System.out.println("In main");  
  51.                 myclass1 MC1=new myclass1(20);  
  52.                 MC1.set_i(10);  
  53.                 MC1.set_f((float)10.03);  
  54.                 MC1.set_d(10.1123);  
  55.                 MC1.set_b(false);  
  56.                 MC1.set_s("ProbeVue");  
  57.                 MC1.print_i();  
  58.                 int [] int1;  
  59.                 int1 = new int[10];  
  60.                 for(int i=0;i<10;i++)  
  61.                 Array.set(int1,i,(int)i);  
  62.                 for(int i=0;i<10;i++)  
  63.                 {  
  64.                         System.out.println(Array.getInt(int1,i));  
  65.                  }  
  66.  
  67.  
  68.         }  
  69. }  
  70.  

執(zhí)行基本探測(cè)的 Vue 腳本:basic_probing.e

  1. @@BEGIN  
  2. {  
  3. // Declare and Initialize the variable to track the number of calls made   
  4. // to Array.set function  
  5.         int Number_Of_Calls_Of_Array_set;  
  6.         Number_Of_Calls_Of_Array_set=0;  
  7. }  
  8. //Probe String to trace the calls to function myclass1.set_d  
  9. @@uftjava:$__CPID:*:"myclass1.set_d":entry  
  10. {  
  11. //Printing the message for user notification that this function has been called  
  12. //By adding ProbeVue tag to message we can easily filter out the ProbeVue messages only.  
  13.         printf("ProbeVue - Entered  myclass1.set_d function \n");  
  14. }  
  15. @@uftjava:$__CPID:*:"myclass1.set_f":entry  
  16. {  
  17.         printf("ProbeVue - Entered  myclass1.set_f function \n");  
  18. }  
  19. @@uftjava:$__CPID:*:"myclass1.set_i":entry  
  20. {  
  21.         printf("ProbeVue - Entered  myclass1.set_i function \n");  
  22. }  
  23. @@uftjava:$__CPID:*:"myclass1.set_s":entry  
  24. {  
  25.         printf("ProbeVue - Entered  myclass1.set_s function \n");  
  26. }  
  27. @@uftjava:$__CPID:*:"myclass1.set_b":entry  
  28. {  
  29.         printf("ProbeVue - Entered  myclass1.set_b function \n");  
  30. }  
  31. @@uftjava:$__CPID:*:"myjava.main":entry  
  32. {  
  33.         printf("ProbeVue - Entered myjava.main function \n");  
  34. // Printing the Process Id and Parent Process Id  
  35.         printf("       Process Id : %ld\n",__pid);  
  36.         printf("Parent Process Id : %ld\n",__ppid);  
  37. }  
  38. @@uftjava:$__CPID:*:"java.lang.reflect.Array.set":entry  
  39. {  
  40.         printf("ProbeVue - Entered java.lang.reflect.Array.set function \n");  
  41. // Increment the count whenever the function is called  
  42.         Number_Of_Calls_Of_Array_set++;  
  43. }  
  44. @@syscall:$__CPID:exit:entry  
  45. {  
  46. // Exit when the application exits  
  47.         exit();  
  48. }  
  49. @@END  
  50. {  
  51. //This is executed when ProbeVue session exits and prints the following message.  
  52.         printf("Number Of times function - \"java.lang.reflect.Array.set\" called is   
  53.    : %d\n",Number_Of_Calls_Of_Array_set);  
  54. }  
  55.  

輸出

  1. # probevue -X `which java` -A "-agentlib:probevuejava myjava" basic_probing.e  
  2. ProbeVue - Entered myjava.main function  
  3.        Process Id : 7209080  
  4. Parent Process Id : 5767168  
  5. In main  
  6. Value of Integer i:10  
  7. ProbeVue - Entered  myclass1.set_i function  
  8. ProbeVue - Entered  myclass1.set_f function  
  9. ProbeVue - Entered  myclass1.set_d function  
  10. ProbeVue - Entered  myclass1.set_b function  
  11. ProbeVue - Entered  myclass1.set_s function  
  12. Value of Float f:10.03  
  13. Value of Double d:10.1123  
  14. Value of Boolean b:false  
  15. Value of String s:ProbeVue  
  16. 0  
  17. 1  
  18. 2  
  19. 3  
  20. 4  
  21. 5  
  22. 6  
  23. 7  
  24. 8  
  25. 9  
  26. ProbeVue - Entered java.lang.reflect.Array.set function  
  27. ProbeVue - Entered java.lang.reflect.Array.set function  
  28. ProbeVue - Entered java.lang.reflect.Array.set function  
  29. ProbeVue - Entered java.lang.reflect.Array.set function  
  30. ProbeVue - Entered java.lang.reflect.Array.set function  
  31. ProbeVue - Entered java.lang.reflect.Array.set function  
  32. ProbeVue - Entered java.lang.reflect.Array.set function  
  33. ProbeVue - Entered java.lang.reflect.Array.set function  
  34. ProbeVue - Entered java.lang.reflect.Array.set function  
  35. ProbeVue - Entered java.lang.reflect.Array.set function  
  36. Number Of times function - "java.lang.reflect.Array.set" called is : 10  
  37.  

訪問(wèn)參數(shù)

除了提供放置探測(cè)的功能之外,ProbeVue 還允許收集傳遞給函數(shù)的參數(shù)值。對(duì)于訪問(wèn)參數(shù),不需要為 ProbeVue 指定函數(shù)原型。

注意,Java 應(yīng)用程序代碼與前一個(gè)示例相同,也是 myjava.java。

訪問(wèn)參數(shù)的示例 Vue 腳本

  1. # cat accessing_argument.e  
  2. @@uftjava:$__CPID:*:"myclass1.set_d":entry  
  3. {  
  4. //Declaring Vue variable - d of type double  
  5.         double d;  
  6.         d=__arg2;  
  7.         printf("ProbeVue - Entered  myclass1.set_d function with   
  8.    argument :%llf\n",__arg2);  
  9.         printf("ProbeVue Variable d : %llf\n",d);  
  10. // Above is to demonstrate that argument values could be stored in Vue variables and then  
  11. // either operated and printed or printed directly  
  12. }  
  13. @@uftjava:$__CPID:*:"myclass1.set_f":entry  
  14. {  
  15.         printf("ProbeVue - Entered  myclass1.set_f function with argument :%f\n",__arg2);  
  16. }  
  17. @@uftjava:$__CPID:*:"myclass1.set_i":entry  
  18. {  
  19.         printf("ProbeVue - Entered  myclass1.set_i function with argument :%d\n",__arg2);  
  20. }  
  21. @@uftjava:$__CPID:*:"myclass1.set_s":entry  
  22. {  
  23. //Declaring String type Vue variable - s with its size  
  24.         String s[100];  
  25. //String type variable of Java can be directly copied to String type variable of Vue  
  26.         s=__arg2;  
  27.         printf("ProbeVue - Entered  myclass1.set_s function with argument :%s\n",__arg2);  
  28.         printf("ProbeVue Variable s : %s\n",s);  
  29. }  
  30. @@uftjava:$__CPID:*:"myclass1.set_b":entry  
  31. {  
  32.         printf("ProbeVue - Entered  myclass1.set_b function with argument :%d\n",__arg2);  
  33. }  
  34. @@uftjava:$__CPID:*:"myjava.main":entry  
  35. {  
  36.         printf("ProbeVue - Entered Probed Main\n");  
  37. }  
  38. @@uftjava:$__CPID:*:"java.lang.reflect.Array.set":entry  
  39. {  
  40.         printf("ProbeVue - Entered java.lang.reflect.Array.set function with   
  41.    2nd argument as : %d\n",__arg2);  
  42. }  
  43. @@syscall:$__CPID:exit:entry  
  44. {  
  45.         exit();  
  46. }  
  47.  

輸出

  1. #probevue -X `which java` -A "-agentlib:probevuejava myjava" accessing_argument.e  
  2. ProbeVue - Entered Probed Main  
  3. In main  
  4. Value of Integer i:10  
  5. ProbeVue - Entered  myclass1.set_i function with argument :10  
  6. ProbeVue - Entered  myclass1.set_f function with argument :10.030000  
  7. ProbeVue - Entered  myclass1.set_d function with argument :10.112300  
  8. ProbeVue Variable d : 10.112300  
  9. ProbeVue - Entered  myclass1.set_b function with argument :0  
  10. ProbeVue - Entered  myclass1.set_s function with argument :ProbeVue  
  11. ProbeVue Variable s : ProbeVue  
  12. Value of Float f:10.03  
  13. Value of Double d:10.1123  
  14. Value of Boolean b:false  
  15. Value of String s:ProbeVue  
  16. 0  
  17. 1  
  18. 2  
  19. 3  
  20. 4  
  21. 5  
  22. 6  
  23. 7  
  24. 8  
  25. 9  
  26. ProbeVue - Entered java.lang.reflect.Array.set function with 2nd argument as : 0  
  27. ProbeVue - Entered java.lang.reflect.Array.set function with 2nd argument as : 1  
  28. ProbeVue - Entered java.lang.reflect.Array.set function with 2nd argument as : 2  
  29. ProbeVue - Entered java.lang.reflect.Array.set function with 2nd argument as : 3  
  30. ProbeVue - Entered java.lang.reflect.Array.set function with 2nd argument as : 4  
  31. ProbeVue - Entered java.lang.reflect.Array.set function with 2nd argument as : 5  
  32. ProbeVue - Entered java.lang.reflect.Array.set function with 2nd argument as : 6  
  33. ProbeVue - Entered java.lang.reflect.Array.set function with 2nd argument as : 7  
  34. ProbeVue - Entered java.lang.reflect.Array.set function with 2nd argument as : 8  
  35. ProbeVue - Entered java.lang.reflect.Array.set function with 2nd argument as : 9  
  36.  

注意以下幾點(diǎn):

◆對(duì)于靜態(tài)函數(shù),可以使用 __arg1 訪問(wèn)函數(shù)的第一個(gè)實(shí)際參數(shù)。

◆對(duì)于非靜態(tài)函數(shù),可以使用 __arg2 訪問(wèn)函數(shù)的第一個(gè)實(shí)際參數(shù),因?yàn)樽鳛?__arg1 隱式地傳遞 this 指針。

其他要點(diǎn)

◆ProbeVue 腳本可以使用完全限定名(例如 java.lang.Math.PI)讀取 Java 類中的靜態(tài)變量和常量。

◆沒(méi)有替代 @@uftjava 的語(yǔ)法。

◆不需要指定函數(shù)原型,也不需要頭文件。

◆不需要通過(guò)使用 copy_userdata 訪問(wèn)基本數(shù)據(jù)類型。

◆Java 的布爾數(shù)據(jù)類型映射到 ProbeVue 的整數(shù)數(shù)據(jù)類型,1 值代表 true,0 值代表 false。

◆Java 的字符串?dāng)?shù)據(jù)類型映射到 ProbeVue 的字符串?dāng)?shù)據(jù)類型。

◆__pname 提供進(jìn)程名稱 "java" 而不是應(yīng)用程序名,比如 myjavaapp。

◆所有其他函數(shù)的使用方法相同。

◆可以用 -agentlib:probevuejava 標(biāo)志啟動(dòng) Java 應(yīng)用程序,但是以后再啟動(dòng) ProbeVue 會(huì)話。

◆可以探測(cè)靜態(tài)和非靜態(tài)函數(shù)。

◆如果在 ProbeVue 命令行上用 -X 選項(xiàng)啟動(dòng) JVM,那么只能探測(cè) Java 類中的 main 函數(shù)。這迫使 JVM 等到 ProbeVue 啟動(dòng)之后才啟動(dòng) Java 應(yīng)用程序。

可能實(shí)現(xiàn)的場(chǎng)景

◆統(tǒng)計(jì)調(diào)用某一函數(shù)的次數(shù)。

◆跟蹤調(diào)用各個(gè)函數(shù)的次序。

◆檢查參數(shù)值是否正確。

限制

◆只支持 JVM V1.5 和更高版本。

◆目前不支持訪問(wèn)數(shù)組、實(shí)例變量和對(duì)象引用。

◆不支持探測(cè)重載和多態(tài)的函數(shù)。

◆目前不支持 get_function Vue 函數(shù)。

◆不能探測(cè) Java 函數(shù)的出口點(diǎn),因此不能獲取函數(shù)的返回值。

【編輯推薦】

  1. 盤點(diǎn)四大頂級(jí)Java編程工具
  2. 簡(jiǎn)述Java語(yǔ)言的對(duì)象克隆特性
  3. 用Java語(yǔ)言進(jìn)行Unicode代理編程
  4. 分裂與妥協(xié) IBM的Java平臺(tái)策略簡(jiǎn)析
責(zé)任編輯:佚名 來(lái)源: developerworks
相關(guān)推薦

2012-02-15 13:26:56

IndexedDB

2010-04-01 15:10:06

Visual Stud

2016-03-12 21:46:56

Inspeckage應(yīng)用程序動(dòng)態(tài)分析

2022-12-25 18:03:13

Debug原理軟件

2011-04-01 11:01:02

應(yīng)用程序BlackBerryJava

2011-05-05 18:08:43

云計(jì)算Windows AzuPaaS

2010-01-28 09:44:08

C++應(yīng)用程序

2023-09-22 09:41:28

LinuxC語(yǔ)言

2011-07-06 10:22:31

XCode IOS object-C

2013-04-22 09:21:43

2012-11-28 11:14:39

IBMdW

2011-05-18 10:42:48

2013-02-22 09:28:45

MEAP軟件移動(dòng)應(yīng)用開發(fā)HTML5

2014-05-22 10:03:29

2011-11-17 15:17:37

AdobeAIR調(diào)試性能

2010-01-14 11:14:47

C++應(yīng)用程序

2010-01-25 16:41:08

C++應(yīng)用程序

2010-01-04 10:41:14

Silverlight

2011-08-10 11:25:59

ipad信息架構(gòu)數(shù)據(jù)結(jié)構(gòu)

2009-06-10 11:47:32

Android應(yīng)用程序模塊
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)