~clint-fewbar/ubuntu/precise/erlang/merge-15b

« back to all changes in this revision

Viewing changes to erts/emulator/beam/erl_process_dump.c

  • Committer: Package Import Robot
  • Author(s): Sergei Golovan
  • Date: 2011-12-15 19:20:10 UTC
  • mfrom: (1.1.18) (3.5.15 sid)
  • mto: (3.5.16 sid)
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: package-import@ubuntu.com-20111215192010-jnxcfe3tbrpp0big
Tags: 1:15.b-dfsg-1
* New upstream release.
* Upload to experimental because this release breaks external drivers
  API along with ABI, so several applications are to be fixed.
* Removed SSL patch because the old SSL implementation is removed from
  the upstream distribution.
* Removed never used patch which added native code to erlang beam files.
* Removed the erlang-docbuilder binary package because the docbuilder
  application was dropped by upstream.
* Documented dropping ${erlang-docbuilder:Depends} substvar in
  erlang-depends(1) manpage.
* Made erlang-base and erlang-base-hipe provide virtual package
  erlang-abi-15.b (the number means the first erlang version, which
  provides current ABI).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * %CopyrightBegin%
3
3
 *
4
 
 * Copyright Ericsson AB 2003-2010. All Rights Reserved.
 
4
 * Copyright Ericsson AB 2003-2011. All Rights Reserved.
5
5
 *
6
6
 * The contents of this file are subject to the Erlang Public License,
7
7
 * Version 1.1, (the "License"); you may not use this file except in
