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

# IXtfConsoleControlClient::GenerateStackDump

> IXtfConsoleControlClient::GenerateStackDump

# IXtfConsoleControlClient::GenerateStackDump

生成堆栈转储。

<a id="syntaxSection" />

## 语法

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

<a id="parametersSection" />

### 参数

*ProcessId*\
类型：UINT32

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

*DumpType*\
类型：UINT32

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

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

*ImageName*\
类型：LPCWSTR

映像的名称。

*FilePath*\
类型：LPBSTR

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

<a id="retvalSection" />

### 返回值

类型：HRESULT

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

<a id="remarksSection" />

## 备注

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

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

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

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

<a id="remarks_output" />

### 处理 LPBSTR 指针

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

<a id="requirementsSection" />

## 要求

**头文件：** xtfconsolecontrol.h

**库：** xtfconsolecontrol.lib

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

<a id="seealsoSection" />

## 另请参阅

[XtfConsoleControl](/reference/tools/xtf/xtfconsolecontrol/xtfconsolecontrol_members)\
[XBOX Tools Framework](/reference/tools/xtf/atoc-xbox-tools-framework)


## Related topics

- [IXtfConsoleControlClient](/zh-CN/reference/tools/xtf/xtfconsolecontrol/interfaces/IXtfConsoleControlClient/ixtfconsolecontrolclient.md)
- [IXtfConsoleControlClient::ShutdownConsole](/zh-CN/reference/tools/xtf/xtfconsolecontrol/interfaces/IXtfConsoleControlClient/methods/ixtfconsolecontrolclient_shutdownconsole.md)
- [IXtfConsoleControlClient::UpdatesPending](/zh-CN/reference/tools/xtf/xtfconsolecontrol/interfaces/IXtfConsoleControlClient/methods/ixtfconsolecontrolclient_updatespending.md)
- [IXtfConsoleControlClient::SetConfigValue](/zh-CN/reference/tools/xtf/xtfconsolecontrol/interfaces/IXtfConsoleControlClient/methods/ixtfconsolecontrolclient_setconfigvalue.md)
- [IXtfConsoleControlClient::GetAllSettings](/zh-CN/reference/tools/xtf/xtfconsolecontrol/interfaces/IXtfConsoleControlClient/methods/ixtfconsolecontrolclient_getallsettings.md)
