> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# GenerateStackDump

> IXtfConsoleControlClient::GenerateStackDump

# IXtfConsoleControlClient::GenerateStackDump

生成堆栈转储。

## 语法

```cpp theme={null}
HRESULT GenerateStackDump(
         UINT32 ProcessId,
         UINT32 DumpType,
         LPCWSTR ImageName,
         LPBSTR FilePath  
)  
```

### 参数

*ProcessId*\
类型：UINT32

要为其创建堆栈转储的进程的标识符。

*DumpType*\
类型：UINT32

要创建的堆栈转储类型。有效的转储类型为：

| 值 | 说明 |
| - | - |
| 0 | Triage |
| 1 | Mini |
| 2 | Heap |

*ImageName*\
类型：LPCWSTR

映像的名称。

*FilePath*\
类型：LPBSTR

指向接收所创建堆栈转储文件的文件路径的字符串的指针。

### 返回值

类型：HRESULT

如果成功，则返回 `S_OK`；否则返回 HRESULT 错误代码。如果函数在等待堆栈转储完成时超时，此函数将返回 `E_MESSAGE_TIMED_OUT`。

## 备注

此函数为开发主机上的可执行映像从指定进程生成堆栈转储。堆栈转储将作为文件保存到主机的暂存驱动器上，路径由 `FilePath` 返回。

堆栈转储捕获的信息以及捕获该信息所需的时间取决于 `DumpType` 中指定的转储类型。此函数在 5 分钟后超时；如果在函数超时之前主机未返回堆栈转储，则此函数返回 `E_MESSAGE_TIMED_OUT`。下表描述了每种堆栈转储类型返回的信息。

| 转储类型 | 说明 |
| - | - |
| Triage | 收集所有线程的堆栈跟踪、活动 OS 句柄、线程信息以及有关已卸载模块的信息。Triage 转储会清除个人身份信息 (PII)。 |
| Mini | 收集所有已加载模块的数据段、与安全令牌相关的数据、线程信息以及有关已卸载模块的信息。Mini 转储不会清除 PII。 |
| Heap | 提供在 Game OS 中运行的所有进程和内存的完整用户模式故障转储。虽然此选项提供的信息最多，但可能需要几分钟才能写出所有数据。 |

有关可用的工具和自动化 API（例如 XBOX Tools Framework (XTF)）的详细信息，请参阅 [工具和自动化 API (NDA 主题)](https://learn.microsoft.com/gaming/gdk/docs/gdk-dev/console-dev/debug/atoc-api-tools-dev-env)。

### 处理 LPBSTR 指针

有关处理此函数返回的 LPBSTR 指针的详细信息，请参阅 [为 BSTR 分配和释放内存](https://learn.microsoft.com/cpp/atl-mfc-shared/allocating-and-releasing-memory-for-a-bstr?view=vs-2019)。

## 要求

**头文件：** xtfconsolecontrol.h

**库：** xtfconsolecontrol.lib

**支持的平台：** Windows（适用于 XBOX 主机工具）

## 另请参阅

[XtfConsoleControl](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfconsolecontrol/xtfconsolecontrol_members.md)\
[XBOX Tools Framework](https://docs.xbox.com/zh-CN/reference/tools/xtf/atoc-xbox-tools-framework.md)


## Related topics

- [IXtfConsoleControlClient（接口内容）](https://docs.xbox.com/zh-CN/reference/tools/xtf/xtfconsolecontrol/interfaces/IXtfConsoleControlClient/ixtfconsolecontrolclient.md)
- [SetWatsonDumpEnablement](https://docs.xbox.com/zh-CN/reference/graphics/d3d12/interfaces/id3d12deviceremovedextendeddatasettings/methods/id3d12deviceremovedextendeddatasettings_setwatsondumpenablement_public.md)
- [xbWatson](https://docs.xbox.com/zh-CN/tools/tools-console/xbWatson/xbwatson.md)
- [XBOX 上的 Address Sanitizer 支持](https://docs.xbox.com/zh-CN/tools/tools-console/visualstudio/address-sanitizer-support.md)
- [Crash data 页面](https://docs.xbox.com/zh-CN/tools/tools-console/wdp/windows-device-portal-on-xbox-crash-data.md)
