JP2014063346A - Information processor - Google Patents
Information processor Download PDFInfo
- Publication number
- JP2014063346A JP2014063346A JP2012207976A JP2012207976A JP2014063346A JP 2014063346 A JP2014063346 A JP 2014063346A JP 2012207976 A JP2012207976 A JP 2012207976A JP 2012207976 A JP2012207976 A JP 2012207976A JP 2014063346 A JP2014063346 A JP 2014063346A
- Authority
- JP
- Japan
- Prior art keywords
- branch
- address
- data
- memory
- program
- 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.)
- Pending
Links
Images
Landscapes
- Debugging And Monitoring (AREA)
Abstract
Description
本発明は情報処理装置に関し、たとえば、対象プログラム中の命令をどれくらい実行したかを検出する情報処理装置に利用できるものである。 The present invention relates to an information processing apparatus, and can be used, for example, in an information processing apparatus that detects how many instructions in a target program have been executed.
マイクロコンピュータの1種であるMCU(Micro Computer Unit)が家電などの各種電気機器に組み込まれるようになり、MCUに内蔵されるソフトウェアが有するバグを見つけ出し修正するデバッグ工程は重要である。デバッグ工程では、プログラムが適切に動作するかをチェックするために、ICE(In-Circuit Emulator)等のエミュレータをMCUに接続して、プログラム実行中のMCU内の各部の状態をICEによりモニタする。 An MCU (Micro Computer Unit), which is a kind of microcomputer, has been incorporated into various electrical devices such as home appliances, and a debugging process for finding and correcting bugs in software built in the MCU is important. In the debugging process, an emulator such as an ICE (In-Circuit Emulator) is connected to the MCU in order to check whether the program operates properly, and the state of each part in the MCU that is executing the program is monitored by the ICE.
モニタする項目の1つに、プログラムのトレースデータから、プログラム内の分岐命令によって実行された命令の当該プログラムに占める割合を検出する、いわゆるプログラムのカバレッジ率の計測がある。たとえば、特許文献1(特開2004−21939号公報)には、プログラム実行時にMCUから出力されるトレースデータに含まれる全ての分岐元/分岐先アドレスを一旦ICE内のメモリに記録する。そして、プログラム実行終了後に記録された分岐情報をソフトウェアにより解析し、解析結果から分岐率を算出する。 One of the items to be monitored is measurement of a so-called program coverage rate in which the ratio of instructions executed by branch instructions in the program to the program is detected from the trace data of the program. For example, in Patent Document 1 (Japanese Patent Application Laid-Open No. 2004-21939), all branch source / branch destination addresses included in trace data output from an MCU during program execution are temporarily recorded in a memory in the ICE. Then, the branch information recorded after the program execution is completed is analyzed by software, and the branch rate is calculated from the analysis result.
また、カバレッジ率を計測するためにトレースデータを記録する場合に、トレースデータをMCUからホストコンピュータ内の大容量メモリに直接転送することができないとき(たとえば、転送帯域が確保できないようなとき)には、通常トレースデータをMCUからエミュレータが備えるメモリに転送して記録する。しかし、エミュレータに搭載可能なメモリはホストコンピュータに比較して圧倒的に容量が小さいため、長時間のプログラム実行などによりトレースデータ量が多くなると、エミュレータのメモリではトレースデータの上書き記録が発生し、カバレッジ率を計測することができないという問題があった。 Also, when recording trace data to measure the coverage rate, when the trace data cannot be transferred directly from the MCU to the large-capacity memory in the host computer (for example, when the transfer bandwidth cannot be secured) The normal trace data is transferred from the MCU to a memory provided in the emulator and recorded. However, since the memory that can be installed in the emulator is overwhelmingly small compared to the host computer, if the amount of trace data increases due to long-time program execution, etc., overwriting recording of trace data occurs in the emulator memory, There was a problem that the coverage rate could not be measured.
特許文献1は、トレース高速化とトレースパケット数削減を図るためのトレースデータの選択出力や分岐情報の圧縮や復元方法を開示するが、トレースデータを記憶するためのメモリ容量削減の方法は何ら開示しない。
それゆえに、対象プログラムのカバレッジ計測に係るトレースデータを格納するためのメモリ容量増加を抑制する情報処理装置の提供が望まれる。 Therefore, it is desired to provide an information processing apparatus that suppresses an increase in memory capacity for storing trace data related to coverage measurement of a target program.
その他の課題と新規な特徴は、本明細書の記述および添付図面から明らかになるであろう。 Other problems and novel features will become apparent from the description of the specification and the accompanying drawings.
本発明の一実施形態では、情報処理装置は、複数の分岐命令を含むプログラムを実行時に、分岐命令が実行される毎に当該分岐命令の分岐元データと対応の分岐先データとを入力する入力部と、複数の分岐命令に関するデータを格納するためのメモリと、メモリのアクセスを制御するための制御部と、を備える。制御部は、入力部が入力する分岐命令の分岐先データに基づくメモリのアドレス指定領域に、当該分岐命令の次位に実行される分岐命令について入力する分岐元データを格納する。 In one embodiment of the present invention, when an information processing apparatus executes a program including a plurality of branch instructions, an input for inputting branch source data of the branch instruction and corresponding branch destination data each time the branch instruction is executed And a memory for storing data relating to a plurality of branch instructions, and a control unit for controlling access to the memory. The control unit stores branch source data to be input for a branch instruction to be executed next to the branch instruction in the addressing area of the memory based on the branch destination data of the branch instruction input by the input unit.
本発明の一実施形態の情報処理装置は、対象プログラムのカバレッジ計測に係るトレースデータを格納するために必要なメモリ容量が増加するのを抑制する。 An information processing apparatus according to an embodiment of the present invention suppresses an increase in memory capacity necessary for storing trace data related to coverage measurement of a target program.
以下、図面を参照しつつ、発明の各実施の形態について説明する。以下の説明では、同一の部品には同一の符号を付してある。それらの名称および機能も同じである。したがって、それらについての詳細な説明は繰り返さない。 Hereinafter, embodiments of the invention will be described with reference to the drawings. In the following description, the same parts are denoted by the same reference numerals. Their names and functions are also the same. Therefore, detailed description thereof will not be repeated.
本実施の形態では、アドレス指定されてアクセス(データの読出/書込み)される領域を“アドレス領域”と称する。アドレス指定のために用いるデータを“アドレス”と称する。アドレス指定に用いるアドレスはヘキサデシマル(16進法)に従う値を示す。本実施の形態では、“アドレス値”という場合には、このヘキサデシマルの値を示す。なお、アドレスの表現はヘキサデシマルに従う表現に限定されない。 In the present embodiment, an addressed and accessed (data read / write) area is referred to as an “address area”. Data used for addressing is referred to as “address”. The address used for addressing indicates a value according to hexadecimal (hexadecimal). In this embodiment, the “address value” indicates this hexadecimal value. The address expression is not limited to the expression according to hexadecimal.
また、“カバレッジ”(または、カバレッジ率)は、対象プログラムの全命令文(プログラムコード)について、対象プログラムの実行時に、どれくらい実行されたかを示す値であり、いわゆるC0カバレッジと呼ばれる。 “Coverage” (or coverage rate) is a value indicating how much of all the command statements (program code) of the target program is executed when the target program is executed, and is called so-called C0 coverage.
[実施の形態1]
<システム構成>
図1は、本発明の実施の形態1に係るシステムの概略構成図である。図1を参照して、システムは、情報処理装置に相当するICEなどのエミュレータ100、エミュレータ100にデータ伝送路であるバス500を介し接続されるMCU200、およびエミュレータ100にケーブル400を介し接続されるホストコンピュータ300を備える。エミュレータ100は、ICEなどの情報処理装置に相当する。
[Embodiment 1]
<System configuration>
FIG. 1 is a schematic configuration diagram of a system according to
ケーブル400の通信フォーマットは、たとえばUSB(Universal Serial Bus)を適用するが、USBに限定されない。また、エミュレータ100とホストコンピュータ300とは、ケーブル400による有線通信に限定されず、無線通信であってもよい。
The communication format of the
MCU200は、基板上にCPU(Central Processing Unit)201、I/O回路202、データおよびプログラムを格納するための記憶部203、およびOCD回路204を備える。I/O回路202は、バス500が接続されてバス500とMCU200との間でのデータ入出力を制御する。これら各部は、通信用のバスを介して相互に接続される。
The
記憶部203は、揮発性/不揮発性メモリ、ROM(Read Only Memory)およびRAM(Random Access Memory)などを含む。
The
OCD(On Chip Debugging Emulator)回路204は、後述するパケットを生成しI/O回路202に出力する。I/O回路202は、OCD回路204からのパケットを含むデータを入力し、転送用フォーマット従い変換し、変換後のデータをバス500に出力する。
An OCD (On Chip Debugging Emulator)
<分岐命令に係る分岐元/分岐先データ>
本実施の形態では、カバレッジ率の計測対象プログラム(以下、対象プログラムという)は複数の分岐命令を含む。対象プログラムが実行されるときに分岐命令が実行されると、当該分岐命令の分岐元を示す分岐元データと、分岐先を示す分岐先データが検出される。
<Branch source / branch destination data related to branch instruction>
In the present embodiment, a coverage rate measurement target program (hereinafter referred to as a target program) includes a plurality of branch instructions. When a branch instruction is executed when the target program is executed, branch source data indicating the branch source of the branch instruction and branch destination data indicating the branch destination are detected.
具体的には、MCU200において、対象プログラムのプログラムコードは記憶部203の予め定められた記憶領域に格納される。プログラム実行時には、CPU201内の図示しないプログラムカウンタのカウント値に基づくアドレス指定により記憶部203の対象プログラム中の命令を読出し、読出した命令を実行する。命令が実行されると、プログラムカウンタのカウント値は、次位の命令を格納したアドレスを指示するようにインクリメントされる。CPU201は、インクリメント後のカウント値に基づくアドレス指定により次位の命令を読出し、読出した命令を実行する。これにより、記憶部203に格納される対象プログラムが実行される。
Specifically, in the
対象プログラム実行時に、CPU201が、分岐命令を実行したとき、OCD回路204はCPU201−記憶部203間の図示しないバスを監視して分岐元データと分岐先データを取得する。ここでは、分岐元データは、分岐命令が格納されていたアドレスを示し、分岐先データは、分岐命令を実行したときにインクリメントされた後のプログラムカウンタのカウント値に基づくアドレスを示す。つまり、分岐先データ、分岐命令により分岐(jumpなど)した先の命令が格納されたアドレスを示す。
When the
図2は、本発明の実施の形態1に係るホストコンピュータ300のハードウェア構成図である。図2を参照してホストコンピュータ300は一般的な情報処理装置に相当する。具体的には、CPU301、揮発/不揮発メモリ、ROM、RAMおよびハードディスクなどを含む記憶部302、ケーブル400が接続される通信部303、表示部304、タイマ305、および入力部306を備える。さらに、CD−ROM(Compact Disc Read Only Memory)308などの記録媒体が着脱自在に装着されて、装着される記録媒体をアクセスするためのI/F(Interface)307を備える。各部は、バスを介し通信する。記憶部302は、CPU301が解析するべきデータ(以下、解析データという)が格納される予め定められた記憶領域である解析用メモリ312を含む。また、入力部306は、マウス、キーボードなどによるユーザ操作を受付けて、受付けた操作内容に従う指令・データを入力する。
FIG. 2 is a hardware configuration diagram of the
ホストコンピュータ300とエミュレータ100間では、ケーブル400などによる通信ではなく、CD−ROM308などの記録媒体を介してデータ転送するとしてもよい。
Data may be transferred between the
なお、ホストコンピュータ300は図1のように据え置き型に限定されず、携帯型の情報処理端末であってもよい。
The
<エミュレータの構成およびパケット構成>
図3は、本発明の実施の形態1に係るエミュレータ100のハードウェア構成とパケット構成を示す図である。図3(A)のエミュレータ100は、バス500が接続される入力部107、不揮発性のRAMなどからなるカバレッジ計測用メモリ101、およびカバレッジ計測用メモリ101を制御するためのメモリ制御回路102を備える。これら回路に関連して、さらに、メモリアドレスレジスタ103、分岐元保持レジスタ104、分岐元アドレス値の大小比較をするための大小比較器105、および分岐先保持レジスタ106を備える。カバレッジ計測用メモリ101は、MCU200におけるプログラム実行に伴って出力されるトレースデータを記録するためのメモリであって、とりわけ分岐命令に関する情報(以降、分岐情報という)を格納するためのメモリである。
<Emulator configuration and packet configuration>
FIG. 3 is a diagram showing a hardware configuration and a packet configuration of the
メモリ制御回路102は、アドレス113によりカバレッジ計測用メモリ101をアドレス指定し、指定されたアドレス領域についてデータ114を読み書きする。
The
入力部107は、入力するデータを出力するために図示しないマルチプレクサを有する。
The
図3(B)には、トレースバス500を介し転送されるパケットのフィールド構成が示される。OCD回路204は、対象プログラムを実行時に、分岐命令が実行されると、当該分岐命令のためのパケットを生成する。CPU201は実行される命令コードの種類を判別し、分岐命令であると判定したときは、OCD回路204にパケット生成を指示するとともに、分岐命令に係る分岐元データおよび分岐先データを出力する。
FIG. 3B shows a field configuration of a packet transferred via the
図3(B)を参照しパケットは、当該パケットの種類、当該パケットの宛先/送信元などを示す情報HEを格納するためのヘッダフィルードおよび転送するべきデータを格納するためのデータフィルードを含む。データフィルードには、CPU201が出力する分岐元データ112および分岐先データ111がセット(組)で格納される。
With reference to FIG. 3B, the packet includes a header field for storing information HE indicating the type of the packet, the destination / source of the packet, and the like, and a data field for storing data to be transferred. In the data field,
エミュレータ100の入力部107は、MCU200からパケットを入力し、入力パケットの情報HEを解析する。解析結果に基づき、当該パケットの種類が分岐情報を格納したパケットであると検出すると、マルチプレクサを、当該パケットの分岐元データ112を大小比較器105へ出力し、分岐先データ111をメモリアドレスレジスタ103に出力するように制御する。
The
ここでは、説明を簡単にするために、MCU200で対象プログラムが実行中は、分岐命令が実行される毎に、当該分岐命令のパケットがバス500を介しエミュレータ100に伝送されるとする。
Here, to simplify the description, it is assumed that a packet of a branch instruction is transmitted to the
<カバレッジ計測用メモリへの記録アルゴリズム>
図4は、本発明の実施の形態1に係るカバレッジ計測のためのメイン処理のフローチャートである。図4を参照して、メイン処理は、カバレッジ計測用メモリ101へのデータ記録処理(ステップT1)と、カバレッジ計測用メモリ101の記録データのカバレッジ計測に係る解析処理(ステップT2)とを含む。
<Recording algorithm to coverage measurement memory>
FIG. 4 is a flowchart of the main process for coverage measurement according to
図5は、本発明の実施の形態1に係るカバレッジ計測用メモリ101へのデータ記録処理のフローチャートである。なお、カバレッジ計測用メモリ101のメモリアドレスそれぞれは、MCU200の記憶部203のプログラム記憶領域のアドレスに1対1に割付けられる。割付け後に、カバレッジ計測用メモリ101は初期化される。初期化では、全アドレス領域にゼロが格納される。これをゼロクリアという。
FIG. 5 is a flowchart of data recording processing to the
その後、MCU200で、対象プログラムが実行開始される。MCU200のOCD回路204は、当該プログラムの実行開始をエミュレータ100に通知する。エミュレータ100は、当該通知をバス500を介し入力すると、図5の処理を開始する。
Thereafter, the
ここでは、プログラムは先頭アドレスのプログラムコードから実行開始され、以降のアドレスのプログラムコードが順次に実行される。なお、実行開始アドレスは、先頭アドレスに固定されず、ユーザ指示に従い可変に変更できるとしてもよい。 Here, the program starts to be executed from the program code at the head address, and the program codes at the subsequent addresses are sequentially executed. Note that the execution start address is not fixed to the head address, but may be variably changed according to a user instruction.
エミュレータ100の入力部107は、バス500からパケットを入力すると(ステップS3)、パケットのデータ部の分岐先データ111が示すアドレス値をメモリアドレスレジスタ103に格納する(ステップS7)。
When the packet is input from the bus 500 (step S3), the
メモリ制御回路102は、メモリアドレスレジスタ103に格納された値(アドレス値)に基づき、カバレッジ計測用メモリ101をアドレス指定する(ステップS9)。そして、指定アドレス領域からデータを読出し、読出したデータを分岐元保持レジスタ104に格納する(ステップS11)。これと同時に、メモリアドレスレジスタ103の内容を分岐先保持レジスタ106に転送する(ステップS13)。
The
その後、入力部107により次位に実行される分岐命令のパケットを入力する(ステップS15)。 Thereafter, a packet of a branch instruction to be executed next is input by the input unit 107 (step S15).
大小比較器105は、入力パケットの分岐元データ112のアドレス値と分岐元保持レジスタ104の値(プログラム実行開始後の初回の比較では当該値はゼロを示す)とを比較する(ステップS17)。メモリ制御回路102は、比較結果に基づき、前者が後者より大きいと判定した場合には(ステップS19でYES)、分岐先保持レジスタ106の値(前回に入力したパケットの分岐先データ111が示す分岐先アドレス)に基づくカバレッジ計測用メモリ101のアドレス指定領域の値を、今回入力したパケットの分岐元データ112が示す分岐元アドレス値に書換える(ステップS21)。
The
また、比較の結果から、入力する分岐元データ112が示すアドレス値は分岐元保持レジスタ104の値以下であると判定したときは(ステップS19でNO)、書換え(ステップS21)を行なわずに、ステップS23に移行する。
If it is determined from the comparison result that the address value indicated by the
MCU200は対象プログラム実行を終了したとき、実行終了通知をエミュレータ100に通知する。
When the
エミュレータ100の入力部107が、実行終了通知を入力すると、図5の処理を終了し(ステップS23でYES)、元の図4の処理に戻る。実行終了通知を入力しない間は(ステップS23でNO)、ステップS7に戻る。
When the
以降は、トレースデータであるパケットを入力する毎に、当該パケット中の分岐情報に基づきステップS7〜ステップS21を実行する。 Thereafter, each time a packet that is trace data is input, steps S7 to S21 are executed based on branch information in the packet.
以上の記録処理により、カバレッジ計測用メモリ101のアドレス(分岐命令の分岐先アドレスに対応)には、次位の分岐命令の分岐元アドレスの値が格納される形式でトレースデータが記録される。 By the above recording process, the trace data is recorded in the address of the coverage measurement memory 101 (corresponding to the branch destination address of the branch instruction) in a format in which the value of the branch source address of the next branch instruction is stored.
また、大小比較器105およびメモリ制御回路102によるアドレス値の比較処理および、比較結果に基づく、カバレッジ計測用メモリ101の分岐先アドレス値の書換え処理(ステップS21)により、カバレッジ計測用メモリ101の格納される分岐元アドレス値は、先行する分岐先アドレスから連続して実行されたプログラムコードが格納されたアドレス領域のサイズを示す。
Further, the
<トレースデータの解析>
図6は、本発明の実施の形態1に係るカバレッジ計測に係る解析処理のフローチャートである。図6を参照して解析処理(図4のステップT2)を説明する。なお、予めホストコンピュータ300の記憶部302には、MCU200における対象プログラムのプログラムコード格納領域と同じサイズの解析用メモリ312が確保されて、ゼロクリアされていると想定する。
<Analysis of trace data>
FIG. 6 is a flowchart of analysis processing related to coverage measurement according to
CPU301は、エミュレータ100と通信することにより、カバレッジ計測用メモリ101の先頭アドレスからデータを順番に読出す(ステップS23)。読出したデータが“ゼロ”であるか否かを判定する(ステップS25)。“ゼロ”であると判定すると(ステップS25でNO)、ステップS23に戻り、カバレッジ計測用メモリ101の次位のアドレスからデータを読出し、以降の処理を繰返す。
The
一方、“ゼロ”でないと判定すると(ステップS25でYES)、解析用メモリ312に対しマーキングする(ステップS27)。マーキングは、対象プログラム中の実行済みのプログラムコードを示すための処理を示す。具体的には、解析用メモリ312の分岐先アドレス(カバレッジ計測用メモリ101の直前のステップS23でデータ読出がされたアドレス)から次の分岐元アドレス(カバレッジ計測用メモリ101の直前のステップS23で読出されたアドレス値)までの各アドレス領域に、マークデータを格納する。マークデータは、実行されなかったプログラムコードから区別できるものであればよく、たとえば値“1”、フラグなどである。本実施の形態では、値“1”を格納する。
On the other hand, if it is determined that it is not “zero” (YES in step S25), the
その後、CPU301は、カバレッジ計測用メモリ101のトレースデータが格納されている最終アドレス領域のデータを読出したか否かを判定し(ステップS29)、未だ最終アドレス領域のデータを読出していないと判定すると(ステップS29でNO)、ステップS23に戻るが、読出したと判定すると(ステップS29でYES)、図6の処理は終了し、図4の元の処理に戻る。
Thereafter, the
以上の解析処理により、最終的に解析用メモリ312にはMCU200で実行されたプログラムコードが格納されたアドレス領域のみに実行済みマークが格納されたカバレッジ計測の結果が生成される。生成されたカバレッジ計測結果は、表示部304などの出力デバイスを介して出力される。
As a result of the above analysis processing, the result of coverage measurement in which the executed mark is stored only in the address area in which the program code executed by the
ここで、対象プログラム中の各分岐命令の分岐先データが、異なる分岐先アドレスを示す場合のカバレッジ計測について、以下に具体的に説明する。 Here, the coverage measurement in the case where the branch destination data of each branch instruction in the target program indicates a different branch destination address will be specifically described below.
<トレースデータの具体例>
図7は、本発明の実施の形態1に係るカバレッジ計測用メモリ101に記憶されるデータ例を説明する図である。図7(A)を参照して、MCU200でプログラム実行が開始されるとトレースが開始される。トレース開始されると実行される分岐命令毎に、パケットが出力される。ここでは、出力されるパケットを示すトレース(1)〜(4)それぞれは、分岐先データ111および分岐元データ112のセットを含む。なお、図中では(1)〜(4)は、括弧に代替して丸を用いている。
<Specific examples of trace data>
FIG. 7 is a diagram for explaining an example of data stored in the
MCU200から各分岐命令に対応する図7(A)の分岐情報が出力される場合に、カバレッジ計測用メモリ101には図5のフローチャートに従って、図7(B)に示すようデータが格納される。つまりに、図7(B)の制御部110は、各分岐命令について、対応の分岐先データ111が示す分岐先アドレスに対応するカバレッジ計測用メモリ101のアドレス領域に、次位に実行される分岐命令の分岐元データ112が示す分岐元アドレスを格納する。カバレッジ計測用メモリ101は、計測対象のプログラムコードサイズ分のメモリ領域101Eを有する。
When the branch information of FIG. 7A corresponding to each branch instruction is output from the
なお、制御部110は、図3(A)のエミュレータ100の入力部107を除く部分を示す。
Note that the
この構成によると、分岐先データ111(すなわち、分岐先アドレス)をカバレッジ計測用メモリ101のアドレスで置き換えることができる。その結果、カバレッジ計測用メモリ101に格納するべきデータは、分岐先データ111(すなわち、分岐先アドレス)のみで済ませることができ、従来方式(分岐先データ111と分岐元データ112のセットを格納する方式)に比較し、カバレッジ計測用メモリ101に必要なメモリ容量を少なくすることができる。
According to this configuration, the branch destination data 111 (that is, the branch destination address) can be replaced with the address of the
図8は、本発明の実施の形態1に係る対象プログラムと、カバレッジ計測用メモリ101の格納データとを模式的に示す図である。図8(A)は、カバレッジ計測用メモリ101に格納されるデータの一例を示し、図8(B)はMCU200の記憶部203の予め定められた領域に格納された対象プログラムを模式的に示す。
FIG. 8 is a diagram schematically showing a target program according to
図8(B)を参照して、記憶部203の予め定められた領域はアドレスH´0100〜H´0500で指定されるアドレス領域を含む。当該予め定められた領域に格納された対象プログラムはたとえば3個の分岐命令を含む。対象プログラムが実行開始されると、まず1番目の分岐命令が実行される。
Referring to FIG. 8B, the predetermined area of
1番目の分岐命令が実行されるときに出力されるパケットには、分岐元アドレス、すなわち1番目の分岐命令が格納されているアドレスH´0000と分岐先アドレスH´0100とが格納される。2番目の分岐命令が実行されるときに出力されるパケットには分岐元アドレス、すなわち当該分岐命令が格納されているアドレスH´0200と分岐先アドレスH´0300が検出される。3番目の分岐命令が実行されるときに出力されるパケットには分岐元アドレス、すなわち当該分岐命令が格納されているアドレスH´0400と分岐先アドレスH´0000が検出される。なお、3番目の分岐命令が実行されるときにプログラム実行は終了する。プログラム実行終了を検出したOCD回路204は、分岐先アドレスとしてアドレスH´0000を生成する。
The packet that is output when the first branch instruction is executed stores the branch source address, that is, the address H′0000 where the first branch instruction is stored and the branch destination address H′0100. In the packet output when the second branch instruction is executed, a branch source address, that is, an address H′0200 and a branch destination address H′0300 in which the branch instruction is stored are detected. In the packet output when the third branch instruction is executed, a branch source address, that is, an address H′0400 and a branch destination address H′0000 in which the branch instruction is stored is detected. Note that program execution ends when the third branch instruction is executed. The
図8(B)では、破線はCPU201が実行する命令の実行フローを模式的に示し、実線が示すアドレス領域は対象プログラムのプログラムコードが格納されたアドレス領域を含む。また、当該破線に関連付けてアドレス値(H´0100〜H´0500)が示される。実線に重畳して示される長方形はカバレッジ計測時に実行されたプログラムコードの格納領域を示す。具体的には、長方形の長手方向の長さは、実行されたプログラムコードが格納されたアドレス領域のサイズを示す。
In FIG. 8B, the broken line schematically shows the execution flow of instructions executed by the
図8のカバレッジ計測を、図5のフローチャートに従い説明する。なお、エミュレータ100では、あらかじめカバレッジ計測用メモリ101は初期化(ゼロクリア)されている。MCU200により、対象プログラムの実行が開始されると、カバレッジ計測が開始される。
The coverage measurement of FIG. 8 will be described according to the flowchart of FIG. In the
まず、1番目の分岐命令が実行されると、エミュレータ100は、分岐先アドレスH´0100と分岐元アドレスH´0000を格納したパケットを入力し(ステップS3)、パケットの分岐先アドレスH´0100はメモリアドレスレジスタ103に格納される(ステップS7)。
First, when the first branch instruction is executed, the
メモリ制御回路102は、メモリアドレスレジスタ103に格納されたアドレスH´0100に基づくアドレス指定により、カバレッジ計測用メモリ101から分岐元アドレス値(このときは、ゼロ)を読出し、読出したデータを分岐元保持レジスタ104に格納する(ステップS9、S11)。これと同時に、メモリアドレスレジスタ103に格納されているアドレス値(H´0100)を分岐先保持レジスタ106へ転送する(ステップS13)。
The
その後、2番目の分岐命令のパケットを入力する(ステップS15)。大小比較器105は、当該パケットの分岐元アドレスH´0200と分岐元保持レジスタ104の値(このときは、ゼロ)とを比較する(ステップS16)。そして、比較結果に基づき、前者が後者より大きいと判定する(ステップS19でYES)。メモリ制御回路102は分岐先保持レジスタ106のアドレス値(1番目の分岐命令の分岐先アドレスH´0100)に基づきカバレッジ計測用メモリ101をアドレス指定する。そしてし、当該アドレス指定領域の値を、2番目の分岐命令のパケットの分岐元アドレスH´0200に書換える(ステップS21)。
Thereafter, the packet of the second branch instruction is input (step S15). The
これにより、カバレッジ計測用メモリ101では、1番目の分岐命令の分岐先アドレスH´0100が指定する領域に、次位(2番目)の分岐命令の分岐元アドレス値(H´0200)が格納される。
Thus, in the
まだ、プログラムの実行終了とは判定されないので(ステップS23でNO)、ステップS7に戻る。 Since it is not yet determined that the program has been executed (NO in step S23), the process returns to step S7.
2番目の分岐命令のパケットの分岐先アドレスH´0300はメモリアドレスレジスタ103に格納される(ステップS7)。メモリ制御回路102は、メモリアドレスレジスタ103に格納されたアドレスH´0300に基づくアドレス指定により、カバレッジ計測用メモリ101から分岐元アドレス値(このときは、ゼロ)を読出し、読出したデータを分岐元保持レジスタ104に格納する(ステップS9、S11)。これと同時に、メモリアドレスレジスタ103に格納されているアドレス値(H´0300)を分岐先保持レジスタ106へ転送する(ステップS13)。
The branch destination address H′0300 of the packet of the second branch instruction is stored in the memory address register 103 (step S7). The
その後、3番目の分岐命令のパケットを入力する(ステップS15)。大小比較器105は、当該パケットの分岐元アドレスH´0400と分岐元保持レジスタ104の値(このときは、ゼロ)とを比較する(ステップS16)。比較結果に基づき、前者が後者より大きいと判定する(ステップS19でYES)。メモリ制御回路102は分岐先保持レジスタ106のアドレス値(2番目の分岐命令の分岐先アドレスH´0300)に基づきカバレッジ計測用メモリ101をアドレス指定する。そして、当該アドレス指定領域の値を3番目の分岐命令のパケットの分岐元アドレスH´0400に書換える(ステップS21)。
Thereafter, the third branch instruction packet is input (step S15). The
これにより、カバレッジ計測用メモリ101では、2番目の分岐命令の分岐先アドレスH´0300が指定する領域に、次位(3番目)の分岐命令の分岐元アドレス値(H´0400)が格納される。
Thus, in the
その後、プログラムの実行終了と判定されるので(ステップS23でYES)、処理は元の図4に戻る。これにより、カバレッジ計測用メモリ101へのトレースデータの格納は終了する。
Thereafter, since it is determined that the execution of the program has ended (YES in step S23), the processing returns to the original FIG. Thereby, the storage of the trace data in the
図8(B)の対象プログラムを実行すると、カバレッジ計測用メモリ101には、図8(A)に示すように、1番目の分岐命令の分岐先アドレスH´0100で指定されるアドレス領域には2番目の分岐命令の分岐元アドレスH´0200が格納される。そして、2番目の分岐命令の分岐先アドレスH´0300で指定されるアドレス領域には3番目の分岐命令の分岐元アドレスH´0400が格納される。このように、カバレッジ計測用メモリ101には、アドレス(分岐命令の分岐先アドレスに対応)領域に、次位に実行される分岐命令の分岐元アドレスの値が格納されるようにトレースデータが記録される。
When the target program shown in FIG. 8B is executed, the
<解析処理の具体例>
図9は、本発明の実施の形態に係るカバレッジ計測用メモリ101の格納データに対する解析処理の具体例を示す図である。
<Specific examples of analysis processing>
FIG. 9 is a diagram showing a specific example of analysis processing for data stored in the
図9では、図8に従ってカバレッジ計測用メモリ101に格納されたデータを、図6の手順で解析した結果(1)〜(7)(図中では括弧は丸に代替されている)が示される。ここでは、解析用メモリ312は、記憶部203の対象プログラムのプログラムコード領域と同じサイズを有する。解析用メモリ312は、アドレスH´0000〜H´FFFFで指定されるアドレス領域を有する。CPU301は、記憶部203のプログラムコード記憶領域のアドレスに1対1に割付けられたカバレッジ計測用メモリ101の全アドレス領域のうち、分岐元アドレス値が格納されているアドレス領域が占める大きさを検出する。
FIG. 9 shows the results (1) to (7) obtained by analyzing the data stored in the
まず、ホストコンピュータ300のCPU301は、解析用メモリ312を初期化(ゼロクリア)する(結果(1)を参照)。
First, the
その後、CPU301は、カバレッジ計測用メモリ101の先頭アドレスH´0000の領域から読出処理を開始する。読出された値が初期値(ゼロ)と判定すると、すなわち当該アドレス領域には分岐元アドレス値は格納されていないと判定すると、次位のアドレス領域を読出処理する。このようにして、先頭アドレスH´0000〜アドレスH´00FFまでの各アドレス領域の読出処理を繰返すと、各アドレス領域から読出された値はゼロと判定されるので、上述したマーキングは実行されない(結果(2)を参照)。
Thereafter, the
その後、CPU301は、アドレスH´0100の領域から分岐元アドレス値(H´0200)を読出す。したがって、CPU301は、解析用メモリ312のアドレスH´0100〜H´0200の各アドレス領域をマーキングする。ここでは、各アドレス領域に“1”を格納する(結果(3)を参照)。
Thereafter, the
続くアドレスH´0101からH´02FFまでの各アドレス領域から読出される値はゼロであるから、上述したマーキングは実行されない(結果(4)を参照)。 Since the value read from each address area from the subsequent addresses H′0101 to H′02FF is zero, the above-described marking is not executed (see result (4)).
その後、CPU301は、アドレスH´0300のアドレス領域からアドレスH´0400を読出す。したがって、CPU301は、解析用メモリ312のアドレスH´0300〜H´0400の各アドレス領域に“1”を格納する(結果(5)を参照)。
Thereafter, the
続くアドレスH´0301からH´FFFFまでの各アドレス領域から読出される値はゼロであるから、上述したマーキングは実行されない(結果(6)を参照)。 Since the value read from each address area from the subsequent addresses H′0301 to H′FFFF is zero, the above-described marking is not executed (see result (6)).
最終的に、解析用メモリ312には、先頭アドレス(H´0000)〜最終アドレス(H´FFFF)までの各アドレス領域には上記の結果(1)〜(6)の値(1または0)が格納されたカバレッジ解析結果が格納される(結果(7)を参照)。
Finally, the
これにより、カバレッジ計測用メモリ101の全アドレス領域のうち、分岐元アドレス値が格納されているアドレス領域が占める大きさが検出される。
As a result, the size occupied by the address area in which the branch source address value is stored in the entire address area of the
CPU301は、表示部304に図9の結果(7)に基づく画像または情報を表示する。これにより、ユーザは、対象プログラムについてのカバレッジ計測結果を確認することができる。画像としては、たとえば、結果(7)の“1”の部分のみを色を反転して表示する。
The
また、情報としては、結果(7)をもとに、対象プログラムの全プログラムコード数に対する実行されたコード数が占める割合を算出して表示してもよい。すなわち、記憶部203の対象プログラムコード記憶領域のアドレスに1対1に割付けられたカバレッジ計測用メモリ101の全アドレス領域のうち、分岐元アドレス値が格納されているアドレス領域の割合い、すなわちカバレッジ(網羅率)を算出して表示するとしてもよい。
As information, the ratio of the number of executed codes to the total number of program codes of the target program may be calculated and displayed based on the result (7). That is, the ratio of the address area in which the branch source address value is stored among all the address areas of the
なお、出力は表示に限定されず、印刷であってもよい。
<実施の形態1の効果>
本実施の形態1と対比した従来のトレースデータの記録方法によるカバレッジ計測では、以下の課題が残る。
Note that the output is not limited to display but may be printing.
<Effect of
In the coverage measurement by the conventional trace data recording method compared with the first embodiment, the following problems remain.
課題(1):対象プログラムを実行後のソフトウェアによるトレースデータの解析処理に要する時間が、記録されたトレースデータ量が増加するほど増加する。このため、エミュレータで大量のトレースデータを取得している場合、解析に長時間を要する。 Problem (1): The time required for the analysis process of the trace data by the software after executing the target program increases as the amount of recorded trace data increases. For this reason, when a large amount of trace data is acquired by an emulator, analysis takes a long time.
課題(2):トレースデータの記録に、エミュレータに搭載しているトレースメモリ(カバレッジ計測用メモリ101に相当)を使用するような場合、トレースメモリの容量を超えるトレースデータが出力されるケースでは、当該要領を超えたトレースデータはレースメモリに上書きにより格納される。上書きにより、トレースデータの一部が消失し、カバレッジ計測は失敗する。回避策として、トレースメモリの上書きを抑止する処理を追加する方法を適用できる。つまり、トレースデータが格納されてトレースメモリがフルになったときに、MCUによる対象プログラムの実行を停止し、その後、トレースメモリのトレースデータをホストコンピュータへ転送し、転送後に実行停止していた対象プログラムの実行を再開することで上書きを抑止する。しかしながら、処理の追加により、カバレッジ計測のリアルタイム性が損なわれる。 Problem (2): When using trace memory (corresponding to coverage measurement memory 101) installed in the emulator for recording trace data, in the case where trace data exceeding the capacity of the trace memory is output, Trace data exceeding this point is stored in the race memory by overwriting. Due to overwriting, part of the trace data is lost and coverage measurement fails. As a workaround, it is possible to apply a method of adding processing for suppressing overwriting of the trace memory. In other words, when the trace data is stored and the trace memory becomes full, the execution of the target program by the MCU is stopped, then the trace data in the trace memory is transferred to the host computer, and the execution that has been stopped after the transfer Overwriting is suppressed by resuming program execution. However, the real-time property of coverage measurement is impaired by the addition of processing.
本実施の形態1では、上記の課題を解消する効果を得ることができる。
効果(1):図7〜図9に示すカバレッジ計測用メモリ101の使用方法と分岐情報の記録アルゴリズムを用いた場合、カバレッジ計測用メモリ101に格納される分岐情報は、分岐元データ112が示す分岐アドレスのみで済む。また、対象プログラムを実行する時間の長さに関わらずカバレッジ計測用メモリ101に必要な容量をプログラムサイズに応じた固定サイズとすることができて、上記の課題(1)は解消される。
In the first embodiment, it is possible to obtain the effect of solving the above problem.
Effect (1): When the usage method of the
効果(2):カバレッジ計測用メモリ101は、記憶部203の対象プログラムコードを格納した領域に相当サイズのアドレス領域を有すればよい。その場合であっても、対象プログラム中の分岐命令の数に関わらず、またカバレッジ計測用メモリ101の上書きが発生することはなく、上記の課題(2)は解消される。
Effect (2): The
効果(3):ホストコンピュータ300による解析対象は、MCU200からの分岐情報量(パケット数)に影響されずカバレッジ計測用メモリ101に割当てられたプログラムコード領域サイズ分の範囲に限定することができて、常に一定時間での解析が可能である。また、トレースメモリ上書きによる破綻も生じない。
Effect (3): The analysis target by the
効果(4):上述の効果は、対象プログラムを特別な加工をしないで得ることができる。 Effect (4): The above-described effect can be obtained without special processing of the target program.
[実施の形態2]
本実施の形態2では、対象プログラムが、同一アドレスに分岐するような複数の分岐命令を含む場合を説明する。つまり、実施の形態1では、対象プログラム中の各分岐命令の分岐先データは、異なる分岐先アドレスを示す場合であったが、本実施の形態2では、対象プログラム中の複数の分岐命令の分岐先データ111が同じアドレスを示す場合のカバレッジ計測について説明する。
[Embodiment 2]
In the second embodiment, a case where the target program includes a plurality of branch instructions that branch to the same address will be described. That is, in the first embodiment, the branch destination data of each branch instruction in the target program indicates a different branch destination address. However, in the second embodiment, a plurality of branch instructions in the target program are branched. Coverage measurement when the
なお、本実施の形態2でも、図1〜図3の構成と、図4〜図6のフローチャートが適用されるので、これらの説明は繰り返さない。 In the second embodiment, the configuration shown in FIGS. 1 to 3 and the flowcharts shown in FIGS. 4 to 6 are applied, and the description thereof will not be repeated.
図10は、本発明の実施の形態2に係る対象プログラムと、カバレッジ計測用メモリ101の格納データとを模式的に示す図である。図10(A)は、カバレッジ計測用メモリ101に格納されるデータの一例を示し、図10(B)はMCU200の記憶部203の予め定められた領域に格納された対象プログラムを模式的に示す。
FIG. 10 is a diagram schematically showing the target program according to the second embodiment of the present invention and the data stored in the
図10(B)を参照して、記憶部203の予め定められた領域はアドレスH´0100〜H´0500で指定されるアドレス領域を含む。当該予め定められた領域に格納された対象プログラムはたとえば4個の分岐命令を含む。対象プログラムが実行開始されると、1番目の分岐命令が実行される。
Referring to FIG. 10B, the predetermined area of
1番目の分岐命令が実行されるときに出力されるパケットには、分岐元アドレスH´0000と分岐先アドレスH´0100とが格納される。2番目の分岐命令が実行されるときに出力されるパケットには分岐元アドレスH´0200と分岐先アドレスH´0300が格納される。3番目の分岐命令が実行されるときに出力されるパケットには分岐元アドレスH´0400と分岐先アドレスH´0300が格納される。4番目の分岐命令が実行されるときに出力されるパケットには分岐元アドレスH´0500と分岐先アドレスH´0000が格納される。なお、4番目の分岐命令が実行されるときにプログラム実行は終了する。プログラム実行終了を検出するとOCD回路204は、分岐先アドレスとしてアドレスH´0000を検出する。
The packet that is output when the first branch instruction is executed stores the branch source address H′0000 and the branch destination address H′0100. A packet that is output when the second branch instruction is executed stores a branch source address H′0200 and a branch destination address H′0300. The packet that is output when the third branch instruction is executed stores the branch source address H′0400 and the branch destination address H′0300. The packet that is output when the fourth branch instruction is executed stores the branch source address H′0500 and the branch destination address H′0000. Note that the program execution ends when the fourth branch instruction is executed. When detecting the end of program execution, the
上記の1番目、2番目および3番目の分岐命令が実行された場合には、図10(A)のカバレッジ計測用メモリ101では、実施の形態1と同様に、1番目の分岐命令の分岐先アドレスH´0100で指定されるアドレス領域には2番目の分岐命令の分岐元アドレス値(H´0200)が格納される。そして、2番目の分岐命令の分岐先アドレスH´0300で指定されるアドレス領域には3番目の分岐命令の分岐元アドレス値(H´0400)が格納される。
When the first, second, and third branch instructions are executed, in the
まだ、プログラムの実行終了とは判定されないので(ステップS23でNO)、ステップS7に戻る。 Since it is not yet determined that the program has been executed (NO in step S23), the process returns to step S7.
3番目の分岐命令のパケットの分岐先アドレスH´0300はメモリアドレスレジスタ103に格納される(ステップS7)。メモリ制御回路102は、メモリアドレスレジスタ103に格納されたアドレスH´0300に基づくアドレス指定により、カバレッジ計測用メモリ101から分岐元アドレス値(このときは、H´0400)を読出し、読出したデータを分岐元保持レジスタ104に格納する(ステップS9、S11)。これと同時に、メモリアドレスレジスタ103に格納されているアドレス値(H´0300)を分岐先保持レジスタ106へ転送する(ステップS13)。
The branch destination address H′0300 of the packet of the third branch instruction is stored in the memory address register 103 (step S7). The
その後、4番目の分岐命令のパケットを入力する(ステップS15)。大小比較器105は、当該パケットの分岐元アドレスH´0500と分岐元保持レジスタ104の値(このときは、H´0400)とを比較し(ステップS16)、比較結果に基づき、前者が後者より大きいと判定する(ステップS19でYES)。メモリ制御回路102は分岐先保持レジスタ106のアドレス値(3番目の分岐命令の分岐先アドレスH´0300)に基づきカバレッジ計測用メモリ101をアドレス指定する。そして、当該アドレス指定領域の値を、4番目の分岐命令のパケットの分岐元アドレス値(H´0500)に書換える(ステップS21)。
Thereafter, the packet of the fourth branch instruction is input (step S15). The
これにより、カバレッジ計測用メモリ101では、2番目の分岐命令の分岐先アドレスH´0300が指定する領域には、4番目の分岐命令の分岐元アドレス値(H´0500)が格納される。
Thus, in the
その後、プログラムの実行終了と判定されるので(ステップS23でYES)、図4の元の処理に戻る。 Thereafter, since it is determined that the execution of the program has ended (YES in step S23), the processing returns to the original processing in FIG.
図10(B)では、図8(B)と同様に、破線はCPU201が実行する命令の実行フローを記憶部203を模式的に示し、実線が示すアドレス領域は対象プログラムのプログラムコードが格納されたアドレス領域を含む。また、実線に関連して示される長方形の長手方向の長さは、実行されたプログラムコードが格納されたアドレス領域のサイズを示す。
In FIG. 10B, as in FIG. 8B, the broken line schematically shows the execution flow of instructions executed by the
上記のように4番目の分岐命令の実行により分岐元アドレスH´0500が検出されて、直前(3番目)の分岐命令の分岐元アドレス値(H´0400)と新たに検出した分岐元アドレス値(H´0500)を比較し、大きい方の値(H´0500)を、カバレッジ計測用メモリ101のアドレス(H´0300)領域に格納する。すなわち、アドレス(H´0300)領域に格納されていた元の値(H´0400)を新たな分岐元アドレス値(H´0500)に書換える。これにより、対象プログラムの実行終了時に、カバレッジ計測用メモリ101の記録内容から、対象プログラムのアドレスH´0300からH´0500までのプログラムコードが実行されたことを示すことができる。
As described above, the branch source address H′0500 is detected by the execution of the fourth branch instruction, and the branch source address value (H′0400) of the immediately preceding (third) branch instruction and the newly detected branch source address value. (H′0500) is compared, and the larger value (H′0500) is stored in the address (H′0300) area of the
<タイミングチャート>
図11は、本発明の実施の形態2に係るエミュレータ100の動作を示すタイミングチャートである。図10の同一分岐先アドレスを有する複数の分岐命令が実行される場合のエミュレータ100の動作を、図11を参照し説明する。
<Timing chart>
FIG. 11 is a timing chart showing the operation of the
図11(A)は、MCU200からのパケットの信号を示す。MCU200からの信号は、エミュレータ100に入力後、エミュレータ100の内部の制御クロック(図11(B)を参照)に同期したトレース情報単位(パケットに相当)である、たとえば図11(C)の“分岐1”〜“分岐4”に整形される。
FIG. 11A shows a packet signal from the
上記の1番目、2番目、3番目および4番目の分岐命令に相当する“分岐1”〜“分岐4”が入力されると(図11(C)と(D)を参照)、メモリアドレスレジスタ103のデータはアドレス値H´0100→H´0300→H´0300と変化する(図11(E)を参照)。当該アドレスはアドレス113に相当する。メモリ制御回路102により、アドレス113により指定されるカバレッジ計測用メモリ101のアドレス領域からデータ114が読出されて(図11(F)と(G)を参照)、読出しデータ114は分岐元保持レジスタ104に格納される(図11(H)参照)。
When “
比較器105は、入力する分岐元アドレス値(図11(C)参照)と分岐元保持レジスタ104のアドレス値とを比較し、比較結果から、前者が後者より大きいと判定する、メモリ制御回路102は分岐先保持レジスタ106のアドレス値(図11(D)、図11(K)参照)に基づきカバレッジ計測用メモリ101をアドレス指定し、当該アドレス指定領域にライトデータレジスタの値(図11(I)参照)を格納する(図11(J)参照)。なお、ライトデータレジスタは、メモリ制御回路102内のレジスタ(図示しない)であって、カバレッジ計測用メモリ101に書込むデータを一時的に格納するためのレジスタを示す。
The
<実施の形態2の効果>
エミュレータ100は、MCU200から同じ分岐先アドレスを示す分岐先データ111を有する複数のパケットを連続して入力した場合に、入力順番に、先に入力したパケットと次位に入力したパケット間の分岐元データ112が示す分岐元アドレスを比較し、比較結果に基づき、大きい方を、カバレッジ計測用メモリ101の当該分岐先アドレス領域に格納するアルゴリズムを採用している。
<Effect of
When the
これにより、同一分岐先アドレスを示す複数の分岐命令が実行される場合には、分岐元アドレス値に関わらず(分岐パターンに関わらず)、カバレッジ計測用メモリ101の当該同一分岐先アドレスが示す領域には、複数分岐命令のうちの最大値を示す分岐元アドレスが格納される。したがって、当該同一分岐先アドレス値と最大の分岐元アドレス値とから、複数分岐命令が実行されたときに連続して実行されたプログラムコードの範囲を記録することができる。したがって、同一分岐先アドレスを示す分岐命令が実行されるようなプログラムを計測対象とする場合であっても、カバレッジ計測用メモリ101のトレースデータ量の増加およびホストコンピュータ300による解析時間の増加を防止できる。
Thus, when a plurality of branch instructions indicating the same branch destination address are executed, the area indicated by the same branch destination address of the
[実施の形態3]
本実施の形態3では、対象プログラムから他のプログラムに分岐する場合を説明する。上述した実施の形態1と2では、分岐先は対象プログラム内を示したが、本実施の形態3では、対象プログラムを実行中に、対象外プログラムに分岐する場合のカバレッジ計測を説明する。ここでは、対象プログラムを実行中に、タイマ割込みが発生し、対象プログラム外の割込プログラムに分岐する場合を想定する。
[Embodiment 3]
In the third embodiment, a case will be described in which the target program branches to another program. In
図12は、本発明の実施の形態3に係る対象プログラムと割込プログラムへの分岐とを説明する図である。図13は、本発明の実施の形態3に係るエミュレータ1000の概略構成図である。図13のエミュレータ1000と図3(A)のエミュレータ100の構成と比較し異なる点は、エミュレータ1000はメモリ制御回路102に代替しメモリ制御回路1020を備える点にある。他の部分は、図3(A)に示したものと同じであり説明は繰り返さない。
FIG. 12 is a diagram for explaining the target program and the branch to the interrupt program according to
図12(A)には、記憶部203に格納されたプログラムが模式的に示される。図12(B)には、図12(A)のプログラム実行時に、実行されるプログラムコードの範囲が太矢印で模式的に示される。図12(C)には、対象プログラム実行時に出力される分岐情報が模式的に示される。
FIG. 12A schematically shows a program stored in the
図12(A)では、対象プログラムのプログラムコードは記憶部203のアドレスH´0100〜H´0280に格納され、割込プログラムは、カバレッジ対象外のアドレスH´10000〜H´10020に格納されている。なお、図12(A)では、対象プログラムの各continue文は、本来、アドレスH´0250に分岐するが、説明の便宜上アドレスH´0140に分岐するものとする。
In FIG. 12A, the program code of the target program is stored at addresses H′0100 to H′0280 of the
動作において、対象プログラムが先頭アドレスのプログラムコードから実行開始されると、図12(B)に示すように矢印(1)〜(8)の順番で各矢印の長さ分のプログラムコードが実行される。各矢印先端(終端)のプログラムコードは分岐命令に相当する。したがって、当該先端に対応するアドレスが分岐元アドレスに相当し、次位の矢印の開始端に対応するアドレスが分岐先アドレスに相当する。 In operation, when the execution of the target program is started from the program code at the head address, the program code for the length of each arrow is executed in the order of arrows (1) to (8) as shown in FIG. The The program code at the tip (end) of each arrow corresponds to a branch instruction. Therefore, the address corresponding to the tip corresponds to the branch source address, and the address corresponding to the start end of the next arrow corresponds to the branch destination address.
図12(A)のアドレス(H´0230)のプログラムコードを実行時にタイマ割込(timer_int)が発生したとする(図12(B)の矢印(5)の先端)。このとき、CPU201は、プログラムカウンタの現在値を図示しないレジスタ(退避レジスタという)に退避させる。これにより、退避レジスタに割込プログラムから対象プログラムに戻るためのアドレス値(H´0230)を格納しておくことができる。
Assume that a timer interrupt (timer_int) occurs when the program code at the address (H′0230) in FIG. 12A is executed (the tip of the arrow (5) in FIG. 12B). At this time, the
その後、プログラムカウンタの値はH´10000に更新されて、アドレスH´10000以降の割込プログラム(図12(B)の斜線部)に分岐して、割込プログラムが実行開始される(図12(B)の矢印(6))。 Thereafter, the value of the program counter is updated to H′10000, and the program branches to the interrupt program after the address H′10000 (the shaded area in FIG. 12B), and the interrupt program starts to be executed (FIG. 12). (B) arrow (6)).
割込プログラムが実行終了すると、CPU201は、プログラムカウンタの値を、退避レジスタの値に基づき書き換える。たとえば、アドレスH´0240を示すように書き換える。これにより、対象プログラムの、タイマ割込(timer_int)発生時点のプログラムコードから(矢印(7)を参照)実行が再開される。
When the execution of the interrupt program ends, the
その後、矢印(7)の先端アドレスで分岐命令が実行されて、矢印(8)で示すプログラムコードが実行される。その後、対象プログラムの実行は終了し、MCU200からエミュレータ1000にプログラム実行終了通知が伝送される。
Thereafter, a branch instruction is executed at the tip address of the arrow (7), and the program code indicated by the arrow (8) is executed. Thereafter, the execution of the target program ends, and a program execution end notification is transmitted from the
図12(A)の対象プログラムを実行中は、実施の形態1および2と同様の処理によりカバレッジ計測用メモリ101に分岐情報が出力される。対象プログラム開始から終了までに出力された分岐先情報(分岐先アドレスと分岐元アドレスのセット)は、図12(C)に模式的に示される。
During execution of the target program in FIG. 12A, branch information is output to the
図12(C)の分岐情報600と700それぞれは、矢印(5)の先端アドレス領域の分岐命令が実行されるときに出力される分岐先情報(分岐先アドレス(H´10000)と分岐元アドレス(H´0230)のセット)と、矢印(6)の先端アドレス領域の分岐命令が実行されるときに出力される分岐先情報(分岐先アドレス(H´0240)と分岐元アドレス(H´10020)のセット)それぞれを示す。
Each of the
分岐情報600の分岐先アドレス(H´10000)は、カバレッジ計測用メモリ101のアドレス指定可能な範囲を超える。分岐情報700の分岐元アドレス(H´10020)を、カバレッジ計測用メモリ101の矢印(5)の分岐先アドレス(H´0240)の領域に格納すれば、誤計測となる。つまり、その後のホストコンピュータ300による解析の結果は、アドレスH´0240〜H´10020までのプログラムコードが実行されたことを示すことになるからである。
The branch destination address (H′10000) of the
そこで、本実施の形態3に係るエミュレータ1000のメモリ制御回路1020は、対象プログラム実行中に、対象プログラムから対象外のプログラムに分岐する場合であっても上記の誤計測とならないように、カバレッジ計測用メモリ101に分岐情報を格納する。
Therefore, the
具体的には、メモリ制御回路1020は、入力パケットについてデータ600の分岐情報を検出した場合には、すなわちデータ113が示す分岐先アドレス値と閾値とを比較し、比較結果から、当該分岐先アドレス値は閾値よりも大きいと判定したときは、当該データ113を破棄する。そして、次に入力するパケットの分岐情報(すなわちデータ700)の分岐先アドレス(H´02040)を示すデータ113に基づくカバレッジ計測用メモリ101のアドレス指定領域の値を、先に入力していたパケットの分岐情報(すなわち、データ600)の分岐元アドレス(H´0230)値で書換える。なお、上記の閾値は、記憶部203の対象プログラムの記憶領域の最終アドレス値を示し、メモリ制御回路1020内の図示しないレジスタに格納されていると想定する。
Specifically, when the
これにより、カバレッジ計測用メモリ101のアドレスH´0240の領域に分岐元アドレスH´0230を格納することができて、対象プログラム実行中に、対象プログラム内から対象外プログラムへ分岐する分岐命令が実行されたとしても、カバレッジ計測用メモリ101に、上記の誤計測のないカバレッジ計測を可能とするトレースデータを格納することができる。
As a result, the branch source address H′0230 can be stored in the area of the address H′0240 of the
<変形例1>
上記の分岐先データ111および分岐元データ112は、分岐先アドレスおよび分岐元アドレスを示すとしたが、これらデータはアドレスに限定されない。たとえば、分岐先データ111および分岐元データ112は、記憶部203の対象プログラムが格納された領域の先頭アドレスを基準としたオフセット値を示すとしてもよい。その場合には、エミュレータ100の内部で、たとえば入力部107で、入力パケットのデータ部に格納されている当該基準とオフセット値とから、分岐先アドレスおよび分岐元アドレスを算出する。
<
Although the above
<変形例2>
上記の実施の形態では、対象プログラムはMCU200で実行されるとしたが、ホストコンピュータ300により実行されるとしてもよい。その場合には、ホストコンピュータ300の記憶部302に対象プログラムを格納し、CPU301が当該対象プログラムを実行する。実行中に検出される分岐情報(分岐命令実行毎に検出される分岐情報)は、図5のフローチャートに従って記憶部302の予め定められたトレース領域(カバレッジ計測用メモリ101に相当)に格納する。そして、対象プログラム実行終了後には、図6のフローチャートに従うプログラムを実行することにより、記憶部302のトレース領域のトレースデータを解析し、たとえば図9に示す解析結果を出力する。
<
In the above embodiment, the target program is executed by the
[実施の形態4]
実施の形態1〜3では、エミュレータ100がトレースデータを記録し、ホストコンピュータ300がトレースデータを解析するとしたが、トレースデータ記録はエミュレータ100に代替してホストコンピュータ300で実行するとしてもよい。その場合に、実施の形態1〜3に示すカバレッジ計測用メモリ101へのデータ格納および解析の処理は、図4〜6のフローチャートに従うプログラムとして提供することができる。このようなプログラムは、コンピュータに付属するCD−ROM、ROM、RAMおよびメモリカードなどのコンピュータ読取り可能な記録媒体にて記録させて、プログラム製品として提供することもできる。あるいは、コンピュータに内蔵するハードディスクなどの記録媒体にて非一時的に記録させて、プログラムを提供することもできる。また、ネットワークを介したダウンロードによって、プログラムを提供することもできる。
[Embodiment 4]
In the first to third embodiments, the emulator 100 records the trace data and the
たとえば、図2の構成では、CPU301を備えるホストコンピュータ300には、CD−ROM308を用いて当該プログラムを供給することができる。CPU301は、I/F307を介してCD−ROM308に格納されたプログラムを読出し、実行する。
For example, in the configuration of FIG. 2, the program can be supplied to the
提供されるプログラム製品は、記憶部302のハードディスクなどのプログラム格納部にインストールされてCPU301により読出されて実行される。なお、プログラム製品は、プログラム自体と、プログラムが記録された記録媒体とを含む。
The provided program product is installed in a program storage unit such as a hard disk in the
上述の実施の形態では、情報処理システムが示される。情報処理システムは、複数の分岐命令を含むプログラムを実行するためのプログラム実行ユニットと、当該プログラム実行ユニットに伝送路を介し接続される情報処理装置を備える。この情報処理装置は、プログラム実行ユニットから、実行される分岐命令の分岐元データと対応の分岐先データとを入力するための入力部と、複数の分岐命令に関するデータを格納するためのメモリと、メモリのアクセスを制御するための制御部と、を備える。 In the above-described embodiment, an information processing system is shown. The information processing system includes a program execution unit for executing a program including a plurality of branch instructions, and an information processing apparatus connected to the program execution unit via a transmission path. The information processing apparatus includes an input unit for inputting branch source data of a branch instruction to be executed and corresponding branch destination data from a program execution unit, a memory for storing data relating to a plurality of branch instructions, A control unit for controlling access to the memory.
上記の制御部は、入力部が入力する分岐命令の分岐先データに基づき指定されるメモリのアドレス領域に、当該分岐命令の次位に実行される分岐命令について入力部が入力する分岐元データを格納する。 The control unit described above stores the branch source data input by the input unit for the branch instruction executed next to the branch instruction in the address area of the memory specified based on the branch destination data of the branch instruction input by the input unit. Store.
また、上述の実施の形態では、プロセッサを備えるコンピュータに、情報処理方法を実行させるためのプログラムが示される。このプログラムは、プロセッサに、複数の分岐命令を含むプログラムを実行するための外部のプログラム実行ユニットから、実行される分岐命令の分岐元データと対応の分岐先データとを入力するステップと、複数の分岐命令に関するデータを格納するためのメモリのアクセスを制御するステップと、を実行させる。アクセスを制御するステップでは、入力するステップにより入力する分岐命令の分岐先データに基づき指定されるメモリのアドレス領域に、当該分岐命令の次位に実行される分岐命令について入力するステップにより入力する分岐元データを格納する。 In the above-described embodiment, a program for causing a computer including a processor to execute an information processing method is shown. The program includes inputting a branch source data of a branch instruction to be executed and corresponding branch destination data from an external program execution unit for executing a program including a plurality of branch instructions to the processor; Controlling access to a memory for storing data relating to the branch instruction. In the step of controlling access, the branch input by the step of inputting the branch instruction executed next to the branch instruction in the address area of the memory specified based on the branch destination data of the branch instruction input by the input step Store the original data.
また、上述の実施の形態では、上記のプログラムを非一時的に記録した機械読取可能な記録媒体が示される。 In the above-described embodiment, a machine-readable recording medium in which the above program is recorded non-temporarily is shown.
以上、本発明者によってなされた発明を実施の形態に基づき具体的に説明したが、本発明は前記実施の形態に限定されるものではなく、その要旨を逸脱しない範囲で種々変更可能であることはいうまでもない。 As mentioned above, the invention made by the present inventor has been specifically described based on the embodiment. However, the present invention is not limited to the embodiment, and various modifications can be made without departing from the scope of the invention. Needless to say.
100 エミュレータ、101 カバレッジ計測用メモリ、102 メモリ制御回路、103 メモリアドレスレジスタ、104 分岐元保持レジスタ、105 大小比較器、106 分岐先保持レジスタ、111 分岐先データ、112 分岐元データ、200 MCU、300 ホストコンピュータ、312 解析用メモリ。 100 Emulator, 101 Coverage measurement memory, 102 Memory control circuit, 103 Memory address register, 104 Branch source holding register, 105 Size comparator, 106 Branch destination holding register, 111 Branch destination data, 112 Branch source data, 200 MCU, 300 Host computer, 312 Memory for analysis.
Claims (8)
前記複数の分岐命令に関するデータを格納するためのメモリと、
前記メモリのアクセスを制御するための制御部と、を備え、
前記制御部は、
前記入力部が入力する分岐命令の前記分岐先データに基づき指定される前記メモリのアドレス領域に、当該分岐命令の次位に実行される分岐命令について前記入力部が入力する分岐元データを格納する、情報処理装置。 When executing a program including a plurality of branch instructions, each time a branch instruction is executed, an input unit for inputting branch source data of the branch instruction and corresponding branch destination data;
A memory for storing data relating to the plurality of branch instructions;
A control unit for controlling access to the memory,
The controller is
The branch source data input by the input unit for the branch instruction executed next to the branch instruction is stored in the address area of the memory specified based on the branch destination data of the branch instruction input by the input unit. Information processing device.
前記指定されるアドレス領域に格納されているデータが示す値と、前記次位に実行される分岐命令について前記入力部が入力する分岐元データが示す値とを比較するための比較部を含み、
前記比較の結果から、前記入力する分岐元データが示す値は前記指定されるアドレス領域のデータが示す値よりも大きいと判定したとき、当該アドレス領域のデータを、当該分岐元データに書換える、請求項1に記載の情報処理装置。 The controller is
A comparison unit for comparing the value indicated by the data stored in the designated address area with the value indicated by the branch source data input by the input unit for the branch instruction executed at the next level;
From the result of the comparison, when it is determined that the value indicated by the input branch source data is larger than the value indicated by the specified address area data, the address area data is rewritten to the branch source data. The information processing apparatus according to claim 1.
前記比較の結果から、前記入力する分岐元データが示す値は前記指定されるアドレス領域のデータが示す値以下であると判定したとき、前記書換えを行わない、請求項2に記載の情報処理装置。 The controller is
3. The information processing apparatus according to claim 2, wherein the rewriting is not performed when it is determined from the result of the comparison that a value indicated by the input branch source data is equal to or less than a value indicated by the data in the designated address area. .
前記メモリは、前記記憶領域のアドレスに1対1に割付けられた前記アドレス領域を含む、請求項1から3のいずれかに記載の情報処理装置。 A storage area for storing the program;
The information processing apparatus according to claim 1, wherein the memory includes the address area assigned one-to-one to the address of the storage area.
前記入力部が入力する分岐命令の前記分岐先データが示す値が閾値よりも大きいときは、当該分岐先データに対応の分岐元データを、その後に前記入力部が入力する分岐命令の前記分岐先データに基づき指定される前記メモリのアドレス領域に格納する、請求項1に記載の情報処理装置。 The controller is
When the value indicated by the branch destination data of the branch instruction input by the input unit is greater than a threshold value, the branch source data corresponding to the branch destination data is set, and then the branch destination of the branch instruction input by the input unit The information processing apparatus according to claim 1, wherein the information processing apparatus is stored in an address area of the memory designated based on data.
前記複数の分岐命令に関するデータを格納するためのメモリのアクセスを制御するステップと、を備え、
前記アクセスを制御するステップでは、
前記入力するステップにより入力する分岐命令の前記分岐先データに基づき指定される前記メモリのアドレス領域に、当該分岐命令の次位に実行される分岐命令について前記入力するステップにより入力する分岐元データを格納する、情報処理方法。 A step of inputting branch source data of the branch instruction and corresponding branch destination data each time the branch instruction is executed when executing a program including a plurality of branch instructions;
Controlling access of a memory for storing data relating to the plurality of branch instructions,
In the step of controlling the access,
The branch source data input by the step of inputting the branch instruction executed next to the branch instruction in the address area of the memory specified based on the branch destination data of the branch instruction input by the input step An information processing method for storing.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2012207976A JP2014063346A (en) | 2012-09-21 | 2012-09-21 | Information processor |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2012207976A JP2014063346A (en) | 2012-09-21 | 2012-09-21 | Information processor |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2014063346A true JP2014063346A (en) | 2014-04-10 |
Family
ID=50618522
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2012207976A Pending JP2014063346A (en) | 2012-09-21 | 2012-09-21 | Information processor |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2014063346A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2020154796A (en) * | 2019-03-20 | 2020-09-24 | 日本電気株式会社 | Malware analysis apparatus, malware analysis method, and program |
-
2012
- 2012-09-21 JP JP2012207976A patent/JP2014063346A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2020154796A (en) * | 2019-03-20 | 2020-09-24 | 日本電気株式会社 | Malware analysis apparatus, malware analysis method, and program |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7886198B2 (en) | Method and system of identifying overlays used by a program | |
US20170024266A1 (en) | Memory system, information processing system, and host device | |
US8001427B2 (en) | Method and system of indexing into trace data based on entries in a log buffer | |
JP4846493B2 (en) | Debug system and debug circuit | |
US20160292057A1 (en) | Real time terminal for debugging embedded computing systems | |
US10452513B2 (en) | Trace data capture device and method, system, diagnostic method and apparatus and computer program | |
JP2010157218A (en) | Method and device to profile ram memory object for displacement with nonvolatile memory | |
JPWO2005022390A1 (en) | Microcomputer and system program development method | |
US9286248B2 (en) | Methods and systems for moving and resizing I/O activity logs | |
US20080016415A1 (en) | Evaluation system and method | |
CN109582521B (en) | Method, device, equipment and medium for testing read-write performance of storage system | |
US20120151267A1 (en) | System for extending use of a data address break point register to implement multiple watch points | |
US20060075310A1 (en) | Microcomputer and trace control method capable of tracing desired task | |
JP2014063346A (en) | Information processor | |
KR20180110482A (en) | System and method for testing memory | |
JPWO2010032330A1 (en) | Information processing apparatus and memory protection method thereof | |
US9092486B2 (en) | Extensible I/O activity logs | |
JP2003263339A (en) | Debug function-incorporated microcomputer | |
JP2009043061A (en) | Debugging device and debugging method | |
KR20180122409A (en) | Tracking activity | |
JP3251266B2 (en) | Emulation system, upload data acquisition method, and recording medium recording the method | |
JP5000689B2 (en) | Temporal correlation of messages transmitted by microprocessor monitor circuits. | |
JP5762229B2 (en) | How to measure program performance | |
JP2006504205A (en) | Temporal correlation of messages transmitted by microprocessor monitor circuits. | |
JP2007156594A (en) | Program trace unit and method |