English 中文(简体)
习俗核心倾销
原标题:customise core dump

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.

如果你想更容易发现这种信息,那么你就能够引进一种全球性的信息,例如。

void *a_corrupt_ptr;  // global

void some_func() {
...

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

然后在座标上查阅<代码>a_corrupt_ptr。

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





相关问题
Signal 11, segmentation fault on iphone App exit

I have an iphone app. It seems to run fine. When I connect to a provisioned iphone to Xcode and run the App, the console log in the Organizer window, always complains about a Segmentation fault when ...

Segmentation fault on large array sizes

The following code gives me a segmentation fault when run on a 2Gb machine, but works on a 4GB machine. int main() { int c[1000000]; cout << "done "; return 0; } The size of the ...

PHP doesn t handle stack overflow?

I was surprised when I just tried the following PHP code: function foo() { foo(); } foo(); I expected to get "500: Internal server error". Instead the connection was closed immediately (no bytes ...

PHP segmentation fault caused by php while loop

I discovered a way to make php segfault, and I m a bit curious about what s happening. Maybe someone can explain this for me? joern@xps:..com/trunk5/tools/nestedset> cat > while.php <?php ...

C: Accessing a pointer from outside a function

I have the following code: int takeEven(int *nums, int numelements, int *newlist) { newlist = malloc(numelements * sizeof *newlist); int i, found = 0; for(i = 0; i < numelements; ++i, ...

Segmentation fault on time(0);

I m rewriting an old program to do some new stuff, and suddenly I get a segmentation fault error on the following line of code: time_t seconds_since_time_begun = time(0); Why, oh why? Update: I ...

热门标签