pthdb_pthread_context 或 pthdb_pthread_setcontext 子例程

用途

通过 struct context64 结构提供对 pthread 上下文的访问。

pthread 调试库 (libpthdebug.a)

语法

#include <sys/pthdebug.h>

int pthdb_pthread_context (pthdb_session_t   session,
                           pthdb_pthread_t   pthread,
                           pthdb_context_t * context)

int pthdb_pthread_setcontext (pthdb_session_t   session,
                              pthdb_pthread_t   pthread,
                              pthdb_context_t * context)

描述

pthread 调试库通过 struct context64 结构提供对 pthread 上下文的访问,无论进程是 32 位还是 64 位。 对于 32 位进程,调试器应该能够从 32 位转换为 64 位,并从 64 位转换为 64 位。 此结构的填充程度取决于是否存在 PTHDB_FLAG_GPRSPTHDB_FLAG_SPRSPTHDB_FLAG_FPRS 会话标志。 需要使用 pthread 调试库来访问没有内核线程的 pthread 的上下文。 pthread 调试库也可以用来访问带有内核线程的 pthread 的上下文,但这会导致调用回调试器,这意味着调试器能够自己获取此信息。 调试器确定内核线程是以用户方式还是内核方式运行,然后相应地填充 struct context64 。 pthread 调试库本身不使用此信息,因此对 read_regswrite_regs 回调函数的正确实现不敏感。

pthdb_pthread_context 根据会话标志的设置报告 pthread 的上下文。 如果 pthread 具有内核线程,那么使用 read_regs 回调。 如果未定义 read_regs ,那么将返回 PTHDB_NOTSUP

pthdb_pthread_setcontext 根据会话标志的设置设置 pthread 的上下文。 如果 pthread 没有内核线程,那么使用 write_data 回调。 如果 pthread 具有内核线程,请使用 write_regs 回调。

如果调试器未定义 read_regswrite_regs 回调,并且如果 pthread 没有内核线程,那么 pthdb_pthread_contextpthdb_pthread_setcontext 函数成功。 但是,如果 pthread 没有内核线程,那么这些函数将失败并返回 PTHDB_CONTEXT

参数

描述
会话 会话句柄。
pthread pthread 句柄。
上下文 上下文缓冲区指针。

返回值

如果成功,那么这些函数将返回 PTHDB_SUCCESS。 否则,将返回错误代码。

错误代码

描述
PTHDB_BAD_SESSION 会话句柄无效。
PTHDB_BAD_PTHREAD pthread 句柄无效。
PTHDB_BAD_POINTER 缓冲区指针无效。
PTHDB_CALLBACK 回调函数失败。
PTHDB_CONTEXT 无法确定 pthread 上下文。
PTHDB_MEMORY 内存不足
PTHDB_NOTSUP 如果 read_regswrite_datawrite_regs 回调设置为 NULL ,那么 pthdb_pthread_ (set) context 将返回 PTHDB_NOTSUP
PTHDB_INTERNAL 库中出错。