Skip to content

Instantly share code, notes, and snippets.

@rptynan
Created April 26, 2017 15:30
Show Gist options
  • Save rptynan/2a4b149e67f7ea7ba3cc6daa680be18e to your computer and use it in GitHub Desktop.
Save rptynan/2a4b149e67f7ea7ba3cc6daa680be18e to your computer and use it in GitHub Desktop.
root@feast-1 /u/l/s/p/l/test # ❮❮❮ time gmake -B -f tools/Makefile.allocsites /usr/lib/allocsites/usr/obj/usr/src/sys/CRUNCHED/kernel.debug-allocsites.c 1>! ~/allocsites.log 2>! ~/allocsites.errorlog
tools/Makefile.allocsites:13: ALLOCSITES_BASE is /usr/lib/allocsites
all_alloc_descriptors is: malloc(Zpi)p malloc(Z)p calloc(zZ)p realloc(pZ)p memalign(zZ)p alloca(Z)pmeta_instr_regexp is: ^([0-9a-f]*) <([^>]*)>.*((call|jmp).*(<((malloc)|(calloc)|(realloc)|(memalign)|(posix_memalign)|(valloc)|(__monalloca_)|(malloc)|(__wrap_malloc)|(malloc)|(__wrap_malloc)|(calloc)|(__wrap_calloc)|(realloc)|(__wrap_realloc)|(memalign)|(__wrap_memalign)|(alloca)|(__wrap_alloca))|.*\*)|.* 00 00 00 00.*callq)objdumpmeta has meta_instr_regexp: ^([0-9a-f]*) <([^>]*)>.*((call|jmp).*(<((malloc)|(calloc)|(realloc)|(memalign)|(posix_memalign)|(valloc)|(__monalloca_)|(malloc)|(__wrap_malloc)|(malloc)|(__wrap_malloc)|(calloc)|(__wrap_calloc)|(realloc)|(__wrap_realloc)|(memalign)|(__wrap_memalign)|(alloca)|(__wrap_alloca))|.*\*)|.* 00 00 00 00.*callq)Written allocsites output to /tmp/root/tmp.aBS0DEDe
Written objdump output to /tmp/root/tmp.5nWZmKiT
Found allocation sites:·
ffffffff80cc73a7 cam_quirkmatch +0x2a
ffffffff80cc7a4b cam_compat_handle_0x17 +0x157
ffffffff80cc7d82 cam_compat_ioctl +0x6b
ffffffff80cc7d8c cam_compat_ioctl +0x75
ffffffff80cc7e34 camperiphfree +0x84
ffffffff80cc7faa camperiphfree +0x1fa
ffffffff80cc8052 camperiphscsistatuserror +0x58
...
regexp: ^ffffffff80cc73a7[[:blank:]]*<
tail: : No such file or directory
tail: : No such file or directory
Warning: could not find source line for cam_quirkmatch+0x2a, skipping
Context attempt was:
return_addr is ffffffff80cc73aa
return_addr_sym is cam_quirkmatch
return_addr_offset is 0x2d
Warning: filenames disagreed: addr2line '/usr/src/sys/cam/cam.c', objdump ''
regexp: ^ffffffff80cc7a4b[[:blank:]]*<
tail: : No such file or directory
tail: : No such file or directory
Warning: could not find source line for cam_compat_handle_0x17+0x157, skipping
Context attempt was:
return_addr is ffffffff80cc7a4e
return_addr_sym is cam_compat_handle_0x17
return_addr_offset is 0x15a
Warning: filenames disagreed: addr2line '/usr/src/sys/cam/cam_compat.c', objdump ''
regexp: ^ffffffff80cc7d82[[:blank:]]*<
tail: : No such file or directory
tail: : No such file or directory
Warning: could not find source line for cam_compat_ioctl+0x6b, skipping
Context attempt was:
...
Found 187 allocation sites
Found 187 allocation sites
Warning: output_word value hit zero again.
Warning: output_word value hit zero again.
Looking for definition of declaration At 0x736, tag DW_TAG_structure_type
Failed to find definition of declaration At 0x736, tag DW_TAG_structure_type
Warning: output_word value hit zero again.
Looking for definition of declaration At 0x1d28, tag DW_TAG_structure_type
Failed to find definition of declaration At 0x1d28, tag DW_TAG_structure_type
Warning: output_word value hit zero again.
Looking for definition of declaration At 0x1ed5, tag DW_TAG_structure_type
Failed to find definition of declaration At 0x1ed5, tag DW_TAG_structure_type
Warning: output_word value hit zero again.
...
Found a type named __uniqtype__signed_char but it was defined in a CU named /usr/src/sys/ddb/db_break.c whereas we want one named /usr/src/sys/ddb/db_capture.c
Found a type named __uniqtype__signed_char but it was defined in a CU named /usr/src/sys/ddb/db_break.c whereas we want one named /usr/src/sys/ddb/db_capture.c
Found a type named __uniqtype__signed_char but it was defined in a CU named /usr/src/sys/ddb/db_break.c whereas we want one named /usr/src/sys/ddb/db_capture.c
Success: found a type named __uniqtype__signed_char in a CU named /usr/src/sys/ddb/db_capture.c == /usr/src/sys/ddb/db_capture.c
mkdir -p $(dirname "/usr/lib/allocsites/usr/obj/usr/src/sys/CRUNCHED/kernel.debug.objallocs")
/usr/local/src/liballocs/tools//objdumpallocs "/usr/obj/usr/src/sys/CRUNCHED/kernel.debug" | sed "s|.*|/usr/obj/usr/src/sys/CRUNCHED/kernel.debug\t&|" > "/usr/lib/allocsites/usr/obj/usr/src/sys/CRUNCHED/kernel.debug.objallocs" || (rm -f "/usr/lib/allocsites/usr/obj/usr/src/sys/CRUNCHED/kernel.debug.objallocs"; false)
( /usr/local/src/liballocs/tools//gather-srcallocs.sh "/usr/lib/allocsites/usr/obj/usr/src/sys/CRUNCHED/kernel.debug.objallocs" 2>&1 1>"/usr/lib/allocsites/usr/obj/usr/src/sys/CRUNCHED/kernel.debug.srcallocs" || (rm -f "/usr/lib/allocsites/usr/obj/usr/src/sys/CRUNCHED/kernel.debug.srcallocs"; false) ) | tee "/usr/lib/allocsites/usr/obj/usr/src/sys/CRUNCHED/kernel.debug.srcallocs.rej"
Saw line /usr/obj/usr/src/sys/CRUNCHED/kernel.debug
Slurped args: -wi /usr/obj/usr/src/sys/CRUNCHED/kernel.debug
Guessed file arg: /usr/obj/usr/src/sys/CRUNCHED/kernel.debug
Note: found CU /usr/src/sys/amd64/amd64/locore.S
CU info is: <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
<c> DW_AT_stmt_list : 0x0
<10> DW_AT_low_pc : 0xffffffff80cc70d0
<18> DW_AT_high_pc : 0xffffffff80cc70ff
<20> DW_AT_name : /usr/src/sys/amd64/amd64/locore.S
<42> DW_AT_comp_dir : /usr/obj/usr/src/sys/CRUNCHED
<60> DW_AT_producer : GNU AS 2.25.1
<6e> DW_AT_language : 32769 (MIPS assembler)
language field of CU info is 32769 (MIPS assembler)
comp_dir line of CU info is <42> DW_AT_comp_dir : /usr/obj/usr/src/sys/CRUNCHED
Note: found comp_dir /usr/obj/usr/src/sys/CRUNCHED
Warning: could not gather source-level allocs for unknown language: 32769 (MIPS assembler) (32769,00000000 33 32 37 36 39 09 28 4d 49 50 53 20 61 73 73 65 |32769.(MIPS asse|
00000010 6d 62 6c 65 72 29 |mbler)|
00000016)
Note: found CU /usr/src/sys/cam/cam.c
CU info is: <0><7b>: Abbrev Number: 1 (DW_TAG_compile_unit)
<7c> DW_AT_producer : (indirect string, offset: 0x10a2): GNU C 4.9.4 -mno-omit-leaf-frame-pointer -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float -mtune=generic -march=x86-64 -gdwarf-3 -gdwarf-2 -g -O -std=c99 -fno-common -finline-limit=8000 -fno-omit-frame-pointer -fno-asynchronous-unwind-tables -ffreestanding -fstack-protector --paraminline-unit-growth=100 --param large-function-growth=1000
<80> DW_AT_language : 1 (ANSI C)
<81> DW_AT_name : (indirect string, offset: 0x216e): /usr/src/sys/cam/cam.c
<85> DW_AT_comp_dir : (indirect string, offset: 0x1591): /usr/obj/usr/src/sys/CRUNCHED
<89> DW_AT_low_pc : 0xffffffff80cc70ff
<91> DW_AT_high_pc : 0xffffffff80cc78f4
<99> DW_AT_stmt_list : 0x61
language field of CU info is 1 (ANSI C)
comp_dir line of CU info is <85> DW_AT_comp_dir : (indirect string, offset: 0x1591): /usr/obj/usr/src/sys/CRUNCHED
Note: found comp_dir /usr/obj/usr/src/sys/CRUNCHED
Warning: cu_allocspath is /usr/src/sys/cam/cam.i.allocs
/usr/local/src/liballocs/tools/lang/c/bin/../src/base-types-translation /usr/obj/usr/src/sys/CRUNCHED/kernel.debug
/usr/local/src/liballocs/tools/lang/c/bin/../lib/symname-funcs.sh: line 2: /usr/local/src/liballocs/tools/lang/c/bin/../src/base-types-translation: No such file or directory
sed program is ; s/(__uniqtype__|__ARG[0-9]+_|__PTR_|__REF_|__RR_|__ARR[0-9]+_|__FUN_FROM_|__FUN_TO_|__VA_)(__ARG[0-9]+_|__PTR_|__REF_|__RR_|__ARR[0-9]+_|__FUN_FROM_|__FUN_TO_|__VA_|$)/\1\2/g
Note: found CU /usr/src/sys/cam/cam_compat.c
CU info is: <0><47c1>: Abbrev Number: 1 (DW_TAG_compile_unit)
<47c2> DW_AT_producer : (indirect string, offset: 0x10a2): GNU C 4.9.4 -mno-omit-leaf-frame-pointer -mcmodel=kernel -mno-red-zone -mno-mmx -mno-sse -msoft-float -mtune=generic -march=x86-64 -gdwarf-3 -gdwarf-2 -g -O -std=c99 -fno-common -finline-limit=8000 -fno-omit-frame-pointer -fno-asynchronous-unwind-tables -ffreestanding -fstack-protector --param inline-unit-growth=100 --param large-function-growth=1000
<47c6> DW_AT_language : 1 (ANSI C)
<47c7> DW_AT_name : (indirect string, offset: 0x27e2): /usr/src/sys/cam/cam_compat.c
<47cb> DW_AT_comp_dir : (indirect string, offset: 0x1591): /usr/obj/usr/src/sys/CRUNCHED
<47cf> DW_AT_low_pc : 0xffffffff80cc78f4
<47d7> DW_AT_high_pc : 0xffffffff80cc7db0
<47df> DW_AT_stmt_list : 0x2ee
language field of CU info is 1 (ANSI C)
comp_dir line of CU info is <47cb> DW_AT_comp_dir : (indirect string, offset: 0x1591): /usr/obj/usr/src/sys/CRUNCHED
Note: found comp_dir /usr/obj/usr/src/sys/CRUNCHED
Warning: cu_allocspath is /usr/src/sys/cam/cam_compat.i.allocs
/usr/local/src/liballocs/tools/lang/c/bin/../src/base-types-translation /usr/obj/usr/src/sys/CRUNCHED/kernel.debug
NO MATCH: found /usr/src/sys/x86/x86/mca.c != /usr/src/sys/x86/x86/intr_machdep.c or NOT lexicographic_compare_ge 000171 000311 or NOT lexicographic_compare_lt 000171 000312
warning: skipping objdump meta line, comparing lt next source entry (which has file /usr/src/sys/x86/x86/mca.c, line 000171): /usr/obj/usr/src/sys/CRUNCHED/kernel.debug intr_suspend 0xffffffff8150b439 /usr/src/sys/x86/x86/intr_machdep.c 000311 000312 (indirect) __uniqtype__mca_record
NO MATCH: found /usr/src/sys/x86/x86/mca.c != /usr/src/sys/x86/x86/intr_machdep.c or NOT lexicographic_compare_ge 000171 000330 or NOT lexicographic_compare_lt 000171 000331
warning: skipping objdump meta line, comparing lt next source entry (which has file /usr/src/sys/x86/x86/mca.c, line 000171): /usr/obj/usr/src/sys/CRUNCHED/kernel.debug intr_assign_cpu 0xffffffff8150ad77 /usr/src/sys/x86/x86/intr_machdep.c 000330 000331 (indirect) __uniqtype__mca_record
NO MATCH: found /usr/src/sys/x86/x86/mca.c != /usr/src/sys/x86/x86/intr_machdep.c or NOT lexicographic_compare_ge 000171 000364 or NOT lexicographic_compare_lt 000171 000365
warning: skipping objdump meta line, comparing lt next source entry (which has file /usr/src/sys/x86/x86/mca.c, line 000171): /usr/obj/usr/src/sys/CRUNCHED/kernel.debug intr_register_source 0xffffffff8150b092 /usr/src/sys/x86/x86/intr_machdep.c 000364 000365 (indirect) __uniqtype__mca_record
NO MATCH: found /usr/src/sys/x86/x86/mca.c != /usr/src/sys/x86/x86/intr_machdep.c or NOT lexicographic_compare_ge 000171 000552 or NOT lexicographic_compare_lt 000171 000553
warning: skipping objdump meta line, comparing lt next source entry (which has file /usr/src/sys/x86/x86/mca.c, line 000171): /usr/obj/usr/src/sys/CRUNCHED/kernel.debug intr_shuffle_irqs 0xffffffff8150b6fd /usr/src/sys/x86/x86/intr_machdep.c 000552 000553 (indirect) __uniqtype__mca_record
NO MATCH: found /usr/src/sys/x86/x86/mca.c != /usr/src/sys/x86/x86/intr_machdep.c or NOT lexicographic_compare_ge 000171 000554 or NOT lexicographic_compare_lt 000171 000555
warning: skipping objdump meta line, comparing lt next source entry (which has file /usr/src/sys/x86/x86/mca.c, line 000171): /usr/obj/usr/src/sys/CRUNCHED/kernel.debug intr_shuffle_irqs 0xffffffff8150b713 /usr/src/sys/x86/x86/intr_machdep.c 000554 000555 (indirect) __uniqtype__mca_record
NO MATCH: found /usr/src/sys/x86/x86/mca.c != /usr/src/sys/x86/x86/io_apic.c or NOT lexicographic_compare_ge 000171 000523 or NOT lexicographic_compare_lt 000171 000524
warning: skipping objdump meta line, comparing lt next source entry (which has file /usr/src/sys/x86/x86/mca.c, line 000171): /usr/obj/usr/src/sys/CRUNCHED/kernel.debug ioapic_create 0xffffffff8150ca12 /usr/src/sys/x86/x86/io_apic.c 000523 000524 (indirect) __uniqtype__mca_record
NO MATCH: found /usr/src/sys/x86/x86/mca.c != /usr/src/sys/x86/x86/legacy.c or NOT lexicographic_compare_ge 000171 000185 or NOT lexicographic_compare_lt 000171 000186
warning: skipping objdump meta line, comparing lt next source entry (which has file /usr/src/sys/x86/x86/mca.c, line 000171): /usr/obj/usr/src/sys/CRUNCHED/kernel.debug legacy_add_child 0xffffffff8150d162 /usr/src/sys/x86/x86/legacy.c 000185 000186 (indirect) __uniqtype__mca_record
NO MATCH: found /usr/src/sys/x86/x86/mca.c != /usr/src/sys/x86/x86/legacy.c or NOT lexicographic_compare_ge 000171 000326 or NOT lexicographic_compare_lt 000171 000327
warning: skipping objdump meta line, comparing lt next source entry (which has file /usr/src/sys/x86/x86/mca.c, line 000171): /usr/obj/usr/src/sys/CRUNCHED/kernel.debug cpu_add_child 0xffffffff8150d336 /usr/src/sys/x86/x86/legacy.c 000326 000327 (indirect) __uniqtype__mca_record
NO MATCH: found /usr/src/sys/x86/x86/mca.c != /usr/src/sys/x86/x86/local_apic.c or NOT lexicographic_compare_ge 000171 000854 or NOT lexicographic_compare_lt 000171 000855
warning: skipping objdump meta line, comparing lt next source entry (which has file /usr/src/sys/x86/x86/mca.c, line 000171): /usr/obj/usr/src/sys/CRUNCHED/kernel.debug lapic_handle_timer 0xffffffff8150edca /usr/src/sys/x86/x86/local_apic.c 000854 000855 (indirect) __uniqtype__mca_record
NO MATCH: found /usr/src/sys/x86/x86/mca.c != /usr/src/sys/x86/x86/local_apic.c or NOT lexicographic_compare_ge 000171 001319 or NOT lexicographic_compare_lt 000171 001320
warning: skipping objdump meta line, comparing lt next source entry (which has file /usr/src/sys/x86/x86/mca.c, line 000171): /usr/obj/usr/src/sys/CRUNCHED/kernel.debug apic_init 0xffffffff8150d89c /usr/src/sys/x86/x86/local_apic.c 001319 001320 (indirect) __uniqtype__mca_record
NO MATCH: found /usr/src/sys/x86/x86/mca.c != /usr/src/sys/x86/x86/local_apic.c or NOT lexicographic_compare_ge 000171 001350 or NOT lexicographic_compare_lt 000171 001351
warning: skipping objdump meta line, comparing lt next source entry (which has file /usr/src/sys/x86/x86/mca.c, line 000171): /usr/obj/usr/src/sys/CRUNCHED/kernel.debug apic_init 0xffffffff8150d920 /usr/src/sys/x86/x86/local_apic.c 001350 001351 (indirect) __uniqtype__mca_record
NO MATCH: found /usr/src/sys/x86/x86/mca.c != /usr/src/sys/x86/x86/local_apic.c or NOT lexicographic_compare_ge 000171 001371 or NOT lexicographic_compare_lt 000171 001372
warning: skipping objdump meta line, comparing lt next source entry (which has file /usr/src/sys/x86/x86/mca.c, line 000171): /usr/obj/usr/src/sys/CRUNCHED/kernel.debug apic_setup_local 0xffffffff8150d49e /usr/src/sys/x86/x86/local_apic.c 001371 001372 (indirect) __uniqtype__mca_record
NO MATCH: found /usr/src/sys/x86/x86/mca.c != /usr/src/sys/x86/x86/local_apic.c or NOT lexicographic_compare_ge 000171 001397 or NOT lexicographic_compare_lt 000171 001398
warning: skipping objdump meta line, comparing lt next source entry (which has file /usr/src/sys/x86/x86/mca.c, line 000171): /usr/obj/usr/src/sys/CRUNCHED/kernel.debug apic_setup_io 0xffffffff8150ec94 /usr/src/sys/x86/x86/local_apic.c 001397 001398 (indirect) __uniqtype__mca_record
NO MATCH: found /usr/src/sys/x86/x86/mca.c != /usr/src/sys/x86/x86/mca.c or NOT lexicographic_compare_ge 000171 000210 or NOT lexicographic_compare_lt 000171 000211
test -e "/usr/lib/allocsites/usr/obj/usr/src/sys/CRUNCHED/kernel.debug.allocs"
/usr/local/src/liballocs/tools//allocsites < "/usr/lib/allocsites/usr/obj/usr/src/sys/CRUNCHED/kernel.debug.allocs" > "/usr/lib/allocsites/usr/obj/usr/src/sys/CRUNCHED/kernel.debug-allocsites.c" || (rm -f "/usr/lib/allocsites/usr/obj/usr/src/sys/CRUNCHED/kernel.debug-allocsites.c"; false)
rm /usr/lib/allocsites/usr/obj/usr/src/sys/CRUNCHED/kernel.debug.srcallocs /usr/lib/allocsites/usr/obj/usr/src/sys/CRUNCHED/kernel.debug.allocs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment