MCPcopy Create free account
hub / github.com/nodejs/node / print_handles_data

Function print_handles_data

deps/v8/tools/windbg.js:682–741  ·  view source on GitHub ↗
(print_handles = false)

Source from the content-addressed store, hash-verified

680 Handles
681-----------------------------------------------------------------------------*/
682function print_handles_data(print_handles = false) {
683 if (isolate_address == 0) {
684 print("Please call !set_iso(isolate_address) first.");
685 return;
686 }
687
688 let iso = cast(isolate_address, "v8::internal::Isolate");
689 let hsd = iso.handle_scope_data_;
690 let hsimpl = iso.handle_scope_implementer_;
691
692 // depth level
693 print(`Nested depth level: ${hsd.level}`);
694
695 // count of handles
696 const ptr_size = pointer_size();
697 let blocks = hsimpl.blocks_;
698 const block_size = 1022; // v8::internal::KB - 2
699 const first_block = blocks.data_.address;
700 const last_block = (blocks.size_ == 0)
701 ? first_block
702 : first_block + ptr_size * (blocks.size_ - 1);
703
704 const count = (blocks.size_ == 0)
705 ? 0
706 : (blocks.size_ - 1) * block_size +
707 (hsd.next.address - poi(last_block))/ptr_size;
708 print(`Currently tracking ${count} local handles`);
709
710 // print the handles
711 if (print_handles && count > 0) {
712 for (let block = first_block; block < last_block;
713 block += block_size * ptr_size) {
714 print(`Handles in block at ${hex(block)}`);
715 for (let i = 0; i < block_size; i++) {
716 const location = poi(block + i * ptr_size);
717 print(` ${hex(location)}->${hex(poi(location))}`);
718 }
719 }
720
721 let location = poi(last_block);
722 print(`Handles in block at ${hex(last_block)}`);
723 for (let location = poi(last_block); location < hsd.next.address;
724 location += ptr_size) {
725 print(` ${hex(location)}->${hex(poi(location))}`);
726 }
727 }
728
729 // where will the next handle allocate at?
730 const prefix = "Next handle's location will be";
731 if (hsd.next.address < hsd.limit.address) {
732 print(`${prefix} at ${hex(hsd.next.address)}`);
733 }
734 else if (hsimpl.spare_) {
735 const location = hsimpl.spare_.address;
736 print(`${prefix} from the spare block at ${hex(location)}`);
737 }
738 else {
739 print(`${prefix} from a new block to be allocated`);

Callers

nothing calls this directly

Calls 5

pointer_sizeFunction · 0.85
poiFunction · 0.85
printFunction · 0.70
castFunction · 0.70
hexFunction · 0.70

Tested by

no test coverage detected