Debugging, Profiling, Code improvement tools
  • Introduction
  • Chapter1: 追蹤問題
    • 1.1.找出錯誤來源
  • Chapter2: 解決問題
    • 2.1.Check list
      • 2.1.1.確認前後條件
  • Chapter3: 錯誤訊息
    • 3.1.python
      • 'charmap' codec can't decode byte 0x8f in position 17: character maps to <undefined>
  • Chapter4:版本管理工具
    • 4.1.Git
      • 4.1.1.Working tree, Index/Cache, Repository and Object
      • 4.1.2.commit
      • 4.1.3.cherry-pick
      • 4.1.4.rebase
    • 4.2.TortoiseGit
      • 4.2.1.bisect
      • 4.4.2.reflog & reset
      • 4.2.3.blame
  • Chapter5: 除錯工具
    • 5.1.Visual studio
      • 5.1.1.輸出debug訊息
      • 5.1.2.中斷點
      • 5.1.3.載入符號, 檢視堆疊
      • 5.1.4.追蹤點
      • 5.1.5.單步執行程式
      • 5.1.6.日誌
      • 5.1.7.靜態程式分析
    • 5.2. WinDbg
      • 5.2.1.安裝WinDbg
      • 5.2.2.設定project及symbol path
      • 5.2.3.分析.dmp file
    • 5.3.API
      • 5.3.1.核心傾印
  • Chapter6: 效能分析工具
    • 6.1.Introduction
    • 6.2.Windows
      • 6.2.1.效能分析指標
      • 6.2.2.Windows Performance Monitor
      • 6.2.3.Process monitor
      • 6.2.4.Windows Performance Toolkit
    • 6.3.C++ project
      • 6.3.1.SMART BEAR AQ Time
    • 6.4.Python project
      • 6.4.1.cProfile, snakeviz
  • Chapter7: 程式碼優化工具
    • 7.1.Python
      • 7.1.1.vulture
Powered by GitBook
On this page
  • 1.堆疊 (Stack)
  • 2.範例程式碼
  • 3.載入符號
  • 4.切換堆疊

Was this helpful?

  1. Chapter5: 除錯工具
  2. 5.1.Visual studio

5.1.3.載入符號, 檢視堆疊

Previous5.1.2.中斷點Next5.1.4.追蹤點

Last updated 5 years ago

Was this helpful?

1.堆疊 (Stack)

  • 一支執行中的程式稱為程序(process), 一個程序中可以有多個, 每個續程中CPU都獨立執行程式, 不會互相干擾

  • 每個續程有各自的堆疊, 堆疊可以存放回返點, 函式參數及區域變數

    • 1.回返點:

      • 當一個執行緒由一個函式執行到另一個函式時, 需要將回返點記錄下來, 以便函式結束後返回到原函式

    • 2.函式參數及區域變數

      • 遞迴函式

        • 每呼叫一次函式, 便會將函式內的參數及區域變數新增加到堆疊上

        • 在函式返回時系統必須將堆疊上屬於那個函式的資料所有權釋放掉

      • 多執行緒執行相同函式

        • 一個函式內的參數及區域變數對於不一樣的執行緒來說都是不一樣的

2.範例程式碼

  • 1.貼上範例程式碼

#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void func(int a)
{
    printf("func call at %d!!\n", a);
}

int main()
{
    int i;
    for (i = 0; i<100; i++){ /* break point here */
        if (i % 10 == 0)
            func(i);
    }
    return 0;
}

3.載入符號

  • 1.用途

    • 通過載入系統DLL的符號資訊以獲得全部呼叫堆疊資訊

  • 2.用法

    • 1.Tools -> Options -> Debugging -> Symbols -> 勾選Microsoft Symbols Server

4.切換堆疊

2.設定

1.在debug狀態下呼叫堆疊: DEBUG -> Windows -> Call Stack

2.從堆疊視窗中可以看到系統DLL的資訊

中斷點
續程(thread)