JP2011107813A - Device, method, and program for obtaining core file - Google Patents

Device, method, and program for obtaining core file Download PDF

Info

Publication number
JP2011107813A
JP2011107813A JP2009259682A JP2009259682A JP2011107813A JP 2011107813 A JP2011107813 A JP 2011107813A JP 2009259682 A JP2009259682 A JP 2009259682A JP 2009259682 A JP2009259682 A JP 2009259682A JP 2011107813 A JP2011107813 A JP 2011107813A
Authority
JP
Japan
Prior art keywords
stack frame
core file
program
information
core
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
JP2009259682A
Other languages
Japanese (ja)
Other versions
JP5421735B2 (en
Inventor
Muneyuki Kawatani
宗之 川谷
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nippon Telegraph and Telephone Corp
Original Assignee
Nippon Telegraph and Telephone Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nippon Telegraph and Telephone Corp filed Critical Nippon Telegraph and Telephone Corp
Priority to JP2009259682A priority Critical patent/JP5421735B2/en
Publication of JP2011107813A publication Critical patent/JP2011107813A/en
Application granted granted Critical
Publication of JP5421735B2 publication Critical patent/JP5421735B2/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

<P>PROBLEM TO BE SOLVED: To achieve shortening a core dump time and reducing the size of a core file. <P>SOLUTION: All stack frames are enumerated, and whether the stack frame is a dump object is determined for each stack frame, and only information which can be referenced from the stack frame determined as the dump object is output to a core file. Thus, the size of a core file is reduced and core dump time is shortened. <P>COPYRIGHT: (C)2011,JPO&INPIT

Description

本発明は、プログラムに故障が発生したときの実行環境情報をコアファイルに出力する技術に関する。   The present invention relates to a technique for outputting execution environment information to a core file when a failure occurs in a program.

実行中のプログラムに故障が発生したときのメモリの内容などをファイルとして保存することで、後でそのファイルを解析して故障発生時のプログラムの実行状態や故障の原因を調査することが可能となる。故障発生時の実行環境情報を保存したファイルのことをコアファイルといい、コアファイルを取得することをコアダンプという(非特許文献1参照)。また、コアファイルの解析を効率化する技術も知られている(非特許文献2参照)。   By saving the contents of memory when a failure occurs in a running program as a file, it is possible to analyze the file later and investigate the execution state of the program at the time of failure and the cause of the failure Become. A file storing execution environment information at the time of failure occurrence is called a core file, and acquiring a core file is called a core dump (see Non-Patent Document 1). A technique for improving the efficiency of analysis of a core file is also known (see Non-Patent Document 2).

"Debugging with GDB 10.17 How to Produce a Core File from Your Program", [online], [平成21年10月30日検索], インターネット〈URL:http://sourceware.org/gdb/current/onlinedocs/gdb.html〉"Debugging with GDB 10.17 How to Produce a Core File from Your Program", [online], [October 30, 2009 search], Internet <URL: http://sourceware.org/gdb/current/onlinedocs/gdb .html> "OSS性能・信頼性評価/障害解析ツール開発 OS層 〜Alicia編〜", [online], [平成21年10月30日検索], インターネット〈URL:http://www.ipa.go.jp/software/open/forum/development/download/051115/OS-Alicia.pdf〉"OSS Performance / Reliability Evaluation / Failure Analysis Tool Development OS Layer -Alicia-", [online], [October 30, 2009 Search], Internet <URL: http://www.ipa.go.jp /software/open/forum/development/download/051115/OS-Alicia.pdf>

しかしながら、従来の技術では、プログラムが利用している全てのメモリ内の情報をダンプ対象とするため、コアファイルの取得に膨大な時間がかかったり、コアファイルのサイズが巨大化するという問題があった。非特許文献2は、コアファイルの解析を効率化するものであるが、コアファイルの取得時間やサイズを縮小する効果はない。   However, in the conventional technology, since all the information in the memory used by the program is targeted for dumping, there is a problem that it takes a long time to acquire the core file or the size of the core file becomes huge. It was. Non-Patent Document 2 improves the efficiency of analysis of a core file, but has no effect of reducing the acquisition time and size of the core file.

コアファイルに出力するダンプ対象を指定してファイルサイズを縮小することが考えられるが、ダンプ対象を効果的に指定しないと、解析に必要な情報を対象外としたり、ダンプ対象が多くてファイルサイズをあまり縮小できない可能性もある。   Although it is possible to reduce the file size by specifying the dump target to be output to the core file, if you do not specify the dump target effectively, the information required for analysis will be excluded or there will be many dump targets and the file size May not be able to be reduced too much.

本発明は、上記に鑑みてなされたものであり、その目的とするところは、コアダンプ時間の短縮、コアファイルのサイズの縮小を実現することにある。   The present invention has been made in view of the above, and an object thereof is to realize a reduction in the core dump time and a reduction in the size of the core file.

第1の本発明に係るコアファイル取得装置は、プログラムを実行する実行手段と、プログラムの故障を検知する検知手段と、検知手段がプログラムの故障を検知したときに、実行手段から各スタックフレームの実行位置情報を取得する取得手段と、ダンプ対象判定条件を記載した設定情報を格納した記憶手段と、スタックフレーム毎に、当該スタックフレームの実行位置情報と記憶手段から読み出した設定情報に記載されたダンプ対象判定条件とを比較して当該スタックフレームがダンプ対象であるか否か判定する判定手段と、判定手段がダンプ対象であると判定したスタックフレームから参照可能な情報を実行手段から取得してコアファイルに出力する出力手段と、を有することを特徴とする。   A core file acquisition apparatus according to a first aspect of the present invention includes an execution unit that executes a program, a detection unit that detects a failure of the program, and a detection unit that detects each failure of the stack frame when the detection unit detects a failure of the program. The acquisition means for acquiring the execution position information, the storage means for storing the setting information describing the dump target determination condition, and for each stack frame, the execution position information of the stack frame and the setting information read from the storage means A determination unit that compares the dump target determination condition to determine whether or not the stack frame is a dump target, and obtains information that can be referred to from the stack frame that the determination unit determines to be the dump target from the execution unit. Output means for outputting to a core file.

上記コアファイル取得装置において、判定手段は、検知手段がプログラムの故障を検知したときに、設定情報を記憶手段から読み出すことを特徴とする。   In the core file acquisition apparatus, the determination unit reads setting information from the storage unit when the detection unit detects a failure of the program.

第2の本発明に係るコアファイル取得方法は、実行手段が実行するプログラムの故障を検知するステップと、プログラムの故障を検知したときに、実行手段から各スタックフレームの実行位置情報を取得するステップと、ダンプ対象判定条件を記載した設定情報を格納した記憶手段から当該設定情報を読み出すステップと、スタックフレーム毎に、当該スタックフレームの実行位置情報とダンプ対象判定条件とを比較して当該スタックフレームがダンプ対象であるか否か判定するステップと、ダンプ対象であると判定したスタックフレームから参照可能な情報を実行手段から取得してコアファイルに出力するステップと、を有することを特徴とする。   The core file acquisition method according to the second aspect of the present invention includes a step of detecting a failure of a program executed by the execution means, and a step of acquiring execution position information of each stack frame from the execution means when the failure of the program is detected And reading the setting information from the storage means storing the setting information describing the dump target determination condition, and comparing the stack frame execution position information with the dump target determination condition for each stack frame. And a step of acquiring information that can be referred to from the stack frame determined to be a dump target from the execution means and outputting the information to a core file.

上記コアファイル取得方法において、プログラムの故障を検知したときに、記憶手段から設定情報を読み出すことを特徴とする。   In the core file acquisition method, the setting information is read from the storage means when a failure of the program is detected.

第3の本発明に係るコアファイル取得プログラムは、上記コアファイル取得装置を構成する各手段としてコンピュータを機能させることを特徴とする。   A core file acquisition program according to the third aspect of the present invention causes a computer to function as each means constituting the core file acquisition apparatus.

本発明によれば、コアダンプ時間の短縮、コアファイルのサイズの縮小を実現することができる。   According to the present invention, it is possible to reduce the core dump time and the size of the core file.

実施例1におけるコアファイル取得装置の構成を示す機能ブロック図である。It is a functional block diagram which shows the structure of the core file acquisition apparatus in Example 1. FIG. 実施例1におけるコアファイル取得装置の処理の流れを示すフローチャートである。6 is a flowchart illustrating a processing flow of the core file acquisition apparatus according to the first embodiment. 上記コアファイル取得装置によりコアファイルに出力される情報を説明するための概略説明図である。It is a schematic explanatory drawing for demonstrating the information output to a core file by the said core file acquisition apparatus. 実施例2におけるコアファイル取得装置の構成を示す機能ブロック図である。It is a functional block diagram which shows the structure of the core file acquisition apparatus in Example 2. FIG. 実施例2におけるコアファイル取得装置の処理の流れを示すフローチャートである。It is a flowchart which shows the flow of a process of the core file acquisition apparatus in Example 2. FIG.

以下、本発明の実施の形態について図面を用いて説明する。   Hereinafter, embodiments of the present invention will be described with reference to the drawings.

図1は、実施例1におけるコアファイル取得装置の構成を示す機能ブロック図である。同図に示すコアファイル取得装置1は、実行部11、検知部12、取得部13、判定部14、および記憶部15を備える。以下、各部の詳細について説明する。   FIG. 1 is a functional block diagram illustrating the configuration of the core file acquisition apparatus according to the first embodiment. The core file acquisition apparatus 1 shown in the figure includes an execution unit 11, a detection unit 12, an acquisition unit 13, a determination unit 14, and a storage unit 15. Details of each part will be described below.

実行部11は、演算処理装置、メモリ等を備え、コアダンプ取得対象プログラムを実行する。コアダンプ取得対象プログラム内で故障が発生すると、実行部11は検知部12に故障発生通知を送信する。コアダンプ取得対象プログラム内で発生する故障は、例えば、変数の値が不正な値になることなどである。   The execution unit 11 includes an arithmetic processing unit, a memory, and the like, and executes the core dump acquisition target program. When a failure occurs in the core dump acquisition target program, the execution unit 11 transmits a failure occurrence notification to the detection unit 12. The failure that occurs in the core dump acquisition target program is, for example, that the value of a variable becomes an incorrect value.

検知部12は、実行部11から故障発生通知を受信することでコアダンプ取得対象プログラムの故障を検知し、取得部13へコアファイル取得要求を発行する。故障発生通知およびコアファイル取得要求には、コアダンプ取得対象プログラムを識別する識別子が含まれる。なお、検知部12が実行部11にアクセスして故障を検知するものでもよい。   The detection unit 12 receives a failure occurrence notification from the execution unit 11 to detect a failure in the core dump acquisition target program and issues a core file acquisition request to the acquisition unit 13. The failure occurrence notification and the core file acquisition request include an identifier for identifying the core dump acquisition target program. The detection unit 12 may access the execution unit 11 to detect a failure.

取得部13は、検知部12からのコアファイル取得要求に応じてコアダンプ取得対象プログラムに接続し、スタックフレームの実行位置情報を取得する。そして、スタックフレーム単位でダンプ対象であるか否かを判定部14に問い合わせ、ダンプ対象と判定されたスタックフレームから参照可能な情報を実行部11から取得してコアファイル151に出力する。スタックフレームは、メソッドが呼び出されたときに実行部11のメモリに確保される記憶領域であり、メソッド内で利用される変数などの情報が格納される。メソッド内で別のメソッドを呼び出すと別のメソッド用のスタックフレームがメモリに確保される。スタックフレームの実行位置情報は、ソースファイル名、ソースファイル中の行番号、クラス名、メソッド名などの情報を含み、コアダンプ取得対象プログラムの現在の実行位置を知ることができる情報である。スタックフレームから参照可能な情報は主に変数であり、スタックフレーム内の変数だけでなく、スタックフレーム内の変数が参照し、その変数から辿ることができる変数もコアファイル151に出力する参照可能な情報である。   The acquisition unit 13 connects to the core dump acquisition target program in response to the core file acquisition request from the detection unit 12 and acquires execution position information of the stack frame. Then, the determination unit 14 is inquired as to whether or not it is a dump target in units of stack frames, information that can be referred to from the stack frame determined to be a dump target is acquired from the execution unit 11 and output to the core file 151. The stack frame is a storage area secured in the memory of the execution unit 11 when a method is called, and stores information such as variables used in the method. When another method is called in the method, a stack frame for another method is secured in the memory. The execution position information of the stack frame includes information such as a source file name, a line number in the source file, a class name, and a method name, and is information that allows the current execution position of the core dump acquisition target program to be known. The information that can be referred to from the stack frame is mainly variables. Not only the variables in the stack frame but also the variables in the stack frame refer to, and the variables that can be traced from the variables can be output to the core file 151. Information.

判定部14は、取得部13が指定したスタックフレームがダンプ対象であるか否かを判定する。スタックフレームがダンプ対象であるか否かの判定は、取得部13から判定するスタックフレームの実行位置情報を受信し、受信した実行位置情報と記憶部15に格納された設定ファイル152とを比較することで行う。設定ファイル152には、ダンプ対象から除外するソースファイル名、クラス名の一部などのダンプ対象判定条件が記載されている。例えば、あるスタックフレームの実行位置情報のソースファイル名が設定ファイル152に除外対象として記載されている場合は、そのスタックフレームはダンプ対象ではないと判定する。また、設定ファイル152にソースファイル名に加えてクラス名の一部が記載されているときは、ソースファイル名が一致し、さらに、実行位置情報のクラス名が設定ファイル152に記載されたクラス名の一部を含む場合は、そのスタックフレームはダンプ対象ではないと判定する。なお、判定部14が故障発生前に設定ファイル152を取得してもよいが、検知部12が故障発生通知を受信したときに判定部14が設定ファイル152を取得する場合は、コアダンプ取得対象プログラム内で故障が発生するまでは設定ファイル152を取得しないので、実際に検知部12が故障を検知するまではコアダンプ取得対象プログラムの挙動への影響がほとんどない。   The determination unit 14 determines whether the stack frame specified by the acquisition unit 13 is a dump target. Whether or not the stack frame is a dump target is determined by receiving execution position information of the stack frame determined from the acquisition unit 13 and comparing the received execution position information with the setting file 152 stored in the storage unit 15. Do that. The setting file 152 describes dump target determination conditions such as a source file name excluded from the dump target and a part of the class name. For example, when the source file name of the execution position information of a certain stack frame is described as an exclusion target in the setting file 152, it is determined that the stack frame is not a dump target. When a part of the class name is described in the setting file 152 in addition to the source file name, the source file name matches, and the class name of the execution position information is the class name described in the setting file 152. Is included, it is determined that the stack frame is not a dump target. The determination unit 14 may acquire the setting file 152 before the failure occurs. However, when the determination unit 14 acquires the setting file 152 when the detection unit 12 receives the failure occurrence notification, the core dump acquisition target program Since the setting file 152 is not acquired until a failure occurs in the system, there is almost no influence on the behavior of the core dump acquisition target program until the detection unit 12 actually detects the failure.

記憶部15は、上述した設定ファイル152を記憶するのに加えて、取得部13が出力した情報をコアファイル151に記憶する。   In addition to storing the setting file 152 described above, the storage unit 15 stores the information output by the acquisition unit 13 in the core file 151.

次に、コアファイル取得装置1の処理の流れについて説明する。図2は、実施例1におけるコアファイル取得装置1の処理の流れを示すフローチャートである。   Next, the process flow of the core file acquisition apparatus 1 will be described. FIG. 2 is a flowchart illustrating a process flow of the core file acquisition apparatus 1 according to the first embodiment.

まず、検知部12が実行部11から故障発生通知を受信してコアダンプ取得対象プログラムの故障を検知すると、検知部12は、取得部13へコアファイル取得要求を発行する(ステップS11)。取得部13がコアファイル取得要求を受信すると、取得部13は、コアダンプ取得対象プログラムに接続してコアファイル取得対象プログラムの動作を停止させ、全スタックフレームを列挙し、スタックフレーム毎に以下の処理を行う。   First, when the detection unit 12 receives a failure occurrence notification from the execution unit 11 and detects a failure of the core dump acquisition target program, the detection unit 12 issues a core file acquisition request to the acquisition unit 13 (step S11). When the acquisition unit 13 receives the core file acquisition request, the acquisition unit 13 connects to the core dump acquisition target program, stops the operation of the core file acquisition target program, enumerates all stack frames, and performs the following processing for each stack frame. I do.

取得部13は、スタックフレームの実行位置情報を実行部11から取得する(ステップS12)。取得した実行位置情報は、記憶部15のコアファイル151に出力する。実行位置情報の取得時間もサイズも他のダンプする情報に比べてかなり小さいため、本実施例では、ダンプ対象であるか否かに関わらず、全てのスタックフレームの実行位置情報をコアファイル151に出力する。もちろん、ダンプ対象と判定されたスタックフレームの実行位置情報のみをコアファイル151に出力するものでもよい。   The acquisition unit 13 acquires stack frame execution position information from the execution unit 11 (step S12). The acquired execution position information is output to the core file 151 in the storage unit 15. Since the acquisition time and size of the execution position information are considerably shorter than other dumping information, in this embodiment, the execution position information of all stack frames is stored in the core file 151 regardless of whether or not it is a dump target. Output. Of course, only the execution position information of the stack frame determined to be dumped may be output to the core file 151.

その後、取得部13が実行位置情報を判定部14に渡すと、判定部14は実行位置情報と設定ファイル152のダンプ対象判定条件とを比較してスタックフレームがダンプ対象であるか否か判定する(ステップS13)。スタックフレームがダンプ対象でない場合は、次のスタックフレームを処理するためにステップS15へ進む。   Thereafter, when the acquisition unit 13 passes the execution position information to the determination unit 14, the determination unit 14 compares the execution position information with the dump target determination condition of the setting file 152 to determine whether the stack frame is a dump target. (Step S13). If the stack frame is not a dump target, the process proceeds to step S15 to process the next stack frame.

スタックフレームがダンプ対象の場合、取得部13は、そのスタックフレームから参照可能な情報を実行部11から取得してコアファイル151に出力する(ステップS14)。   When the stack frame is a dump target, the acquisition unit 13 acquires information that can be referred to from the stack frame from the execution unit 11 and outputs the information to the core file 151 (step S14).

そして、全てのスタックフレームについて処理したか否か判定する(ステップS15)。まだ処理していないスタックフレームが存在する場合はステップS12へ戻る。全てのスタックフレームについて処理したときは、コアファイル取得装置1の処理を終了する。   Then, it is determined whether or not all stack frames have been processed (step S15). If there is a stack frame that has not yet been processed, the process returns to step S12. When all the stack frames have been processed, the processing of the core file acquisition device 1 is terminated.

図3は、コアファイル取得装置1によりコアファイル151に出力される情報を説明するための概略説明図である。図3に示す例では、#0から#4の5つのスタックフレームが列挙される。スタックフレームの右側に示す○印は、スタックフレームから辿ることができる情報を示している。列挙したスタックフレームのうち、#0,#3は他社プログラムによるスタックフレームである。#0,#3のスタックフレームをダンプ対象外とすると、そこからのみ参照されている情報のダンプを除外できる。図3では、白○印で示す情報がダンプされ、網掛け○印で示す情報はダンプされない。ダンプ対象外スタックフレーム(例えば#0)から参照される情報であっても、ダンプ対象スタックフレーム(例えば#1)から参照可能な情報であればコアファイル151に出力される。   FIG. 3 is a schematic explanatory diagram for explaining information output to the core file 151 by the core file acquisition apparatus 1. In the example shown in FIG. 3, five stack frames # 0 to # 4 are listed. A circle on the right side of the stack frame indicates information that can be traced from the stack frame. Among the listed stack frames, # 0 and # 3 are stack frames by other companies' programs. If the stack frames of # 0 and # 3 are excluded from dumping, dumping of information that is referenced only from there can be excluded. In FIG. 3, information indicated by white circles is dumped, and information indicated by shaded circles is not dumped. Even if the information is referenced from the non-dump target stack frame (for example, # 0), the information can be output to the core file 151 as long as the information can be referred to from the dump target stack frame (for example, # 1).

スタックフレームから参照可能な情報は、スタックフレームが保持する情報だけでなく、その情報が参照する情報も含む。したがって、取得部13は、スタックフレームから情報を辿ってコアファイル151に出力する。具体的には、ある変数が別の変数を有する場合は別の変数もコアファイル151に出力し、その別の変数がさらに別の変数を有する場合はさらに別の変数もコアファイル151に出力する。情報の参照関係もコアファイル151に出力する。   Information that can be referred to from the stack frame includes not only information held by the stack frame but also information referred to by the information. Therefore, the acquisition unit 13 traces information from the stack frame and outputs it to the core file 151. Specifically, when a variable has another variable, another variable is also output to the core file 151. When the other variable has another variable, another variable is also output to the core file 151. . Information reference relationships are also output to the core file 151.

図4は、実施例2のコアファイル取得装置の構成を示す機能ブロック図である。同図に示すコアファイル取得装置100は、JVM(Java Virtual Machine)110、故障検知部120、コアファイル取得部130、およびダンプ対象判定部140を備え、二次記憶装置150に接続されている。   FIG. 4 is a functional block diagram illustrating the configuration of the core file acquisition apparatus according to the second embodiment. A core file acquisition apparatus 100 shown in FIG. 1 includes a JVM (Java Virtual Machine) 110, a failure detection unit 120, a core file acquisition unit 130, and a dump target determination unit 140, and is connected to the secondary storage device 150.

JVM110は、Java(登録商標)言語で記述されたプログラム111を実行する仮想マシンである。プログラム111内で故障が発生すると、故障検知部120に故障発生通知を送信する。故障の検知は、例えばJavaの例外キャッチ命令であるcatch節の中に故障発生通知送信機能を記述することで実現できる。また、if文を用いて変数値の異常を故障として判定し、故障発生通知を送信することでも実現できる。他にも、アスペクト指向を用い、ある条件を満たす場合を故障として検知する方法や、BCI(Byte Code Instrumentation)を用いて故障を検知する方法がある。   The JVM 110 is a virtual machine that executes a program 111 written in the Java (registered trademark) language. When a failure occurs in the program 111, a failure occurrence notification is transmitted to the failure detection unit 120. Failure detection can be realized by describing a failure occurrence notification transmission function in a catch clause, which is an exception catch instruction of Java, for example. It can also be realized by determining an abnormality of the variable value as a failure using an if statement and transmitting a failure occurrence notification. In addition, there are a method of detecting a case where a certain condition is satisfied using aspect orientation as a failure, and a method of detecting a failure using Byte Code Instrumentation (BCI).

故障検知部120は、故障発生通知を受信すると、コアファイル取得部130へコアファイル取得要求を発行するとともに、ダンプ対象判定部140へ初期化要求を発行する。   When receiving the failure occurrence notification, the failure detection unit 120 issues a core file acquisition request to the core file acquisition unit 130 and issues an initialization request to the dump target determination unit 140.

コアファイル取得部130は、故障検知部120からのコアファイル取得要求に応じてJVM110を介してプログラム111に接続し、スタックフレーム単位でダンプ対象であるか否かをダンプ対象判定部140に問い合わせ、ダンプ対象と判定されたスタックフレームから参照可能な情報を取得してコアファイル151に出力する。プログラム111により複数のスレッドが実行される場合は、全スレッドそれぞれの全スタックフレームそれぞれについてダンプ対象であるか否かを問い合わせる。コアファイル取得部130は、スタックフレームの実行位置情報(パッケージ名、ソースファイル名、ソースファイル中の行番号、クラス名、メソッド名など)を取得し、実行位置情報をダンプ対象判定部140に渡して、そのスタックフレームがダンプ対象であるか否かを問い合わせる。   The core file acquisition unit 130 connects to the program 111 via the JVM 110 in response to the core file acquisition request from the failure detection unit 120, and inquires of the dump target determination unit 140 whether or not the dump target is a stack frame unit. Information that can be referred to is acquired from the stack frame determined to be dumped and output to the core file 151. When a plurality of threads are executed by the program 111, an inquiry is made as to whether or not all stack frames of all threads are to be dumped. The core file acquisition unit 130 acquires stack frame execution position information (package name, source file name, line number in the source file, class name, method name, etc.), and passes the execution position information to the dump target determination unit 140. To inquire whether the stack frame is a dump target.

本実施例では、プログラム111に接続する方法として、JDI(Java Debug Interface)を用いる。プログラムがJava言語で記述されたものであれば、JVMDI(Java Virtual Machine Debug Interface)やJDWP(Java Debug Wire Protocol)も用いることができる。プログラムがC言語で記述されたものであれば、ptraceシステムコールや、ptraceを使用して作られたgdbを用いることができる。   In the present embodiment, JDI (Java Debug Interface) is used as a method of connecting to the program 111. If the program is written in the Java language, JVMDI (Java Virtual Machine Debug Interface) and JDWP (Java Debug Wire Protocol) can also be used. If the program is written in C language, the ptrace system call or gdb created using ptrace can be used.

ダンプ対象判定部140は、コアファイル取得部130が指定したスタックフレームがダンプ対象であるか否かを判定する。本実施例では、スタックフレームの実行位置情報のクラス名が設定ファイル152に記載されたクラス名の一部を含む場合に、そのスタックフレームはダンプ対象ではないと判定する。つまり、スタックフレームの実行位置情報のクラス名が設定ファイル152に記載されたクラス名の一部を含まない場合に、そのスタックフレームはダンプ対象となる。なお、ダンプ対象であるか否かの判定条件に、パッケージ名、ソースファイル名、ソースファイル中の行番号、あるいはメソッド名を用いてもよい。もちろん、ダンプ対象の判定条件に正規表現を用いることも、行番号の大小関係を用いることも可能である。   The dump target determination unit 140 determines whether the stack frame specified by the core file acquisition unit 130 is a dump target. In this embodiment, when the class name of the execution position information of the stack frame includes a part of the class name described in the setting file 152, the stack frame is determined not to be dumped. That is, when the class name of the execution position information of the stack frame does not include a part of the class name described in the setting file 152, the stack frame becomes a dump target. Note that a package name, a source file name, a line number in the source file, or a method name may be used as a determination condition for determining whether or not to dump. Of course, it is possible to use a regular expression as a judgment condition for dumping, or to use a line number size relationship.

ダンプ対象判定部140は、故障検知部120からの初期化要求に応じて二次記憶装置150から設定ファイル152を読み出し、ダンプ対象判定部140の有するメモリにロードする。   The dump target determination unit 140 reads the setting file 152 from the secondary storage device 150 in response to the initialization request from the failure detection unit 120 and loads it into the memory included in the dump target determination unit 140.

二次記憶装置150は、ダンプ対象の判定条件を記載した設定ファイル152を記憶し、コアファイル取得部130が出力した情報をコアファイル151として記憶する。   The secondary storage device 150 stores the setting file 152 in which the determination condition for dumping is described, and stores the information output by the core file acquisition unit 130 as the core file 151.

次に、コアファイル取得装置100の処理の流れについて説明する。図5は、本実施例におけるコアファイル取得装置100の処理の流れを示すフローチャートである。   Next, a processing flow of the core file acquisition apparatus 100 will be described. FIG. 5 is a flowchart showing the processing flow of the core file acquisition apparatus 100 in the present embodiment.

まず、故障検知部120が故障発生通知を受信してプログラム111の故障を検知すると、故障検知部120は、コアファイル取得部130へコアファイル取得要求を発行するとともに、ダンプ対象判定部140へ初期化要求を発行する(ステップS101)。ダンプ対象判定部140は、初期化要求に応じて二次記憶装置150から設定ファイル152のダンプ対象判定条件を読み出す。   First, when the failure detection unit 120 receives a failure occurrence notification and detects a failure of the program 111, the failure detection unit 120 issues a core file acquisition request to the core file acquisition unit 130 and also initializes to the dump target determination unit 140. Issue an activation request (step S101). The dump target determination unit 140 reads the dump target determination condition of the setting file 152 from the secondary storage device 150 in response to the initialization request.

コアファイル取得部130がコアファイル取得要求を受信すると、コアファイル取得部130はプログラム111にデバッガのAPIを経由してアタッチする(ステップS102)。コアファイル取得部130は、プログラム111にアタッチ後、プログラム111の動作を停止させ、JDIの VirtualMachine.allThreads() メソッドを利用してプログラム111の全スレッドを列挙し、スレッド毎に以下の処理を行う。   When the core file acquisition unit 130 receives the core file acquisition request, the core file acquisition unit 130 attaches to the program 111 via the API of the debugger (step S102). After attaching to the program 111, the core file acquisition unit 130 stops the operation of the program 111, enumerates all the threads of the program 111 using the JDI VirtualMachine.allThreads () method, and performs the following processing for each thread. .

コアファイル取得部130は、対象スレッドのスレッドID、スレッド名、モニター取得待ちオブジェクト、およびモニターを保持しているオブジェクト一覧を取得し、ダンプ情報として二次記憶装置150のコアファイル151に出力する(ステップS103)。スレッドに関する情報は全てJDIのAPIにより取得可能である。コアファイル取得部130は、対象スレッドについて、JDIの ThreadReference.frames() メソッドを利用して全スタックフレームを列挙し、スタックフレーム毎に以下の処理を行う。   The core file acquisition unit 130 acquires the thread ID of the target thread, the thread name, the monitor acquisition waiting object, and the object list holding the monitor, and outputs them as dump information to the core file 151 of the secondary storage device 150 ( Step S103). All information about threads can be acquired by JDI API. The core file acquisition unit 130 enumerates all stack frames for the target thread using the ThreadReference.frames () method of JDI, and performs the following processing for each stack frame.

コアファイル取得部130は、スタックフレームの実行位置情報(パッケージ名、ソースファイル名、ソースファイル中の行番号、クラス名、メソッド名)を取得し、スタックフレーム情報として二次記憶装置150のコアファイル151に出力する(ステップS104)。本実施例では、スタックフレームがダンプ対象であるか否かに関わらず、取得した実行位置情報をコアファイル151に出力する。   The core file acquisition unit 130 acquires stack frame execution position information (package name, source file name, line number in the source file, class name, method name), and uses the core file of the secondary storage device 150 as stack frame information. 151 (step S104). In this embodiment, the acquired execution position information is output to the core file 151 regardless of whether or not the stack frame is a dump target.

コアファイル取得部130が実行位置情報をダンプ対象判定部140に渡すと、ダンプ対象判定部140は実行位置情報とダンプ対象判定条件とを比較してスタックフレームがダンプ対象であるか否かを判定する(ステップS105)。そのスタックフレームがダンプ対象でない場合は、次のスタックフレームを処理するためにステップS110へ進む。   When the core file acquisition unit 130 passes the execution position information to the dump target determination unit 140, the dump target determination unit 140 compares the execution position information with the dump target determination condition to determine whether the stack frame is a dump target. (Step S105). If the stack frame is not a dump target, the process proceeds to step S110 to process the next stack frame.

スタックフレームがダンプ対象の場合、コアファイル取得部130は、JDIの StackFrame.visibleVariables() メソッドを利用し、そのスタックフレームが保持する全変数を列挙し、列挙した変数のうち、プリミティブ型変数をコアファイル151に出力する(ステップS106)。プリミティブ型変数とは整数値、浮動小数値、あるいは文字値などを値として持ち、他の変数を値として持たない変数である。一方、プリミティブ型変数以外の変数としてオブジェクト型変数が存在する。オブジェクト型変数は、プリミティブ型変数や別のオブジェクト型変数など他の変数を持つ変数である。   When the stack frame is a dump target, the core file acquisition unit 130 uses JDI's StackFrame.visibleVariables () method to enumerate all the variables held by the stack frame, and among the enumerated variables, core type variables are listed. It outputs to the file 151 (step S106). A primitive variable is a variable that has an integer value, a floating-point value, or a character value as a value and does not have other variables as values. On the other hand, object type variables exist as variables other than primitive type variables. An object type variable is a variable having another variable such as a primitive type variable or another object type variable.

続いて、列挙した変数のうち、オブジェクト型変数のオブジェクトID、型名、文字列表現値をオブジェクト情報としてコアファイル151に出力する(ステップS107)。オブジェクト型変数の情報は、JDIの ObjectReference.uniqueID() メソッド、ObjectReference.referenceType().name() メソッド、および ObjectReference.toString() メソッドにより取得する。   Subsequently, among the enumerated variables, the object ID, type name, and character string expression value of the object type variable are output to the core file 151 as object information (step S107). Information on the object type variable is acquired by the JDI ObjectReference.uniqueID () method, ObjectReference.referenceType (). Name () method, and ObjectReference.toString () method.

そして、JDIの StackFrame.visibleVariables() メソッドを利用し、オブジェクト型変数が保持する全メンバ変数を列挙し、列挙した変数のうち、プリミティブ型変数をコアファイル151に出力する(ステップS108)。メンバ変数にオブジェクト型変数が存在する場合は(ステップS109)、そのオブジェクト型変数に対してステップS107以降の処理を再帰的に実行する。   Then, using JDI's StackFrame.visibleVariables () method, all member variables held by the object type variable are enumerated, and among the enumerated variables, the primitive type variable is output to the core file 151 (step S108). If an object type variable exists as a member variable (step S109), the processing after step S107 is recursively executed on the object type variable.

スタックフレームから辿ることができる全ての変数の出力が終わると、全てのスタックフレームについて処理したか否か判定し(ステップS110)、まだ処理していないスタックフレームが存在する場合はステップS104へ戻る。   When all the variables that can be traced from the stack frame have been output, it is determined whether or not all the stack frames have been processed (step S110). If there is a stack frame that has not yet been processed, the process returns to step S104.

全てのスタックフレームについて処理した場合には、全てのスレッドについて処理したか否か判定し(ステップS111)、まだ処理していないスレッドが存在する場合はステップS103へ戻る。全てのスレッドについて処理したときは、コアファイル取得装置100の処理を終了する。   If all the stack frames have been processed, it is determined whether all threads have been processed (step S111). If there is a thread that has not yet been processed, the process returns to step S103. When all the threads have been processed, the processing of the core file acquisition apparatus 100 ends.

なお、実施例1,2に示したコアファイル取得装置が備える各部は、演算処理装置、記憶装置、メモリ等を備えたコンピュータにより構成して、各部の処理がプログラムによって実行されるものとしてもよい。このプログラムはコアファイル取得装置が備える記憶装置に記憶されており、磁気ディスク、光ディスク、半導体メモリ等の記録媒体に記録することも、ネットワークを通して提供することも可能である。また、各実施例のコアファイル取得装置の構成は一例であり、各部を別々のコンピュータにより構成してもよい。   In addition, each part with which the core file acquisition apparatus shown in Example 1, 2 is comprised is comprised by the computer provided with the arithmetic processing unit, the memory | storage device, memory, etc., and the process of each part may be performed by a program. . This program is stored in a storage device included in the core file acquisition device, and can be recorded on a recording medium such as a magnetic disk, an optical disk, or a semiconductor memory, or provided through a network. In addition, the configuration of the core file acquisition apparatus of each embodiment is an example, and each unit may be configured by a separate computer.

以上説明したように、全てのスタックフレームを列挙し、スタックフレーム毎にダンプ対象であるか否かを判断し、ダンプ対象と判定されたスタックフレームから参照可能な情報のみコアファイルに出力することで、コアファイルのサイズを縮小し、コアダンプ時間を短縮することが可能となる。スタックフレーム単位でダンプの要否が指定可能であるので、例えば、外部ライブラリ等のスタックフレームを除外することで、つまり、相対的に故障する可能性の高いライブラリ等のスタックフレームをダンプ対象とすることで、プログラムの故障の解析に必要な情報の全てを残しつつ、コアファイルのサイズを縮小することができる。   As described above, all stack frames are listed, whether or not each stack frame is a dump target, and only information that can be referenced from the stack frame determined to be dumped is output to the core file. It becomes possible to reduce the size of the core file and shorten the core dump time. Since it is possible to specify the necessity of dumping in units of stack frames, for example, by excluding stack frames such as external libraries, that is, stack frames such as libraries that are relatively likely to fail are targeted for dumping. As a result, it is possible to reduce the size of the core file while leaving all the information necessary for analyzing the failure of the program.

1…コアファイル取得装置
11…実行部
12…検知部
13…取得部
14…判定部
15…記憶部
100…コアファイル取得装置
110…JVM
111…プログラム
120…故障検知部
130…コアファイル取得部
140…ダンプ対象判定部
150…二次記憶装置
151…コアファイル
152…設定ファイル
DESCRIPTION OF SYMBOLS 1 ... Core file acquisition apparatus 11 ... Execution part 12 ... Detection part 13 ... Acquisition part 14 ... Determination part 15 ... Storage part 100 ... Core file acquisition apparatus 110 ... JVM
DESCRIPTION OF SYMBOLS 111 ... Program 120 ... Failure detection part 130 ... Core file acquisition part 140 ... Dump object determination part 150 ... Secondary storage device 151 ... Core file 152 ... Setting file

Claims (5)

プログラムを実行する実行手段と、
前記プログラムの故障を検知する検知手段と、
前記検知手段が前記プログラムの故障を検知したときに、前記実行手段から各スタックフレームの実行位置情報を取得する取得手段と、
ダンプ対象判定条件を記載した設定情報を格納した記憶手段と、
前記スタックフレーム毎に、当該スタックフレームの実行位置情報と前記記憶手段から読み出した前記設定情報に記載された前記ダンプ対象判定条件とを比較して当該スタックフレームがダンプ対象であるか否か判定する判定手段と、
前記判定手段がダンプ対象であると判定した前記スタックフレームから参照可能な情報を前記実行手段から取得してコアファイルに出力する出力手段と、
を有することを特徴とするコアファイル取得装置。
Execution means for executing the program;
Detecting means for detecting a failure of the program;
An acquisition means for acquiring execution position information of each stack frame from the execution means when the detection means detects a failure of the program;
Storage means for storing setting information describing the dump target determination condition;
For each stack frame, the execution position information of the stack frame is compared with the dump target determination condition described in the setting information read from the storage unit to determine whether the stack frame is a dump target. A determination means;
Output means for acquiring information that can be referred to from the stack frame determined by the determination means to be dumped from the execution means and outputting the information to a core file;
A core file acquisition apparatus comprising:
前記判定手段は、前記検知手段が前記プログラムの故障を検知したときに、前記設定情報を前記記憶手段から読み出すことを特徴とする請求項1記載のコアファイル取得装置。   2. The core file acquisition apparatus according to claim 1, wherein the determination unit reads the setting information from the storage unit when the detection unit detects a failure of the program. 実行手段が実行するプログラムの故障を検知するステップと、
前記プログラムの故障を検知したときに、前記実行手段から各スタックフレームの実行位置情報を取得するステップと、
ダンプ対象判定条件を記載した設定情報を格納した記憶手段から当該設定情報を読み出すステップと、
前記スタックフレーム毎に、当該スタックフレームの実行位置情報と前記ダンプ対象判定条件とを比較して当該スタックフレームがダンプ対象であるか否か判定するステップと、
ダンプ対象であると判定した前記スタックフレームから参照可能な情報を前記実行手段から取得してコアファイルに出力するステップと、
を有することを特徴とするコアファイル取得方法。
Detecting a failure of a program executed by the execution means;
Obtaining execution position information of each stack frame from the execution means when a failure of the program is detected;
Reading the setting information from the storage means storing the setting information describing the dump target determination condition;
For each stack frame, comparing execution position information of the stack frame with the dump target determination condition to determine whether the stack frame is a dump target; and
Obtaining from the execution means information that can be referred to from the stack frame determined to be a dump target, and outputting to the core file;
A core file acquisition method characterized by comprising:
前記プログラムの故障を検知したときに、前記記憶手段から前記設定情報を読み出すことを特徴とする請求項3記載のコアファイル取得方法。   4. The core file acquisition method according to claim 3, wherein the setting information is read from the storage means when a failure of the program is detected. 請求項1又は2に記載のコアファイル取得装置を構成する各手段としてコンピュータを機能させるためのコアファイル取得プログラム。   The core file acquisition program for functioning a computer as each means which comprises the core file acquisition apparatus of Claim 1 or 2.
JP2009259682A 2009-11-13 2009-11-13 Core file acquisition apparatus, core file acquisition method, and core file acquisition program Expired - Fee Related JP5421735B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2009259682A JP5421735B2 (en) 2009-11-13 2009-11-13 Core file acquisition apparatus, core file acquisition method, and core file acquisition program

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2009259682A JP5421735B2 (en) 2009-11-13 2009-11-13 Core file acquisition apparatus, core file acquisition method, and core file acquisition program

Publications (2)

Publication Number Publication Date
JP2011107813A true JP2011107813A (en) 2011-06-02
JP5421735B2 JP5421735B2 (en) 2014-02-19

Family

ID=44231236

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2009259682A Expired - Fee Related JP5421735B2 (en) 2009-11-13 2009-11-13 Core file acquisition apparatus, core file acquisition method, and core file acquisition program

Country Status (1)

Country Link
JP (1) JP5421735B2 (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007172414A (en) * 2005-12-23 2007-07-05 Fuji Soft Inc Compact core dump program for built-in equipment and method using compact core dump
JP2008186378A (en) * 2007-01-31 2008-08-14 Ipride Co Ltd Program for handling exception

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007172414A (en) * 2005-12-23 2007-07-05 Fuji Soft Inc Compact core dump program for built-in equipment and method using compact core dump
JP2008186378A (en) * 2007-01-31 2008-08-14 Ipride Co Ltd Program for handling exception

Also Published As

Publication number Publication date
JP5421735B2 (en) 2014-02-19

Similar Documents

Publication Publication Date Title
US8156475B2 (en) Device and method for testing embedded software using emulator
US8386851B2 (en) Functional coverage using combinatorial test design
JP5523872B2 (en) Program dynamic analysis method and apparatus
US20170132119A1 (en) Method and device for retrieving test case based on code coverage
US6769077B2 (en) System and method for remotely creating a physical memory snapshot over a serial bus
US20120159449A1 (en) Call Stack Inspection For A Thread Of Execution
US20080148238A1 (en) Runtime Analysis of a Computer Program to Identify Improper Memory Accesses that Cause Further Problems
KR102025078B1 (en) Diagnosing code using single step execution
US8752027B2 (en) Injecting faults into program for testing software
US20080276129A1 (en) Software tracing
JP2006185211A (en) Program analysis system, test execution device, and analysis method and program thereof
JP2002082926A (en) Distributed application test and operation management system
CN111026601A (en) Monitoring method and device for Java application system, electronic equipment and storage medium
JP2010067188A (en) Information processor for supporting programming, information processing system, and programming support method and program
JP2010033543A (en) Software operation monitoring system, client computer, server computer thereof, and program thereof
JP2015011372A (en) Debug support system, method, program, and recording medium
US8533683B2 (en) Stack walking enhancements using sensorpoints
US9842044B2 (en) Commit sensitive tests
US8689223B2 (en) Mechanisms to detect priority inversion
JP2007199845A (en) Method and device for detecting memory c0rruption
US10713145B2 (en) Automated debugging with combined static and dynamic analysis
JP5495310B2 (en) Information processing apparatus, failure analysis method, and failure analysis program
CN109992511B (en) Device and method for obtaining code test coverage rate
US20200183809A1 (en) Usage amount monitoring method and monitoring unit of electronic control unit for vehicle
US8312433B2 (en) Operating system aided code coverage

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20120307

RD03 Notification of appointment of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7423

Effective date: 20120510

RD04 Notification of resignation of power of attorney

Free format text: JAPANESE INTERMEDIATE CODE: A7424

Effective date: 20120514

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20130529

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20130604

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20130801

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20131119

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20131122

R150 Certificate of patent or registration of utility model

Ref document number: 5421735

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R150

S531 Written request for registration of change of domicile

Free format text: JAPANESE INTERMEDIATE CODE: R313531

R350 Written notification of registration of transfer

Free format text: JAPANESE INTERMEDIATE CODE: R350

LAPS Cancellation because of no payment of annual fees