在 Visual Studio 偵錯工具中指定符號 ( .pdb) 和原始程式檔 (c #、c + +、Visual Basic、F # ) Specify symbol (.pdb) and source files in the Visual Studio debugger (C#, C++, Visual Basic, F#)

程式資料庫 (.pdb) 檔案(也稱為符號檔)、將專案原始程式碼中的識別碼和語句對應至已編譯之應用程式中的對應識別碼和指示。Program database (.pdb) files, also called symbol files, map identifiers and statements in your project's source code to corresponding identifiers and instructions in compiled apps. 這些對應檔會將偵錯工具連結至您的原始程式碼,以啟用偵錯工具。These mapping files link the debugger to your source code, which enables debugging.

當您使用標準 Debug 組建設定從 Visual Studio IDE 建立專案時,編譯器會建立適當的符號檔。When you build a project from the Visual Studio IDE with the standard Debug build configuration, the compiler creates the appropriate symbol files. 本文說明如何在 IDE 中管理符號檔,例如如何 在偵錯工具選項中指定符號的位置、如何在偵錯工具時 檢查符號載入狀態 ,以及如何 在程式碼中設定符號選項This article describes how to manage symbol files in the IDE, for example, how to specify the location of symbols in the debugger options, how to check symbol loading status while debugging, and how to set symbol options in code.

如需符號檔的詳細說明,請參閱下列檔:For a detailed explanation of symbol files, see the following:

符號檔的運作方式How symbol files work

.Pdb 檔案包含偵錯工具和專案狀態資訊,可讓您應用程式的偵錯工具的累加式連結。The .pdb file holds debugging and project state information that allows incremental linking of a Debug configuration of your app. Visual Studio 偵錯工具在進行偵錯工具時,會使用 .pdb 檔案來判斷兩個重要的資訊片段:The Visual Studio debugger uses .pdb files to determine two key pieces of information while debugging:

  • 要在 Visual Studio IDE 中顯示的原始程式檔名稱和行號。The source file name and line number to display in the Visual Studio IDE.
  • 應用程式停止中斷點的位置。Where in the app to stop for a breakpoint.

符號檔也會顯示來源檔案的位置,並選擇性地顯示從中抓取來源檔案的位置。Symbol files also show the location of the source files, and optionally, the server to retrieve them from.

偵錯工具只會載入與建立應用程式時所建立之 .pdb 檔案完全相符的 .pdb 檔 (也就是原始 .pdb 檔案或複製) 。The debugger only loads .pdb files that exactly match the .pdb files created when an app was built (that is, the original .pdb files or copies). 完全 是必要的,因為即使程式碼本身未變更,應用程式的配置也可能會變更。This exact duplication is necessary because the layout of apps can change even if the code itself has not changed.

提示

若要在專案原始程式碼之外(例如,您的專案呼叫的 Windows 程式碼或協力廠商程式碼)進行程式碼的偵錯工具,您必須指定外部程式碼 .pdb 檔案的位置 (並選擇性地指定原始程式檔) ,其必須完全符合您應用程式中的組建。To debug code outside your project source code, such as Windows code or third-party code your project calls, you must specify the location of the external code's .pdb files (and optionally, the source files), which must exactly match the builds in your app.

符號檔位置和載入行為Symbol file locations and loading behavior

當您在 Visual Studio IDE 中對專案進行偵錯工具時,偵錯工具會自動載入位於專案資料夾中的符號檔。When you debug a project in the Visual Studio IDE, the debugger automatically loads symbol files that are located in the project folder.

注意

在遠端裝置上對 managed 程式碼進行偵錯工具時,所有的符號檔都必須位於本機電腦上,或位於 偵錯工具選項中指定的位置。When debugging managed code on a remote device, all symbol files must be located either on the local machine, or in a location specified in the debugger options.

偵錯工具也會在下列位置中搜尋符號檔:The debugger also searches for symbol files in the following locations:

  1. 在 DLL 或可執行檔 (.exe 中指定的位置) 檔。The location that is specified inside the DLL or the executable (.exe) file.

    根據預設,如果您的電腦上已建立 DLL 或 .exe 檔,連結器會將相關聯之 .pdb 檔案的完整路徑和檔案名放入 dll 或 .exe 檔案中。By default, if you have built a DLL or an .exe file on your computer, the linker places the full path and filename of the associated .pdb file in the DLL or .exe file. 偵錯工具會檢查符號檔是否存在於該位置中。The debugger checks to see if the symbol file exists in that location.

  2. 與 DLL 或 .exe 檔案相同的資料夾。The same folder as the DLL or .exe file.

  3. 符號檔的偵錯工具選項中指定的任何位置。Any locations specified in the debugger options for symbol files. 若要加入和啟用符號位置,請參閱 設定符號位置和載入選項To add and enable symbol locations, see Configure symbol locations and loading options.

    • 任何本機符號快取資料夾。Any local symbol cache folder.

    • 指定的網路、網際網路或本機符號伺服器和位置,例如 Microsoft 符號伺服器(若已選取)。Specified network, internet, or local symbol servers and locations, such as the Microsoft Symbol Servers if selected. Visual StudioVisual Studio 可以從執行通訊協定的符號伺服器下載偵錯工具符號檔 symsrvcan download debugging symbol files from symbol servers that implement the symsrv protocol. Visual Studio Team Foundation Server適用于 Windows 的調試 程式都是可使用符號伺服器的兩個工具。Visual Studio Team Foundation Server and the Debugging Tools for Windows are two tools that can use symbol servers.

      您可能使用的符號伺服器包括:Symbol servers you might use include:

      公用 Microsoft 符號伺服器:若要在呼叫系統 DLL 或協力廠商程式庫時,偵測發生的損毀,您通常需要系統 .pdb 檔。Public Microsoft Symbol Servers: To debug a crash that occurs during a call to a system DLL or to a third-party library, you often need system .pdb files. 系統 .pdb 檔案包含 Windows dll、 .exe 檔和設備磁碟機的符號。System .pdb files contain symbols for Windows DLLs, .exe files, and device drivers. 您可以從公用 Microsoft 符號伺服器取得 Windows 作業系統、MDAC、IIS、ISA 和 .NET 的符號。You can get symbols for Windows operating systems, MDAC, IIS, ISA, and .NET from the public Microsoft Symbol Servers.

      內部網路或本機電腦上的符號伺服器:您的小組或公司可以為自己的產品建立符號伺服器,並為外部來源的符號快取。Symbol servers on an internal network or on your local machine: Your team or company can create symbol servers for your own products, and as a cache for symbols from external sources. 您的電腦上可能有符號伺服器。You might have a symbol server on your own machine.

      協力廠商符號伺服器: Windows 應用程式和程式庫的協力廠商提供者可以存取網際網路上的符號伺服器。Third-party symbol servers: Third-party providers of Windows applications and libraries can provide access to symbol server on the internet.

      警告

      如果您使用的符號伺服器不是公用 Microsoft 符號伺服器,請確認符號伺服器及其路徑是否值得信任。If you use a symbol server other than the public Microsoft Symbol Servers, make sure that the symbol server and its path are trustworthy. 由於符號檔可以包含任意可執行檔程式碼,因此您可能會面臨安全性威脅。Because symbol files can contain arbitrary executable code, you can be exposed to security threats.

設定符號位置和載入選項Configure symbol locations and loading options

在 [工具 > 選項 > 調試 > 符號] 頁面上,您可以:On the Tools > Options > Debugging > Symbols page, you can:

  • 指定並選取 Microsoft、Windows 或協力廠商元件的搜尋路徑和符號伺服器。Specify and select search paths and symbol servers for Microsoft, Windows, or third-party components.
  • 指定您要或不希望偵錯工具自動載入符號的模組。Specify modules that you do or don't want the debugger to automatically load symbols for.
  • 當您主動進行調試時,請變更這些設定。Change these settings while you are actively debugging. 請參閱 在調試過程中管理符號See Manage symbols while debugging.

若要指定符號位置和載入選項:To specify symbol locations and loading options:

  1. 在 Visual Studio 中,開啟 [工具 > 選項] > (調試 > 符號 或) 的 調試 > 選項 > 符號In Visual Studio, open Tools > Options > Debugging > Symbols (or Debug > Options > Symbols).

  2. 符號檔 ( .pdb) 位置Under Symbol file (.pdb) locations,

    • 若要使用 Microsoft 符號伺服器NuGet.org 符號伺服器,請選取核取方塊。To use the Microsoft Symbol Servers or NuGet.org Symbol Server, select the checkbox.

    • 若要加入新的符號伺服器位置,To add a new symbol server location,

      1. 選取 + 工具列中的符號。Select the + symbol in the toolbar.
      2. 在 [文字] 欄位中輸入 (HTTP) 、網路共用或符號伺服器的本機路徑或符號位置的 URL。Type the URL (http), network share, or local path of the symbol server or symbol location in the text field. 陳述式完成可幫助您找出正確的格式。Statement completion helps you find the correct format.

      工具 - 選項 - - 符號頁面的調試Tools - Options - Debugging - Symbols page

      注意

      只搜尋指定的資料夾。Only the specified folder is searched. 您必須為想要搜尋的任何子資料夾新增專案。You must add entries for any subfolders that you want to search.

    • 若要加入新的 VSTS 符號伺服器位置,To add a new VSTS Symbol Server location,

      1. 在工具列中選取 ![工具]/ 選項//符號新增伺服器圖示 ] 圖示。Select the Tools/ Options/ Debugging/Symbols new server icon icon in the toolbar.
      2. 在 [ 連接到 VSTS 符號伺服器 ] 對話方塊中,選擇其中一個可用的符號伺服器,然後選取 [ 連接]In the Connect to VSTS Symbol Server dialog, choose one of the available symbol servers, and select Connect.
    • 若要變更符號位置的載入順序,請使用 ctrl + 向上 和向 + ctrl,或 向上 鍵和 向下 箭號圖示。To change the loading order for the symbol locations, use Ctrl+Up and Ctrl+Down, or the Up and Down arrow icons.

    • 若要編輯 URL 或路徑,請按兩下該專案,或是選取它,然後按 F2To edit a URL or path, double-click the entry, or select it and press F2.

    • 若要移除專案,請選取專案,然後選取 - 圖示。To remove an entry, select it, and then select the - icon.

  3. (選擇性) 若要改善符號載入效能,請在 [ 在此目錄中 的快取符號] 下,輸入符號伺服器可以複製符號的本機資料夾路徑。(Optional) To improve symbol loading performance, under Cache symbols in this directory, type a local folder path that symbol servers can copy symbols to.

    注意

    請勿將本機符號快取放在受保護的資料夾中,例如 C:\Windows 或子資料夾。Do not place the local symbol cache in a protected folder, like C:\Windows or a subfolder. 請改用可讀寫的資料夾。Use a read-write folder instead.

    注意

    針對 c + + 專案,如果您已 _NT_SYMBOL_PATH 設定環境變數,它會覆寫 此目錄中 的 [快取符號] 下設定的值。For C++ projects, if you have the _NT_SYMBOL_PATH environment variable set, it will override the value set under Cache symbols in this directory.

  4. 指定要讓偵錯工具從符號檔載入的模組, ( .pdb 在啟動時) 位置。Specify the modules that you want the debugger to load from the Symbol file (.pdb) locations when it starts.

    • 除非已排除 (預設) ,否則請選取 [ 載入所有模組 ],以載入符號檔位置中所有模組的所有符號,除了您明確排除的模組以外。Select Load all modules, unless excluded (the default) to load all the symbols for all modules in the symbol file location, except modules you specifically exclude. 若要排除某些模組,請選取 [ 指定排除的模組]、選取 + 圖示、輸入要排除的模組名稱,然後選取 [確定]To exclude certain modules, select Specify excluded modules, select the + icon, type the names of the modules to exclude, and select OK.

    • 若只要載入您從符號檔位置指定的模組,請選取 [ 僅載入指定的模組]。To load only modules you specify from the symbol file locations, select Load only specified modules. 選取 [ 指定包含的模組]、選取 + 圖示、輸入要包含的模組名稱,然後選取 [確定]Select Specify included modules, select the + icon, type the names of the modules to include, and then select OK. 未載入其他模組的符號檔。The symbol files for other modules are not loaded.

  5. 選取 [確定]。Select OK.

用於偵錯工具的其他符號選項Other symbol options for debugging

您可以在 [工具 > 選項] 的 > > [一般] (或 > > [一般) 的 Debug 選項中選取其他符號選項:You can select additional symbol options in Tools > Options > Debugging > General (or Debug > Options > General):

  • 載入 dll 匯出 (僅限原生)Load dll exports (Native only)

    載入適用于 C/c + + 的 DLL 匯出資料表。Loads DLL export tables for C/C++. 如需詳細資訊,請參閱 DLL 匯出資料表For details, see DLL export tables. 讀取 DLL 匯出資訊需要一些額外負荷,因此預設會關閉載入匯出資料表。Reading DLL export information involves some overhead, so loading export tables is turned off by default. 您也可以 dumpbin /exports 在 C/c + + 組建命令列中使用。You can also use dumpbin /exports in a C/C++ build command line.

  • 啟用位址層級的調試,並 在來源無法使用時顯示 反組解碼Enable address level debugging and Show disassembly if source not available

    在找不到來源或符號檔時,一律顯示反組解碼。Always shows the disassembly when source or symbol files are not found.

    / 一般反組解碼選項 / 調試的選項 Options / Debugging  / General disassembly options

  • 啟用來源伺服器支援Enable source server support

    當本機電腦上沒有任何原始程式碼,或 .pdb 檔案不符合原始程式碼時,會使用來源伺服器來協助您進行應用程式的偵錯工具。Uses Source Server to help debug an app when there is no source code on the local machine, or the .pdb file does not match the source code. 來源伺服器會取得檔案的要求,並從原始檔控制傳回實際的檔案。Source Server takes requests for files and returns the actual files from source control. 來源伺服器使用名為 srcsrv.dll 的 DLL 來執行,以讀取應用程式的 .pdb 檔。Source Server runs by using a DLL named srcsrv.dll to read the app's .pdb file. .Pdb 檔案包含原始程式碼存放庫的指標,以及用來從存放庫取出原始程式碼的命令。The .pdb file contains pointers to the source code repository, as well as commands used to retrieve source code from the repository.

    您可以在名為 srcsrv.ini 的檔案中列出允許的命令,以限制 srcsrv.dll 可從應用程式的 .pdb 檔執行的命令。You can limit the commands that srcsrv.dll can execute from the app's .pdb file by listing the allowed commands in a file named srcsrv.ini. srcsrv.ini 檔案放在與 srcsrv.dlldevenv.exe 相同的資料夾中。Place the srcsrv.ini file in the same folder as srcsrv.dll and devenv.exe.

    重要

    任意命令都可以內嵌在應用程式的 .pdb 檔中,因此請務必只將您想要執行的命令放入 srcsrv.ini 檔案中。Arbitrary commands can be embedded in an app's .pdb file, so make sure to put only the commands you want to execute into a srcsrv.ini file. 嘗試執行 srcsvr.ini 檔案中未包含的任何命令,會讓確認對話方塊出現。Any attempt to execute a command not in the srcsvr.ini file will cause a confirmation dialog box to appear. 如需詳細資訊,請參閱 Security Warning: Debugger Must Execute Untrusted CommandFor more information, see Security Warning: Debugger Must Execute Untrusted Command.

    由於不會對命令參數進行任何驗證,因此請謹慎使用受信任的命令。No validation is done on command parameters, so be careful with trusted commands. 例如,如果您在 srcsrv.ini 中列出 cmd.exe ,惡意使用者可能會在 cmd.exe 上指定參數,使其成為危險。For example, if you listed cmd.exe in your srcsrv.ini, a malicious user might specify parameters on cmd.exe that would make it dangerous.

    選取此專案和您想要的子專案。Select this item and the child items you want. 允許部分信任元件的來源伺服器僅 (受控) ,而且 一律執行不受信任的來源伺服器命令而不提示 ,可能會增加安全性風險。Allow source server for partial trust assemblies (Managed only) and Always run untrusted source server commands without prompting can increase the security risks.

    啟用來源伺服器選項Enable source server options

編譯器符號選項Compiler symbol options

當您使用標準 Debug 組建設定從 Visual Studio IDE 建立專案時,c + + 和 managed 編譯器會為您的程式碼建立適當的符號檔。When you build a project from the Visual Studio IDE with the standard Debug build configuration, the C++ and managed compilers create the appropriate symbol files for your code. 您也可以在程式碼中設定編譯器選項。You can also set compiler options in code.

.NET 選項.NET options

使用 /debug 建立,以建立 .pdb 檔。Build with /debug to create a .pdb file. 您可以使用 /debug:full/debug:pdbonly 建置應用程式。You can build applications with /debug:full or /debug:pdbonly. 使用 /debug:full 建置會產生可偵錯的程式碼。Building with /debug:full generates debuggable code. 使用 /debug:pdbonly 進行建置則會產生 .pdb 檔案,但是不會產生用於通知 JIT 編譯器有可用偵錯資訊的 DebuggableAttributeBuilding with /debug:pdbonly generates .pdb files, but does not generate the DebuggableAttribute that tells the JIT compiler that debug information is available. 如果您要為發行組建 (Release Build) 產生 .pdb 檔案,但不希望為可偵錯,則請使用 /debug:pdbonlyUse /debug:pdbonly if you want to generate .pdb files for a release build that you do not want to be debuggable. 如需詳細資訊,請參閱 /debug (c # 編譯器選項) /debug (Visual Basic) For more information, see /debug (C# compiler options) or /debug (Visual Basic).

C/C++ 選項C/C++ options

  • VC <x> .pdb<project> .pdb 檔案VC<x>.pdb and <project>.pdb files

    當您使用 /zi 或/zi建立時,會建立 C/c + + 的 .pdb 檔。A .pdb file for C/C++ is created when you build with /ZI or /Zi. 在中 Visual C++Visual C++/fd選項會為編譯器所建立的 .pdb 檔命名 In Visual C++Visual C++, the /Fd option names the .pdb file the compiler creates. 當您使用 IDE 在中建立專案時 Visual StudioVisual Studio ,會將 /fd 選項設定為建立副檔名為 <project> .pdb.pdb 檔。When you create a project in Visual StudioVisual Studio using the IDE, the /Fd option is set to create a .pdb file named <project>.pdb.

    如果您使用 makefile 來建立 C/c + + 應用程式,並在不使用 /fd 的情況下指定 /zi/zi ,則編譯器會建立兩個 .pdb 檔案:If you build your C/C++ application using a makefile, and you specify /ZI or /Zi without using /Fd, the compiler creates two .pdb files:

    • VC <x>,其中 <x> 代表 Microsoft c + + 編譯器的版本,例如 vc11.pdb .pdbVC<x>.pdb, where <x> represents the version of the Microsoft C++ compiler, for example VC11.pdb

      VC <x> .pdb 檔會儲存個別物件檔案的所有偵錯工具資訊,並且位於與專案 makefile 相同的目錄中。The VC<x>.pdb file stores all debugging information for the individual object files, and resides in the same directory as the project makefile. 每次建立物件檔案時,C/c + + 編譯器都會將 debug 資訊合併為 VC <x> .pdbEach time it creates an object file, the C/C++ compiler merges debug information into VC<x>.pdb. 因此,即使每個原始檔都包含一般標頭檔(例如 <windows.h> ),這些標頭中的 typedef 都只會儲存一次,而不會儲存在每個物件檔案中。So even if every source file includes common header files such as <windows.h>, the typedefs from those headers are stored only once, rather than in every object file. 插入的資訊包括類型資訊,但是不包括符號資訊 (例如函式定義)。The inserted information includes type information, but does not include symbol information, such as function definitions.

    • <project>.pdb<project>.pdb

      <project> .Pdb 檔案會儲存專案的 .exe 檔案的所有偵錯工具資訊,並且位於 \debug 子目錄中。The <project>.pdb file stores all debug information for the project's .exe file, and resides in the \debug subdirectory. <project> .Pdb 檔案包含完整的 debug 資訊,包括函式原型,而不只是在 VC 中 找到 <x> 的類型資訊。The <project>.pdb file contains full debug information, including function prototypes, not just the type information found in VC<x>.pdb.

    VC <x> .pdb<project> .pdb 檔案都允許累加式更新。Both the VC<x>.pdb and <project>.pdb files allow incremental updates. 連結器也會將 .pdb 檔案的路徑嵌入其所建立的 .exe.dll 檔案中。The linker also embeds the path to the .pdb files in the .exe or .dll file that it creates.

  • DLL 匯出資料表DLL export tables

    使用 dumpbin /exports 可查看 DLL 匯出資料表中的可用符號。Use dumpbin /exports to see the symbols available in the export table of a DLL. DLL 匯出資料表的符號資訊適用于處理 Windows 訊息、Windows 程式 (Windowproc) 、COM 物件、封送處理,或您沒有符號的任何 DLL。Symbolic information from DLL export tables can be useful for working with Windows messages, Windows procedures (WindowProcs), COM objects, marshaling, or any DLL you don't have symbols for. 這些符號適用於任何 32 位元系統 DLL。Symbols are available for any 32-bit system DLL. 這些呼叫都按呼叫順序列出,目前的函式 (巢狀最深處) 列在頂端。The calls are listed in the calling order, with the current function (the most deeply nested) at the top.

    藉由讀取 dumpbin /exports 輸出,您可以看到確切的函式名稱,包括非英數位元。By reading the dumpbin /exports output, you can see the exact function names, including non-alphanumeric characters. 看到確切的函式名稱對於在函式上設定中斷點很有用,因為函式名稱可以在偵錯工具中的其他地方截斷。Seeing exact function names is useful for setting a breakpoint on a function, because function names can be truncated elsewhere in the debugger. 如需詳細資訊,請參閱 dumpbin /exportsFor more information, see dumpbin /exports.

Web 應用程式Web applications

將 ASP.NET 應用程式的 web.config 檔案設定為 debug 模式。Set the web.config file of your ASP.NET application to debug mode. 偵錯模式會導致 ASP.NET 產生動態產生之檔案的符號,並使偵錯工具附加到 ASP.NET 應用程式。Debug mode causes ASP.NET to generate symbols for dynamically generated files and enables the debugger to attach to the ASP.NET application. 如果您已從 Web 專案範本建立專案,Visual Studio 會在您開始 debug 時自動設定此專案。Visual Studio sets this automatically when you start to debug, if you created your project from the web projects template.

在調試過程中管理符號Manage symbols while debugging

您可以使用 [模組]、[呼叫堆疊]、[區域變數]、[自動 變數] 或任何 [監看 式]視窗,在 偵測時載入符號或變更符號選項You can use the Modules, Call Stack, Locals, Autos, or any Watch window to load symbols or change symbol options while debugging. 如需詳細資訊,請參閱 深入瞭解偵錯工具附加至您應用程式的方式For more information, see Get more familiar with how the debugger attaches to your app.

在 [模組] 視窗中使用符號Work with symbols in the Modules window

在偵錯工具期間,[ 模組 ] 視窗會顯示偵錯工具視為使用者程式碼或 My Code 的程式碼模組,以及其符號載入狀態。During debugging, the Modules window shows the code modules the debugger is treating as user code, or My Code, and their symbol loading status. 您也可以在 [ 模組 ] 視窗中監視符號載入狀態、載入符號,以及變更符號選項。You can also monitor symbol loading status, load symbols, and change symbol options in the Modules window.

若要在進行調試時監視或變更符號位置或選項:To monitor or change symbol locations or options while debugging:

  1. 若要開啟 [模組] 視窗,請在調試過程中選取 [ Debug > Windows > 模組] (或按下 Ctrl + Alt + U) 。To open the Modules window, while debugging, select Debug > Windows > Modules (or press Ctrl + Alt + U).
  2. 在 [ 模組 ] 視窗中,以滑鼠右鍵按一下 符號狀態符號 檔標頭,或任何模組。In the Modules window, right-click the Symbol Status or Symbol File headers, or any module.
  3. 在快顯功能表中,選取下列其中一個選項︰In the context menu, select one of the following options:
選項Option DescriptionDescription
載入符號Load Symbols 顯示已略過、找不到或未載入符號的模組。Appears for modules with skipped, not found, or not loaded symbols. 嘗試從 [選項 > 調試 > 符號] 頁面上指定的位置載入符號。Attempts to load symbols from locations specified on the Options > Debugging > Symbols page. 如果找不到或未載入符號檔,則會啟動 檔案總管 ,讓您可以指定要搜尋的新位置。If the symbol file is not found or not loaded, launches File Explorer so you can specify a new location to search.
符號載入資訊Symbol Load Information 顯示載入的符號檔的位置,或如果偵錯工具找不到檔案時所搜尋的位置。Shows the location of a loaded symbol file, or the locations that were searched if the debugger cannot find the file.
符號設定Symbol Settings 開啟 [選項 > 調試 > 符號] 頁面,您可以在其中編輯和新增符號位置。Opens the Options > Debugging > Symbols page, where you can edit and add symbol locations.
永遠自動載入Always Load Automatically 將選取的符號檔加入至偵錯工具自動載入的檔案清單。Adds the selected symbol file to the list of files that are automatically loaded by the debugger.

使用未載入的符號/沒有來源載入的頁面Use the No Symbols Loaded/No Source Loaded pages

有幾種方式可讓偵錯工具中斷程式碼,而不含符號或原始程式檔:There are several ways for the debugger to break into code that does not have symbol or source files available:

  • 逐步執行程式碼。Step into code.
  • 從中斷點或例外狀況中斷程式碼。Break into code from a breakpoint or exception.
  • 切換至不同的執行緒。Switch to a different thread.
  • 按兩下 [ 呼叫堆疊 ] 視窗中的框架,以變更堆疊框架。Change the stack frame by double-clicking a frame in the Call Stack window.

發生這種情況時,偵錯工具會顯示 [ 未載入符號 ] 或 [ 未載入來源 ] 頁面,協助您尋找和載入必要的符號或來源。When this happens, the debugger displays the No Symbols Loaded or No Source Loaded pages to help you find and load the necessary symbols or source.

未載入符號頁面No Symbols Loaded page

若要使用 [未載入符號] 檔頁面,以協助尋找及載入遺漏的符號:To use the No Symbols Loaded document page to help find and load missing symbols:

  • 若要變更搜尋路徑,請選取未選取的路徑,或選取 [ 新增路徑 ] 或 [ 新增 VSTS 路徑 ],然後輸入或選取新的路徑。To change the search path, select an unselected path, or select New Path or New VSTS Path and enter or select a new path. 選取 [ 載入 ] 以再次搜尋路徑,並載入符號檔(如果找到的話)。Select Load to search the paths again and load the symbol file if it is found.
  • 若要覆寫任何符號選項並重試搜尋路徑,請選取 [ <executable-name> 流覽並尋找]To override any symbol options and retry the search paths, select Browse and find <executable-name>. 如果找到符號檔,則會載入符號檔,或 檔案總管 開啟,讓您可以手動選取符號檔。The symbol file is loaded if it is found, or File Explorer opens so you can manually select the symbol file.
  • 若要開啟 [選項 > 調試 > 符號] 頁面,請選取 [變更符號設定]。To open the Options > Debugging > Symbols page, select Change Symbol Settings.
  • 若要在新視窗中一次顯示反組解碼,請選取 [ 視圖 反組解碼],或選取 [ 選項] 對話方塊 ,將選項設定為 [當找不到來源或符號檔時一律顯示反組解碼]。To show the disassembly in a new window one time, select view disassembly, or select Options dialog to set the option to always show the disassembly when source or symbol files are not found.
  • 若要顯示搜尋的位置和結果,請展開 [ 符號載入資訊]。To show the locations searched and the outcome, expand Symbol load information.

如果偵錯工具在您執行其中一個選項之後找到 .pdb 檔案,而且可以使用 .pdb 檔案中的資訊來抓取原始程式檔,則會顯示來源。If the debugger finds the .pdb file after you execute one of the options, and can retrieve the source file using the information in the .pdb file, it displays the source. 否則,它會顯示 [ 未載入來源 ] 頁面來描述問題,並連結至可能會解決問題的動作。Otherwise, it displays a No Source Loaded page that describes the issue, with links to actions that might resolve the issue.

若要將原始檔搜尋路徑加入至方案:To add source file search paths to a solution:

您可以指定偵錯工具搜尋原始程式檔的位置,以及從搜尋中排除特定檔案。You can specify the locations the debugger searches for source files, and exclude specific files from the search.

  1. 在 [方案總管 中選取方案,然後選取 [屬性] 圖示,按下 Alt + enter,或按一下滑鼠右鍵並選取 [屬性]。Select the solution in Solution Explorer, and then select the Properties icon, press Alt+Enter, or right-click and select Properties.

  2. 選取 [ Debug Source Files]。Select Debug Source Files.

  3. 在 [ 包含原始程式碼的目錄] 下,輸入或選取要搜尋的原始程式碼位置。Under Directories containing source code, type or select source code locations to search. 使用 新行 圖示來新增更多位置、 向上 箭號和 向下 箭號圖示來重新排序它們,或使用 X 圖示來刪除它們。Use the New Line icon to add more locations, the Up and Down arrow icons to reorder them, or the X icon to delete them.

    注意

    偵錯工具只會搜尋指定的目錄。The debugger searches only the specified directory. 您必須自行加入要搜尋的所有子目錄項目。You must add entries for any subdirectories that you want to search.

  4. 在 [不 尋找這些原始程式 檔] 底下,輸入要從搜尋中排除的原始程式檔名稱。Under Do not look for these source files, type the names of source files to exclude from search.

  5. 選取 [確定] [套用]。Select OK or Apply.

另請參閱See also