ページ更新: 2013-06-06 (木) (2235日前)

関連: Valgrind

(2013-06-06 新規作成)

Intel Software Development Emulator についてのメモ。

目次

[編集]

これって、なに? #

  • CPUエミュレータ。
  • 対応OSは、Windows, Linux, MacOS X。
  • tar+gz や tar+gz2 で圧縮されているので、Windows では、別途、これらのファイルを展開できるアーカイバが必要になる。 (Cygwin tar, gzip, gzip2 や、Lhaz で展開できた)
  • Windows だけはツールの他に Visual Studio 2012 へのアドインが存在する。 ただし、README.txt によると、製品版が出る前のものに対応しているとのことで、RTM, update1, update2 での動作は不明)

ライセンス

[編集]

情報源 #

Intel® Software Development Emulator:

Pin:

[編集]

使い方 #

コマンドラインの形式

sde [sde用引数] -- 調査対象プログラム [調査対象プログラムの引数]

ヘルプ表示

sde -help
sde -thelp
sde -phelp

以下の機能を持つ。

1. mix histogram tool

2. footprint tool

3. mix debugtrace tool

4. AVX/SSE transition checker

[編集]

メモ #

[編集]

実行所要時間と出力ファイルの大きさ #

hello.cpp

// build(Visual C++): cl hello.cpp
#include <cstdio>
#include <cstdlib>
int main() {
    puts("hello\n");
    return EXIT_SUCCESS;
}

環境: Windows XP, Core2Duo E8500, ディスクはSSD 所要時間 11秒 3つの出力ファイルの大きさ

sde-debugtrace-out.txt    65 Mbyte
sde-footprint.txt         1188 byte
sde-mix-out.txt           530 Kbyte

sde-footprint.txt:

# Chunk size 64 bytes 
# FINI TID 0
                         error             0
                          load           804
                         store           189
                    load+store           437
                          code           805
                     load+code            23
                    store+code             0
               load+store+code             0

# FINI GLOBAL SUMMARY
                         error             0
                          load           804
                         store           189
                    load+store           437
                          code           805
                     load+code            23
                    store+code             0
               load+store+code             0
# EOF
MMARY
                         error             0
                          load           696
                         store             6
                    load+store            85
                          code           334
                     load+code            14
                    store+code             0
               load+store+code             0
# EOF

sde-mix-out.txt: 各関数ごとの統計情報?

# Mix output version 7
# Intel(R) SDE version: 5.31.0 bdw-external
# Starting tid 0
# Start counting for tid 0
# Stop counting for tid 0
# FINI: end of program
# ==============================================
# STATS FOR TID 0 EMIT# 1
# ==============================================
# EMIT_TOP_BLOCK_STATS FOR TID 0 EMIT # 1 EVENT=ICOUNT
BLOCK:     0   PC: 7c84b4d0   ICOUNT:     41823   EXECUTIONS:      4647 
  #BYTES: 20   %:  7.35   cumltv%:  7.35  FN: SetUnhandledExceptionFilter  IMG: C:\WINDOWS\system32\kernel32.dll
