JP2012128752A - Source conversion method - Google Patents
Source conversion method Download PDFInfo
- Publication number
- JP2012128752A JP2012128752A JP2010281137A JP2010281137A JP2012128752A JP 2012128752 A JP2012128752 A JP 2012128752A JP 2010281137 A JP2010281137 A JP 2010281137A JP 2010281137 A JP2010281137 A JP 2010281137A JP 2012128752 A JP2012128752 A JP 2012128752A
- Authority
- JP
- Japan
- Prior art keywords
- source
- migration
- transition
- variable
- post
- 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
- Stored Programmes (AREA)
Abstract
Description
本発明は、アーキテクチャが異なるシステムへの移行において、システム移行前とシステム移行後のプログラム動作が変わらないように自動的にソースを変換する技術に関する。 The present invention relates to a technology for automatically converting a source so that a program operation before and after system migration does not change during migration to a system having a different architecture.
従来技術において、システム移行に伴うソースの変換処理に対する仕組みは検討されてきた。アーキテクチャが異なるシステム間の移行においてもメモリ配置についてはOSとコンパイラの仕様に依存しており、正しいソースであれば移行後もユーザが意識することなく正しく動作する。 In the prior art, a mechanism for source conversion processing accompanying system migration has been studied. Even when migrating between systems with different architectures, the memory allocation depends on the specifications of the OS and the compiler, and if the source is correct, it operates correctly without the user being aware of it even after migration.
しかし、ソースに不良(バグ)が含まれており、特にバッファオーバーランの不良が存在しているシステムを移行する場合は、アーキテクチャに依存するメモリ配置変更の影響により移行前と移行後で処理結果が異なる場合があり、人手によるソース修正以外に有効な手段がなかった。バッファオーバーランを検出する技術は検討されているが、ソースの不良を修正した結果、移行前と移行後で処理結果が異なることが不可避な場合がある。 However, when migrating a system that contains defects (bugs) in the source, especially when buffer overrun defects exist, the processing results before and after migration due to the influence of memory placement changes that depend on the architecture There was no effective means other than manual source correction. Although techniques for detecting a buffer overrun have been studied, there are cases where it is inevitable that processing results are different before and after migration as a result of correcting a source defect.
そのため、バッファオーバーランの不良を修正することなく、移行前と移行後で同じ処理結果を得られる仕組みが求められている。 Therefore, there is a need for a mechanism that can obtain the same processing result before and after the transition without correcting the buffer overrun failure.
なお、下記特許文献1では、バッファオーバーランを検出する考え方を示しているが、メモリ配置を変更するソース変換方法については述べていない。
Note that the following
システム移行時にCPUやOSのアーキテクチャ変更に伴いプログラムのメモリ配置が変更になる場合、移行前システムでは問題なく動作していたユーザプログラムが移行後システムでは異なる動作をして問題になることがある。 If the memory layout of a program is changed due to a change in the architecture of the CPU or OS during system migration, a user program that has been operating without any problem in the system before migration may be differently operated in the system after migration, resulting in a problem.
異なる動作の例としては、移行前システムに存在していたバッファオーバーランの潜在不良(バグ)が移行前システムでは未使用のメモリを上書きすることにより正常に動作していたが、移行後システムではメモリ配置が異なっており使用中のメモリを破壊するといったことがあげられる。これは配置するメモリの開始アドレスが、2の倍数や8の倍数などシステムによって異なる仕様に起因している。 As an example of the different behavior, the buffer overrun potential defect (bug) that existed in the pre-migration system worked normally by overwriting unused memory in the pre-migration system, but in the post-migration system, For example, the memory allocation is different and the memory in use is destroyed. This is because the start address of the memory to be arranged is different depending on the system such as a multiple of 2 or a multiple of 8.
バッファオーバーランを検出し、該当するソースを修正するのが本来の対策であるが、修正は人手によるため大きな工数が必要であり、さらに修正箇所の影響が広範囲に及ぶ場合はシステムとしての動作が異なることがある。 The original countermeasure is to detect the buffer overrun and correct the corresponding source. However, since the correction is manual, a large man-hour is required. May be different.
本発明は、ソースの不良を修正することなく、システム移行前とシステム移行後で同じ処理結果を得られるようにメモリ配置を変更するためのソース変換の仕組みを提供することを目的とする。 An object of the present invention is to provide a source conversion mechanism for changing a memory arrangement so that the same processing result can be obtained before and after system migration without correcting a source defect.
移行前のソースを解析し、移行前システムのメモリ割当ての条件を元に変数メモリ配置を計算する。次に、移行後のシステムのアーキテクチャに合わせて移行後の変数メモリ配置を計算する。前述の両者の比較を行い、差分情報を抽出する。差分情報を元に移行前ソースにダミーデータの宣言文の追加を行い、移行後ソースを生成する。 The source before migration is analyzed, and the variable memory allocation is calculated based on the memory allocation condition of the system before migration. Next, the variable memory allocation after migration is calculated according to the architecture of the system after migration. The above two are compared, and difference information is extracted. Based on the difference information, a declaration statement of dummy data is added to the source before migration, and the source after migration is generated.
本発明によれば、バッファオーバーランなどメモリ破壊の不良の影響を移行前と移行後のシステムで同じにすることが出来る。これにより、ソース修正と確認の工数を要することなく、システム移行および移行後の稼動における問題の発生を抑制できるという効果がある。 According to the present invention, it is possible to make the influence of memory destruction defects such as buffer overrun the same between the system before and after the transition. Thus, there is an effect that it is possible to suppress occurrence of problems in system migration and operation after migration without requiring man-hours for source correction and confirmation.
以下、本発明の一実施例について、図面を参照して詳細に説明する。 Hereinafter, an embodiment of the present invention will be described in detail with reference to the drawings.
図1は、本実施例に係わるコンピュータ1の全体構成例を示す図である。
FIG. 1 is a diagram illustrating an example of the overall configuration of a
コンピュータ1はメモリ10とCPU20から構成される。
The
メモリ10はOS領域11とユーザプログラム12とユーザデータ領域13とソース変換プログラム領域14から構成される。
The
ユーザプログラム12は変数などの情報をユーザデータ領域13に格納しながらCPU20により実行される。
The user program 12 is executed by the
図2は、ソース変換プログラム領域14の構成例を示す図である。
FIG. 2 is a diagram illustrating a configuration example of the source
ソース変換プログラム領域14は変数メモリ配置解析部141と移行前・移行後アドレス比較部142とソース変換部143とシステム情報145と移行前・移行後変数メモリ配置情報146と差分情報147とを具備する。
The source
変数メモリ配置解析部141は移行前ソース144とシステム情報145を読み込み、移行前・移行後変数メモリ配置情報146を出力する機能を有する。例では移行前システムの開始アドレスが8の倍数(n1=8)、移行後システムの開始アドレスが2の倍数(n2=2)をシステム情報145として与える。
The variable memory arrangement analyzing unit 141 has a function of reading the
移行前・移行後アドレス比較部142は移行前・移行後変数メモリ配置情報146を読み込み、アドレスを比較した結果を差分情報147として出力する機能を有する。
The pre-migration / post-migration
ソース変換部143は移行前ソース144と差分情報147を読み込み、ソース変換を行い、変換後ソース148を出力する機能を有する。
The
図3は、ソース変換プログラム領域14が具備する処理のうち、変数メモリ配置解析部141の詳細な処理を表すフローチャートである。
FIG. 3 is a flowchart showing the detailed process of the variable memory arrangement analysis unit 141 among the processes included in the source
移行前ソース読込(ステップS1411)は移行前ソース144を読み込む。メモリ配置シミュレーション(ステップS1412)は移行前ソース144とシステム情報145を元に開始アドレスが8の倍数(n1=8)である移行前システムのメモリ配置を計算する。図6に示すソースの例では、char型の変数aを2バイト宣言しており、この場合のアドレス割当は図7に示すように開始アドレス302が0x10000となり、終了アドレス303が0x10001となる。char型の変数bは2バイト宣言しており、システムの制約により開始アドレスが8の倍数(n1=8)になるため、開始アドレス302が0x10008となり、終了アドレス303が0x10009として割り当てられる。変数メモリ配置情報格納(ステップS1413)は前述のアドレス情報を出力する。
Read source before migration (step S1411) reads the
次に、メモリ配置シミュレーション(ステップS1414)は開始アドレスが2の倍数(n2=2)である移行後システムのメモリ配置を計算する。図6に示すソースの例では、char型の変数bを2バイト宣言しており、システムの制約により開始アドレスが2の倍数(n2=2)になるため、図8に示すように開始アドレス402が0x10002となり、終了アドレス403が0x10003として割り当てられる。変数メモリ配置情報格納(ステップS1415)は前述のアドレス情報を出力する。
Next, the memory allocation simulation (step S1414) calculates the memory allocation of the post-migration system whose start address is a multiple of 2 (n2 = 2). In the example of the source shown in FIG. 6, the char type variable b is declared as 2 bytes, and the start address is a multiple of 2 (n2 = 2) due to system restrictions. Therefore, as shown in FIG. Becomes 0x10002, and the
図4は、ソース変換プログラム領域14が具備する処理のうち、移行前・移行後アドレス比較部142の詳細な処理を表すフローチャートである。
FIG. 4 is a flowchart showing the detailed processing of the pre-migration / post-migration
比較処理(ステップS1421)は移行前・移行後変数メモリ配置情報146を元に、移行前システムと移行後システムでアドレスを比較し、一致しているかを判定する(ステップS1422)。図7の変数aと図8の変数aの比較では開始アドレス302と開始アドレス402に差異はないが、変数bについては開始アドレス302が0x10008に対して開始アドレス402が0x10002と異なっているため、一致していないと判定する。
The comparison process (step S1421) compares the addresses of the pre-migration system and the post-migration system based on the pre-migration and post-migration variable
一致していない場合は差分情報蓄積(ステップS1423)により差分情報147を出力する。一致している場合は差分情報を出力せずに処理を終了する。
If they do not match, the
図5は、ソース変換プログラム領域14が具備する処理のうち、ソースコード変換部143の詳細な処理を表すフローチャートである。
FIG. 5 is a flowchart showing detailed processing of the source
差分情報読込(ステップS1431)にて差分情報147を移行前ソース読込(ステップS1432)にて移行前ソース144を読み込む。
The
差分情報147を元に修正箇所検索(ステップS1433)では修正箇所を特定し、ダミー追加処理(ステップS1434)にて移行後システムの開始アドレスが8の倍数になるようダミーのメモリ確保宣言文を追加する。最後に、変換後ソース出力 (ステップS1435)にて変換したソースを出力する。
In the correction location search (step S1433) based on the
図6は、移行前ソース144の例を示すソースである。
FIG. 6 is a source showing an example of the
例では、char型の変数としてa,bを2バイトずつ宣言している。 In the example, a and b are declared 2 bytes each as a char type variable.
図7は、移行前ソース144が移行前システムで動作する際の移行前変数メモリ配置情報146の例を示す図である。
FIG. 7 is a diagram illustrating an example of the pre-migration variable
変数宣言301により変数aは開始アドレス302が0x10000となり、終了アドレス303が0x10001として割り当てられる。また、変数bは開始アドレスが8の倍数になるため、開始アドレス302が0x10008となり、終了アドレス303が0x10009として割り当てられる。
With variable declaration 301, variable a is assigned with
図8は、移行前ソース144が移行後システムで動作する際の移行後変数メモリ配置情報146の例を示す図である。
FIG. 8 is a diagram illustrating an example of post-migration variable
変数宣言401により変数aは開始アドレス402が0x10000となり、終了アドレス403が0x10001として割り当てられる。また、変数bは開始アドレスが2の倍数になるため、開始アドレス402が0x10002となり、終了アドレス403が0x10003として割り当てられる。結果、移行前と移行後のシステムでは、変数aのアドレスは同じだが、変数bのアドレスが異なっている。
With
図9は、移行前ソース144が移行前システムで動作する際のメモリ配置の例を示す図である。
FIG. 9 is a diagram illustrating an example of a memory arrangement when the
移行前システムでは変数aの後続のアドレス0x10002から0x10007までが空きとなっている。 In the pre-migration system, the subsequent addresses 0x10002 to 0x10007 of the variable a are empty.
図10は、移行前ソース144が移行後システムで動作する際のメモリ配置の例を示す図である。
FIG. 10 is a diagram illustrating an example of memory arrangement when the
移行後システムでは変数aに続いて変数bが割り当てられている点が異なる。 In the post-migration system, the variable b is assigned after the variable a.
図11は、移行前システムでバッファオーバーランが発生した場合の例を示す図である。 FIG. 11 is a diagram illustrating an example when a buffer overrun occurs in the pre-migration system.
変数宣言301では変数aは2バイトしか宣言していないが、ユーザプログラム12の不良によりa[2]およびa[3]に値を代入した場合、0x10002と0x10003のメモリに値が書き込まれる。ただし、移行前システムでは空き領域であるためメモリ破壊は発生せずシステムは正常に動作する。 In the variable declaration 301, the variable a declares only 2 bytes, but if a value is assigned to a [2] and a [3] due to a defect in the user program 12, the value is written in the memory of 0x10002 and 0x10003. However, because the pre-migration system is a free area, memory corruption does not occur and the system operates normally.
図12は、移行後システムでバッファオーバーランが発生した場合の例を示す図である。 FIG. 12 is a diagram illustrating an example when a buffer overrun occurs in the post-migration system.
変数宣言401では変数aは2バイトしか宣言していないにもかかわらず、ユーザプログラム12の不良によりa[2]およびa[3]に値を代入した場合、0x10002と0x10003のメモリに値が書き込まれる。しかし、0x10002と0x10003のアドレスは変数b[0]とb[1]に割り当てられているため、移行後システムではメモリ破壊が発生し、システムが異常な動作をする。図11および図12の結果から、移行前システムでは問題がなかったユーザプログラムが移行後システムでは正常に動作しない現象が発生する。
Even though
図13は、変換後ソース148の例を示すソースである。
FIG. 13 is a source showing an example of the converted
ソース変換部143の処理によりchar a[2]; の次行にchar d1[6]; を追加している。変数aの宣言の後に、ダミーデータとして変数d1を6バイト確保することにより変数bの開始アドレスを移行前と同じ0x10008にしている。
By the processing of the
図14は、変換後ソース148が移行後システムで動作する際のメモリ配置の例を示す図である。
FIG. 14 is a diagram illustrating an example of a memory arrangement when the converted
変数aの後に、ダミーデータとして変数d1を6バイト割り当てることにより変数bの開始アドレスを移行前と同じ0x10008にしている。 By assigning 6 bytes of the variable d1 as dummy data after the variable a, the start address of the variable b is set to 0x10008, which is the same as before the transition.
図15は、変換後ソース148が移行後システムで動作する際のメモリ配置とバッファオーバーランが発生した場合の例を示す図である。
FIG. 15 is a diagram illustrating an example of a memory allocation and a buffer overrun when the converted
ユーザプログラム12の不良によりa[2]およびa[3]に値を代入した場合、0x10002と0x10003のメモリに値が書き込まれる。変数d1[0]とd1[1]の値がへんこうされるがダミーデータのため、メモリ破壊は発生せずシステムは正常に動作する。 When a value is assigned to a [2] and a [3] due to a defect in the user program 12, values are written to the 0x10002 and 0x10003 memories. The values of variables d1 [0] and d1 [1] are changed, but because of dummy data, memory corruption does not occur and the system operates normally.
以上本発明の実施例を説明したが、本発明はこれに限定されるものではなく、その要旨を逸脱しない範囲で種々変更可能である。 Although the embodiment of the present invention has been described above, the present invention is not limited to this, and various modifications can be made without departing from the scope of the invention.
1…コンピュータ、10…メモリ、11…OS領域、12…ユーザプログラム、13…ユーザデータ領域、14…ソース変換プログラム領域、20…CPU、301、401…変数宣言、302、402…開始アドレス、303、403…終了アドレス
DESCRIPTION OF
Claims (2)
メモリ配置を解析するステップと、
システム移行前とシステム移行後のアドレスを比較するステップと、
差分情報を出力するステップと、
差分情報を元にソースを変換するステップと、を有する、
ことを特徴とするソース変換方法。 A computer-implemented source conversion method for the same memory allocation in a system migration between different architectures,
Analyzing the memory placement;
Comparing addresses before and after system migration;
Outputting difference information;
Converting the source based on the difference information,
A source conversion method characterized by that.
ことを特徴とする請求項1に記載のソース変換方法。 Furthermore, it has a step of receiving information of an arbitrary start address depending on the architecture required for the source conversion
The source conversion method according to claim 1, wherein:
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2010281137A JP2012128752A (en) | 2010-12-17 | 2010-12-17 | Source conversion method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2010281137A JP2012128752A (en) | 2010-12-17 | 2010-12-17 | Source conversion method |
Publications (1)
Publication Number | Publication Date |
---|---|
JP2012128752A true JP2012128752A (en) | 2012-07-05 |
Family
ID=46645674
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2010281137A Pending JP2012128752A (en) | 2010-12-17 | 2010-12-17 | Source conversion method |
Country Status (1)
Country | Link |
---|---|
JP (1) | JP2012128752A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2019230597A1 (en) * | 2018-05-29 | 2019-12-05 | 日本電信電話株式会社 | Function analyzer, function analysis method, and function analysis program |
-
2010
- 2010-12-17 JP JP2010281137A patent/JP2012128752A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2019230597A1 (en) * | 2018-05-29 | 2019-12-05 | 日本電信電話株式会社 | Function analyzer, function analysis method, and function analysis program |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9424009B2 (en) | Handling pointers in program code in a system that supports multiple address spaces | |
CN109739824B (en) | Log obtaining method and device | |
US20200117475A1 (en) | Function evaluation using multiple values loaded into registers by a single instruction | |
US9396097B2 (en) | Methods, circuits, devices, systems and associated computer executable code for testing software code | |
JP2019215847A (en) | Reducing buffer overflow | |
CN103942082A (en) | Complier optimization method for eliminating redundant storage access operations | |
JP6945768B2 (en) | Detection device, detection method, and detection program | |
JP2012128752A (en) | Source conversion method | |
US8176361B2 (en) | Data processing with protection against soft errors | |
US9256398B2 (en) | Device and method of increasing dynamically-typed software efficiency | |
CN108205596B (en) | Method for realizing simulation function of serious accident analysis and calculation program of nuclear power plant | |
JP2016128941A (en) | Output determination device, output determination method, output determination program, and static analysis device | |
US10162728B2 (en) | Method and device for monitoring the execution of a program code | |
US11221851B2 (en) | Method executed by computing device, apparatus, device and computer-readable storage medium | |
CN113574511A (en) | Test case generation device, test case generation method, and test case generation program | |
WO2020157795A1 (en) | Test device, test method, and test program | |
JP2008090699A (en) | Method, apparatus and program of trace logging | |
JP2009238176A (en) | Information processing apparatus and program verifying method | |
JP7316613B2 (en) | Abnormality detection method, abnormality detection program, abnormality detection device, rewriting method, rewriting program, and rewriting device | |
CN112527657B (en) | Method and equipment for automatic pile insertion in unit test | |
US11853151B1 (en) | Task abnormality detection system and embedded device detection method | |
CN111566625A (en) | Test case generation device, test case generation method, and test case generation program | |
JP2009076002A (en) | Method for adjusting control timing, compile program, compile apparatus, and information processor | |
US20130318509A1 (en) | Generating object code from a conjoined assembler directive | |
JP2011034517A (en) | Equivalence verification device, data processing method thereof, and program |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
RD04 | Notification of resignation of power of attorney |
Free format text: JAPANESE INTERMEDIATE CODE: A7424 Effective date: 20120521 |