194
194
        } else if (is_pid(x)) {
195
195
            erts_print(to, to_arg, "P%T", x);
196
196
        } else if (is_port(x)) {
197
 
            erts_print(to, to_arg, "p<%bpu.%bpu>",
 
197
            erts_print(to, to_arg, "p<%beu.%beu>",
198
198
                       port_channel_no(x), port_number(x));
199
199
        } else if (is_nil(x)) {
200
200
            erts_putc(to, to_arg, 'N');
261
261
static void
262
262
heap_dump(int to, void *to_arg, Eterm x)
263
263
{
 
264
    DeclareTmpHeapNoproc(last,1);
 
265
    Eterm* next = last;
264
266
    Eterm* ptr;
265
 
    Eterm last = OUR_NIL;
266
 
    Eterm* next = &last;
267
267
 
268
268
    if (is_immed(x) || is_CP(x)) {
269
269
        return;
270
270
    }
 
271
    UseTmpHeapNoproc(1);
 
272
    *last = OUR_NIL;
271
273
 
272
 
 again:
273
 
    if (x == OUR_NIL) { /* We are done. */
274
 
        return;
275
 
    } if (is_CP(x)) {
276
 
        next = (Eterm *) EXPAND_POINTER(x);
277
 
    } else if (is_list(x)) {
278
 
        ptr = list_val(x);
279
 
        if (ptr[0] != OUR_NIL) {
280
 
            erts_print(to, to_arg, ADDR_FMT ":l", ptr);
281
 
            dump_element(to, to_arg, ptr[0]);
282
 
            erts_putc(to, to_arg, '|');
283
 
            dump_element(to, to_arg, ptr[1]);
284
 
            erts_putc(to, to_arg, '\n');
285
 
            if (is_immed(ptr[1])) {
286
 
                ptr[1] = make_small(0);
 
274
    while (x != OUR_NIL) {
 
275
        if (is_CP(x)) {
 
276
            next = (Eterm *) EXPAND_POINTER(x);
 
277
        } else if (is_list(x)) {
 
278
            ptr = list_val(x);
 
279
            if (ptr[0] != OUR_NIL) {
 
280
                erts_print(to, to_arg, ADDR_FMT ":l", ptr);
 
281
                dump_element(to, to_arg, ptr[0]);
 
282
                erts_putc(to, to_arg, '|');
 
283
                dump_element(to, to_arg, ptr[1]);
 
284
                erts_putc(to, to_arg, '\n');
 
285
                if (is_immed(ptr[1])) {
 
286
                    ptr[1] = make_small(0);
 
287
                }
 
288
                x = ptr[0];
 
289
                ptr[0] = (Eterm) COMPRESS_POINTER(next);
 
290
                next = ptr + 1;
 
291
                continue;
287
292
            }
288
 
            x = ptr[0];
289
 
            ptr[0] = (Eterm) COMPRESS_POINTER(next);
290
 
            next = ptr + 1;
291
 
            goto again;
292
 
        }
293
 
    } else if (is_boxed(x)) {
294
 
        Eterm hdr;
295
 
        
296
 
        ptr = boxed_val(x);
297
 
        hdr = *ptr;
298
 
        if (hdr != OUR_NIL) {   /* If not visited */
299
 
            erts_print(to, to_arg, ADDR_FMT ":", ptr);
300
 
            if (is_arity_value(hdr)) {
301
 
                Uint i;
302
 
                Uint arity = arityval(hdr);
303
 
 
304
 
                erts_print(to, to_arg, "t" WORD_FMT ":", arity);
305
 
                for (i = 1; i <= arity; i++) {
306
 
                    dump_element(to, to_arg, ptr[i]);
307
 
                    if (is_immed(ptr[i])) {
308
 
                        ptr[i] = make_small(0);
309
 
                    }
310
 
                    if (i < arity) {
311
 
                        erts_putc(to, to_arg, ',');
312
 
                    }
313
 
                }
314
 
                erts_putc(to, to_arg, '\n');
315
 
                if (arity == 0) {
316
 
                    ptr[0] = OUR_NIL;
 
293
        } else if (is_boxed(x)) {
 
294
            Eterm hdr;
 
295
 
 
296
            ptr = boxed_val(x);
 
297
            hdr = *ptr;
 
298
            if (hdr != OUR_NIL) {       /* If not visited */
 
299
                erts_print(to, to_arg, ADDR_FMT ":", ptr);
 
300
                if (is_arity_value(hdr)) {
 
301
                    Uint i;
 
302
                    Uint arity = arityval(hdr);
 
303
 
 
304
                    erts_print(to, to_arg, "t" WORD_FMT ":", arity);
 
305
                    for (i = 1; i <= arity; i++) {
 
306
                        dump_element(to, to_arg, ptr[i]);
 
307
                        if (is_immed(ptr[i])) {
 
308
                            ptr[i] = make_small(0);
 
309
                        }
 
310
                        if (i < arity) {
 
311
                            erts_putc(to, to_arg, ',');
 
312
                        }
 
313
                    }
 
314
                    erts_putc(to, to_arg, '\n');
 
315
                    if (arity == 0) {
 
316
                        ptr[0] = OUR_NIL;
 
317
                    } else {
 
318
                        x = ptr[arity];
 
319
                        ptr[0] = (Eterm) COMPRESS_POINTER(next);
 
320
                        next = ptr + arity - 1;
 
321
                        continue;
 
322
                    }
 
323
                } else if (hdr == HEADER_FLONUM) {
 
324
                    FloatDef f;
 
325
                    char sbuf[31];
 
326
                    int i;
 
327
 
 
328
                    GET_DOUBLE_DATA((ptr+1), f);
 
329
                    i = sys_double_to_chars(f.fd, (char*) sbuf);
 
330
                    sys_memset(sbuf+i, 0, 31-i);
 
331
                    erts_print(to, to_arg, "F%X:%s\n", i, sbuf);
 
332
                    *ptr = OUR_NIL;
 
333
                } else if (_is_bignum_header(hdr)) {
 
334
                    erts_print(to, to_arg, "B%T\n", x);
 
335
                    *ptr = OUR_NIL;
 
336
                } else if (is_binary_header(hdr)) {
 
337
                    Uint tag = thing_subtag(hdr);
 
338
                    Uint size = binary_size(x);
 
339
                    Uint i;
 
340
 
 
341
                    if (tag == HEAP_BINARY_SUBTAG) {
 
342
                        byte* p;
 
343
 
 
344
                        erts_print(to, to_arg, "Yh%X:", size);
 
345
                        p = binary_bytes(x);
 
346
                        for (i = 0; i < size; i++) {
 
347
                            erts_print(to, to_arg, "%02X", p[i]);
 
348
                        }
 
349
                    } else if (tag == REFC_BINARY_SUBTAG) {
 
350
                        ProcBin* pb = (ProcBin *) binary_val(x);
 
351
                        Binary* val = pb->val;
 
352
 
 
353
                        if (erts_smp_atomic_xchg_nob(&val->refc, 0) != 0) {
 
354
                            val->flags = (UWord) all_binaries;
 
355
                            all_binaries = val;
 
356
                        }
 
357
                        erts_print(to, to_arg, "Yc%X:%X:%X", val,
 
358
                                   pb->bytes - (byte *)val->orig_bytes,
 
359
                                   size);
 
360
                    } else if (tag == SUB_BINARY_SUBTAG) {
 
361
                        ErlSubBin* Sb = (ErlSubBin *) binary_val(x);
 
362
                        Eterm* real_bin = binary_val(Sb->orig);
 
363
                        void* val;
 
364
 
 
365
                        if (thing_subtag(*real_bin) == REFC_BINARY_SUBTAG) {
 
366
                            ProcBin* pb = (ProcBin *) real_bin;
 
367
                            val = pb->val;
 
368
                        } else {        /* Heap binary */
 
369
                            val = real_bin;
 
370
                        }
 
371
                        erts_print(to, to_arg, "Ys%X:%X:%X", val, Sb->offs, size);
 
372
                    }
 
373
                    erts_putc(to, to_arg, '\n');
 
374
                    *ptr = OUR_NIL;
 
375
                } else if (is_external_pid_header(hdr)) {
 
376
                    erts_print(to, to_arg, "P%T\n", x);
 
377
                    *ptr = OUR_NIL;
 
378
                } else if (is_external_port_header(hdr)) {
 
379
                    erts_print(to, to_arg, "p<%beu.%beu>\n",
 
380
                               port_channel_no(x), port_number(x));
 
381
                    *ptr = OUR_NIL;
317
382
                } else {
318
 
                    x = ptr[arity];
319
 
                    ptr[0] = (Eterm) COMPRESS_POINTER(next);
320
 
                    next = ptr + arity - 1;
321
 
                    goto again;
322
 
                }
323
 
            } else if (hdr == HEADER_FLONUM) {
324
 
                FloatDef f;
325
 
                char sbuf[31];
326
 
                int i;
327
 
 
328
 
                GET_DOUBLE_DATA((ptr+1), f);
329
 
                i = sys_double_to_chars(f.fd, (char*) sbuf);
330
 
                sys_memset(sbuf+i, 0, 31-i);
331
 
                erts_print(to, to_arg, "F%X:%s\n", i, sbuf);
332
 
                *ptr = OUR_NIL;
333
 
            } else if (_is_bignum_header(hdr)) {
334
 
                erts_print(to, to_arg, "B%T\n", x);
335
 
                *ptr = OUR_NIL;
336
 
            } else if (is_binary_header(hdr)) {
337
 
                Uint tag = thing_subtag(hdr);
338
 
                Uint size = binary_size(x);
339
 
                Uint i;
340
 
 
341
 
                if (tag == HEAP_BINARY_SUBTAG) {
342
 
                    byte* p;
343
 
 
344
 
                    erts_print(to, to_arg, "Yh%X:", size);
345
 
                    p = binary_bytes(x);
346
 
                    for (i = 0; i < size; i++) {
347
 
                        erts_print(to, to_arg, "%02X", p[i]);
348
 
                    }
349
 
                } else if (tag == REFC_BINARY_SUBTAG) {
350
 
                    ProcBin* pb = (ProcBin *) binary_val(x);
351
 
                    Binary* val = pb->val;
352
 
 
353
 
                    if (erts_smp_atomic_xchg(&val->refc, 0) != 0) {
354
 
                        val->flags = (UWord) all_binaries;
355
 
                        all_binaries = val;
356
 
                    }
357
 
                    erts_print(to, to_arg, "Yc%X:%X:%X", val,
358
 
                               pb->bytes - (byte *)val->orig_bytes,
359
 
                               size);
360
 
                } else if (tag == SUB_BINARY_SUBTAG) {
361
 
                    ErlSubBin* Sb = (ErlSubBin *) binary_val(x);
362
 
                    Eterm* real_bin = binary_val(Sb->orig);
363
 
                    void* val;
364
 
 
365
 
                    if (thing_subtag(*real_bin) == REFC_BINARY_SUBTAG) {
366
 
                        ProcBin* pb = (ProcBin *) real_bin;
367
 
                        val = pb->val;
368
 
                    } else {    /* Heap binary */
369
 
                        val = real_bin;
370
 
                    }
371
 
                    erts_print(to, to_arg, "Ys%X:%X:%X", val, Sb->offs, size);
372
 
                }
373
 
                erts_putc(to, to_arg, '\n');
374
 
                *ptr = OUR_NIL;
375
 
            } else if (is_external_pid_header(hdr)) {
376
 
                erts_print(to, to_arg, "P%T\n", x);
377
 
                *ptr = OUR_NIL;
378
 
            } else if (is_external_port_header(hdr)) {
379
 
                erts_print(to, to_arg, "p<%bpu.%bpu>\n",
380
 
                           port_channel_no(x), port_number(x));
381
 
                *ptr = OUR_NIL;
382
 
            } else {
383
 
                /*
384
 
                 * All other we dump in the external term format.
385
 
                 */
386
 
                dump_externally(to, to_arg, x);
387
 
                erts_putc(to, to_arg, '\n');
388
 
                *ptr = OUR_NIL;
 
383
                    /*
 
384
                     * All other we dump in the external term format.
 
385
                     */
 
386
                        dump_externally(to, to_arg, x);
 
387
                    erts_putc(to, to_arg, '\n');
 
388
                    *ptr = OUR_NIL;
 
389
                }
389
390
            }
390
391
        }
 
392
        x = *next;
 
393
        *next = OUR_NIL;
 
394
        next--;
391
395
    }
392
 
 
393
 
    x = *next;
394
 
    *next = OUR_NIL;
395
 
    next--;
396
 
    goto again;
 
396
    UnUseTmpHeapNoproc(1);
397
397
}
398
398
 
399
399
static void