XDIS 7c84b4d0: BASE 0FB708                   movzx ecx, word ptr [eax]
XDIS 7c84b4d3: BASE 33D2                     xor edx, edx
XDIS 7c84b4d5: BASE 38544B01                 cmp byte ptr [ebx+ecx*2+0x1], dl
...
# END_TOP_BLOCK_STATS
# EMIT_DYNAMIC_STATS FOR TID 0 EMIT #1
#
# $dynamic-counts
#
# TID 0
#       opcode                 count
#
*mem-atomic                                                     428
*stack-read                                                   69961
*stack-write                                                  65502
*mem-read-1                                                   40304
*mem-read-2                                                   38041
*mem-read-4                                                   89361
*mem-read-8                                                       6
*mem-write-1                                                  13203
*mem-write-2                                                   5383
*mem-write-4                                                  73886
*mem-write-8                                                      6
*isa-ext-BASE                                                569046
*isa-ext-SSE2                                                     1
*isa-set-I186                                                  6767
*isa-set-I386                                                 36315
*isa-set-I486REAL                                               173
*isa-set-I86                                                 525729
*isa-set-PENTIUMREAL                                              6
*isa-set-PPRO                                                    56
*isa-set-SSE2                                                     1
*category-BINARY                                             187215
*category-BITBYTE                                              4691
*category-CALL                                                 4970
*category-COND_BR                                             93315
*category-CONVERT                                                66
*category-DATAXFER                                           146001
*category-LOGICAL                                             46300
*category-MISC                                                13802
*category-NOP                                                    14
*category-POP                                                  8421
*category-PUSH                                                19827
*category-RET                                                  4966
*category-SEMAPHORE                                             177
*category-SHIFT                                                4198
*category-STRINGOP                                             8071
*category-SYSCALL                                                56
*category-UNCOND_BR                                           26957
*ilen-1                                                       95787
*ilen-2                                                      223676
*ilen-3                                                      156321
*ilen-4                                                       25970
*ilen-5                                                       21014
*ilen-6                                                       40248
*ilen-7                                                        4789
*ilen-8                                                        1125
*ilen-9                                                          82
*ilen-10                                                         35
*sse-packed                                                       1
*legacy-prefixes-0                                           517565
*legacy-prefixes-1                                            51254
*legacy-prefixes-2                                              228
*segment_prefix                                                2524
*lock_prefix                                                    428
*rep_prefix                                                    6803
*repne_prefix                                                  1252
*osz_prefix                                                   40703
*one-memops                                                  246423
*two-memops                                                    5833
*disp_only                                                     6072
*index_disp                                                    1070
*base_index                                                   15334
*base_index_disp                                               7227
*mem_form_unknown                                            222553
*scale_1                                                     232628
*scale_2                                                      16225
*scale_4                                                       2073
*scale_8                                                       1330
*memdisp8                                                    110961
*memdisp32                                                    15143
*dataxfer_fp_double_2                                             1
ADD                                                           40541
AND                                                            2504
CALL_NEAR                                                      4970
CDQ                                                              66
CMP                                                           68353
CMPSB                                                           133
CMPXCHG                                                         149
CMPXCHG8B                                                         6
CPUID                                                             2
DEC                                                            7398
DIV                                                              90
IDIV                                                             66
IMUL                                                            613
INC                                                           65898
JB                                                             2607
JBE                                                             567
JL                                                             1506
JLE                                                             584
JMP                                                           26957
JNB                                                           18830
JNBE                                                            720
JNL                                                            2381
JNLE                                                              2
JNS                                                               1
JNZ                                                           27153
JRCXZ                                                            67
JS                                                              106
JZ                                                            38791
LEA                                                           12687
LEAVE                                                          1113
MOV                                                          121011
MOVAPD                                                            1
MOVSB                                                            69
MOVSD                                                          1899
MOVSX                                                            21
MOVZX                                                         24962
MUL                                                               2
NEG                                                             114
NOP                                                              14
NOT                                                             220
OR                                                             1519
POP                                                            8419
POPFD                                                             2
PUSH                                                          19825
PUSHFD                                                            2
RET_NEAR                                                       4966
SAR                                                            1286
SBB                                                            2015
SCASB                                                          1024
SCASW                                                           228
SETNL                                                            12
SETNZ                                                          4653
SETZ                                                             26
SHL                                                            1007
SHR                                                            1903
SHRD                                                              2
STOSB                                                           115
STOSD                                                          4603
SUB                                                            2125
SYSENTER                                                         56
TEST                                                          21801
XADD                                                             22
XCHG                                                              6
XOR                                                           20256
*total                                                       569047
# END_DYNAMIC_STATS
# FUNCTION TOTALS FOR TID 0
#rank        total     %   cumulative%      address  function-name  image-name
   0:       181120  31.829  31.829          7c8449cd SetUnhandledExceptionFilter  IMG: C:\WINDOWS\system32\kernel32.dll
   1:       114458  20.114  51.943            4012ee unnamedImageEntryPoint  IMG: D:\work\hello.exe
   2:        68983  12.123  64.065          7c95462a RtlExpandEnvironmentStrings_U  IMG: C:\WINDOWS\system32\ntdll.dll
   3:        54082   9.504  73.569          7c957cf0 LdrGetProcedureAddress  IMG: C:\WINDOWS\system32\ntdll.dll
   4:        29234   5.137  78.707          7c95057f wcsncpy          IMG: C:\WINDOWS\system32\ntdll.dll
   5:        12998   2.284  80.991          7c94e80d strchr           IMG: C:\WINDOWS\system32\ntdll.dll
...
            569047 TOTAL
# END FUNCTION TOTALS
# EMIT_PER_FUNCTION_STATS FOR TID 0 EMIT# 1
#
# $dynamic-counts-for-function: SetUnhandledExceptionFilter  IMG: C:\WINDOWS\system32\kernel32.dll at [0x7c8449cd, 0x7c84e698)  31.829%
#
# TID 0
#       opcode                 count
#
*stack-read                                                   30171
*stack-write                                                  12127
*mem-read-1                                                   18047
*mem-read-2                                                   13646
*mem-read-4                                                   30306
...
*total                                                       181120
#
# $dynamic-counts-for-function: unnamedImageEntryPoint  IMG: D:\work\hello.exe at [0x4012ee, 0x408cc4)  20.114%
#
# TID 0
#       opcode                 count
#
*stack-read                                                    5631
...
*total                                                       114458
#
# $dynamic-counts-for-function: RtlExpandEnvironmentStrings_U  IMG: C:\WINDOWS\system32\ntdll.dll at [0x7c95462a, 0x7c9548e2)  12.123%
#
# TID 0
#       opcode                 count
#
*stack-read                                                     939
...
*total                                                       569047

# END_GLOBAL_DYNAMIC_STATS

sde-debugtrace-out.txt: スレッドID, 機械語命令、命令実行で変化したレジスタの値など

TID0: INS 0x7c94118a                     BASE     mov esp, esi                         | esp = 0x12f92c
TID0: Read 0x7c80b64e = *(UINT32*)0012F92C
TID0: INS 0x7c94118c                     BASE     pop ebx                              | ebx = 0x7c80b64e, esp = 0x12f930
TID0: Read 0x1 = *(UINT32*)0012F930
TID0: INS 0x7c94118d                     BASE     pop edi                              | edi = 0x1, esp = 0x12f934
TID0: Read 0x241fc0 = *(UINT32*)0012F934
TID0: INS 0x7c94118e                     BASE     pop esi                              | esi = 0x241fc0, esp = 0x12f938
TID0: Read 0x12fa40 = *(UINT32*)0012F938
TID0: INS 0x7c94118f                     BASE     pop ebp                              | ebp = 0x12fa40, esp = 0x12f93c
TID0: Read 0x7c95b5d2 = *(UINT32*)0012F93C
TID0: INS 0x7c941190                     BASE     ret 0x10                             | esp = 0x12f950
TID0: INS 0x7c95b5d2                     BASE     mov byte ptr [ebp-0x21], al
TID0: Write *(UINT8*)0012FA1F = 0x1
TID0: INS 0x7c95b5d5                     BASE     mov dword ptr [ebp-0x4], edi
TID0: Write *(UINT32*)0012FA3C = 0x1
TID0: INS 0x7c95b5d8                     BASE     call 0x7c95b621                      | esp = 0x12f94c
...