是否可以释放在 GDB 的用户定义命令中分配的附加进程中的对象?

问题描述 投票:0回答:0
  1. 由GDB附加到一个进程运行
    user defined commands
  gdb attach `pidof AttachedProcess`
  1. 在 GDB 的用户定义命令中通过 malloc 分配对象。分配的对象将传递给附加进程并由附加进程释放。
  define myFunc1
    set $pRealName = (const char*)malloc(100)
    call funcInAttachedProcess $pRealName
    # pRealName would be freed by funcInAttachedProcess
  end
  1. 但是在附加进程中调用 free(pObj) 时,会出现关于“尝试释放线程中不是 malloc() 的地址 ...”的错误。

  2. 是否可以直接在附加进程中分配一个由 free() 方法释放的对象?

gdb malloc free user-defined
© www.soinside.com 2019 - 2024. All rights reserved.