开发者

customise core dump

开发者 https://www.devze.com 2023-04-06 14:06 出处:网络
can开发者_高级运维 anybody tell me if there is a way we can force a segfault with certain specific information in it. Forcing a segfault can be done through abort(), call. But i need something

can开发者_高级运维 anybody tell me if there is a way we can force a segfault with certain specific information in it. Forcing a segfault can be done through abort(), call. But i need something like abort(ptr), where ptr is a pointer that tells the actual memory where some corruption started.

thanks, Kapil Upadhayay


Your question is very unclear. Core dump contains a memory snapshot of your entire process, so it already contains the info you want it to contain.

If you want to make finding that info easier, you can introduce a global, e.g.

void *a_corrupt_ptr;  // global

void some_func() {
...

  if (the_pointer_has_been_corrupted(ptr)) {
    a_corrupt_ptr  = ptr;
    abort();
  }

and then examine a_corrupt_ptr in your debugger.

Or you can simply print the value before calling abort().

0

精彩评论

暂无评论...
验证码 换一张
取 消