C ++编译库的钩子函数用于调试

时间:2016-12-27 14:59:34

标签: c++ windows debugging 64-bit hook

出于调试目的,希望在每次调用时获取编译库中某些函数的参数。我知道我可以重新编译库,但是对于某些库来说可能需要一半的时间(例如Qt)。

在编译库中考虑此函数

#!/bin/bash

trapinfo()
{
   echo "=== Trap Info: Status=$? LINENO=$@ A=$A"
}

main()
{
   trap 'trapinfo $LINENO $SAVE_IT -- ${BASH_LINENO[*]}' ERR

   set -e
   set -E
   set -o errtrace
   shopt -s extdebug

   local -g A=1

   # false        # If uncommented, LINENO would be 19
   SAVE_IT=$LINENO && (exit 73)     # LINENO is magic, but a custom variable isn’t

   A=2
}

main

包含库中的SomeClass的程序

class SomeClass
{
public:
    static QString getUpper(const QString &str);
};

我找到了一些similar question,但我不需要dll注入。这是我的程序,包括库。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案

library(PolyHook)做我想做的事。