1 //===-- HashedNameToDIE.cpp -------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #include "HashedNameToDIE.h" 11 #include "llvm/ADT/StringRef.h" 12 13 void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array, 14 DIEArray &die_offsets) { 15 const size_t count = die_info_array.size(); 16 for (size_t i = 0; i < count; ++i) 17 die_offsets.emplace_back(die_info_array[i].cu_offset, 18 die_info_array[i].offset); 19 } 20 21 void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array, 22 const dw_tag_t tag, 23 DIEArray &die_offsets) { 24 if (tag == 0) { 25 ExtractDIEArray(die_info_array, die_offsets); 26 } else { 27 const size_t count = die_info_array.size(); 28 for (size_t i = 0; i < count; ++i) { 29 const dw_tag_t die_tag = die_info_array[i].tag; 30 bool tag_matches = die_tag == 0 || tag == die_tag; 31 if (!tag_matches) { 32 if (die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type) 33 tag_matches = 34 tag == DW_TAG_structure_type || tag == DW_TAG_class_type; 35 } 36 if (tag_matches) 37 die_offsets.emplace_back(die_info_array[i].cu_offset, 38 die_info_array[i].offset); 39 } 40 } 41 } 42 43 void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array, 44 const dw_tag_t tag, 45 const uint32_t qualified_name_hash, 46 DIEArray &die_offsets) { 47 if (tag == 0) { 48 ExtractDIEArray(die_info_array, die_offsets); 49 } else { 50 const size_t count = die_info_array.size(); 51 for (size_t i = 0; i < count; ++i) { 52 if (qualified_name_hash != die_info_array[i].qualified_name_hash) 53 continue; 54 const dw_tag_t die_tag = die_info_array[i].tag; 55 bool tag_matches = die_tag == 0 || tag == die_tag; 56 if (!tag_matches) { 57 if (die_tag == DW_TAG_class_type || die_tag == DW_TAG_structure_type) 58 tag_matches = 59 tag == DW_TAG_structure_type || tag == DW_TAG_class_type; 60 } 61 if (tag_matches) 62 die_offsets.emplace_back(die_info_array[i].cu_offset, 63 die_info_array[i].offset); 64 } 65 } 66 } 67 68 void DWARFMappedHash::ExtractClassOrStructDIEArray( 69 const DIEInfoArray &die_info_array, 70 bool return_implementation_only_if_available, DIEArray &die_offsets) { 71 const size_t count = die_info_array.size(); 72 for (size_t i = 0; i < count; ++i) { 73 const dw_tag_t die_tag = die_info_array[i].tag; 74 if (die_tag == 0 || die_tag == DW_TAG_class_type || 75 die_tag == DW_TAG_structure_type) { 76 if (die_info_array[i].type_flags & eTypeFlagClassIsImplementation) { 77 if (return_implementation_only_if_available) { 78 // We found the one true definition for this class, so only return 79 // that 80 die_offsets.clear(); 81 die_offsets.emplace_back(die_info_array[i].cu_offset, 82 die_info_array[i].offset); 83 return; 84 } else { 85 // Put the one true definition as the first entry so it matches first 86 die_offsets.emplace(die_offsets.begin(), die_info_array[i].cu_offset, 87 die_info_array[i].offset); 88 } 89 } else { 90 die_offsets.emplace_back(die_info_array[i].cu_offset, 91 die_info_array[i].offset); 92 } 93 } 94 } 95 } 96 97 void DWARFMappedHash::ExtractTypesFromDIEArray( 98 const DIEInfoArray &die_info_array, uint32_t type_flag_mask, 99 uint32_t type_flag_value, DIEArray &die_offsets) { 100 const size_t count = die_info_array.size(); 101 for (size_t i = 0; i < count; ++i) { 102 if ((die_info_array[i].type_flags & type_flag_mask) == type_flag_value) 103 die_offsets.emplace_back(die_info_array[i].cu_offset, 104 die_info_array[i].offset); 105 } 106 } 107 108 const char *DWARFMappedHash::GetAtomTypeName(uint16_t atom) { 109 switch (atom) { 110 case eAtomTypeNULL: 111 return "NULL"; 112 case eAtomTypeDIEOffset: 113 return "die-offset"; 114 case eAtomTypeCUOffset: 115 return "cu-offset"; 116 case eAtomTypeTag: 117 return "die-tag"; 118 case eAtomTypeNameFlags: 119 return "name-flags"; 120 case eAtomTypeTypeFlags: 121 return "type-flags"; 122 case eAtomTypeQualNameHash: 123 return "qualified-name-hash"; 124 } 125 return "<invalid>"; 126 } 127 128 DWARFMappedHash::DIEInfo::DIEInfo() 129 : cu_offset(DW_INVALID_OFFSET), offset(DW_INVALID_OFFSET), tag(0), 130 type_flags(0), qualified_name_hash(0) {} 131 132 DWARFMappedHash::DIEInfo::DIEInfo(dw_offset_t c, dw_offset_t o, dw_tag_t t, 133 uint32_t f, uint32_t h) 134 : cu_offset(c), offset(o), tag(t), type_flags(f), qualified_name_hash(h) {} 135 136 DWARFMappedHash::Prologue::Prologue(dw_offset_t _die_base_offset) 137 : die_base_offset(_die_base_offset), atoms(), atom_mask(0), 138 min_hash_data_byte_size(0), hash_data_has_fixed_byte_size(true) { 139 // Define an array of DIE offsets by first defining an array, and then define 140 // the atom type for the array, in this case we have an array of DIE offsets 141 AppendAtom(eAtomTypeDIEOffset, DW_FORM_data4); 142 } 143 144 void DWARFMappedHash::Prologue::ClearAtoms() { 145 hash_data_has_fixed_byte_size = true; 146 min_hash_data_byte_size = 0; 147 atom_mask = 0; 148 atoms.clear(); 149 } 150 151 bool DWARFMappedHash::Prologue::ContainsAtom(AtomType atom_type) const { 152 return (atom_mask & (1u << atom_type)) != 0; 153 } 154 155 void DWARFMappedHash::Prologue::Clear() { 156 die_base_offset = 0; 157 ClearAtoms(); 158 } 159 160 void DWARFMappedHash::Prologue::AppendAtom(AtomType type, dw_form_t form) { 161 atoms.push_back({type, form}); 162 atom_mask |= 1u << type; 163 switch (form) { 164 case DW_FORM_indirect: 165 case DW_FORM_exprloc: 166 case DW_FORM_flag_present: 167 case DW_FORM_ref_sig8: 168 llvm_unreachable("Unhandled atom form"); 169 170 case DW_FORM_string: 171 case DW_FORM_block: 172 case DW_FORM_block1: 173 case DW_FORM_sdata: 174 case DW_FORM_udata: 175 case DW_FORM_ref_udata: 176 case DW_FORM_GNU_addr_index: 177 case DW_FORM_GNU_str_index: 178 hash_data_has_fixed_byte_size = false; 179 LLVM_FALLTHROUGH; 180 case DW_FORM_flag: 181 case DW_FORM_data1: 182 case DW_FORM_ref1: 183 case DW_FORM_sec_offset: 184 min_hash_data_byte_size += 1; 185 break; 186 187 case DW_FORM_block2: 188 hash_data_has_fixed_byte_size = false; 189 LLVM_FALLTHROUGH; 190 case DW_FORM_data2: 191 case DW_FORM_ref2: 192 min_hash_data_byte_size += 2; 193 break; 194 195 case DW_FORM_block4: 196 hash_data_has_fixed_byte_size = false; 197 LLVM_FALLTHROUGH; 198 case DW_FORM_data4: 199 case DW_FORM_ref4: 200 case DW_FORM_addr: 201 case DW_FORM_ref_addr: 202 case DW_FORM_strp: 203 min_hash_data_byte_size += 4; 204 break; 205 206 case DW_FORM_data8: 207 case DW_FORM_ref8: 208 min_hash_data_byte_size += 8; 209 break; 210 } 211 } 212 213 lldb::offset_t 214 DWARFMappedHash::Prologue::Read(const lldb_private::DataExtractor &data, 215 lldb::offset_t offset) { 216 ClearAtoms(); 217 218 die_base_offset = data.GetU32(&offset); 219 220 const uint32_t atom_count = data.GetU32(&offset); 221 if (atom_count == 0x00060003u) { 222 // Old format, deal with contents of old pre-release format 223 while (data.GetU32(&offset)) 224 /* do nothing */; 225 226 // Hardcode to the only known value for now. 227 AppendAtom(eAtomTypeDIEOffset, DW_FORM_data4); 228 } else { 229 for (uint32_t i = 0; i < atom_count; ++i) { 230 AtomType type = (AtomType)data.GetU16(&offset); 231 dw_form_t form = (dw_form_t)data.GetU16(&offset); 232 AppendAtom(type, form); 233 } 234 } 235 return offset; 236 } 237 238 size_t DWARFMappedHash::Prologue::GetByteSize() const { 239 // Add an extra count to the atoms size for the zero termination Atom that 240 // gets written to disk 241 return sizeof(die_base_offset) + sizeof(uint32_t) + 242 atoms.size() * sizeof(Atom); 243 } 244 245 size_t DWARFMappedHash::Prologue::GetMinimumHashDataByteSize() const { 246 return min_hash_data_byte_size; 247 } 248 249 bool DWARFMappedHash::Prologue::HashDataHasFixedByteSize() const { 250 return hash_data_has_fixed_byte_size; 251 } 252 253 size_t DWARFMappedHash::Header::GetByteSize(const HeaderData &header_data) { 254 return header_data.GetByteSize(); 255 } 256 257 lldb::offset_t DWARFMappedHash::Header::Read(lldb_private::DataExtractor &data, 258 lldb::offset_t offset) { 259 offset = MappedHash::Header<Prologue>::Read(data, offset); 260 if (offset != UINT32_MAX) { 261 offset = header_data.Read(data, offset); 262 } 263 return offset; 264 } 265 266 bool DWARFMappedHash::Header::Read(const lldb_private::DWARFDataExtractor &data, 267 lldb::offset_t *offset_ptr, 268 DIEInfo &hash_data) const { 269 const size_t num_atoms = header_data.atoms.size(); 270 if (num_atoms == 0) 271 return false; 272 273 for (size_t i = 0; i < num_atoms; ++i) { 274 DWARFFormValue form_value(NULL, header_data.atoms[i].form); 275 276 if (!form_value.ExtractValue(data, offset_ptr)) 277 return false; 278 279 switch (header_data.atoms[i].type) { 280 case eAtomTypeDIEOffset: // DIE offset, check form for encoding 281 hash_data.offset = 282 (dw_offset_t)form_value.Reference(header_data.die_base_offset); 283 break; 284 285 case eAtomTypeTag: // DW_TAG value for the DIE 286 hash_data.tag = (dw_tag_t)form_value.Unsigned(); 287 break; 288 289 case eAtomTypeTypeFlags: // Flags from enum TypeFlags 290 hash_data.type_flags = (uint32_t)form_value.Unsigned(); 291 break; 292 293 case eAtomTypeQualNameHash: // Flags from enum TypeFlags 294 hash_data.qualified_name_hash = form_value.Unsigned(); 295 break; 296 297 default: 298 // We can always skip atoms we don't know about 299 break; 300 } 301 } 302 return true; 303 } 304 305 void DWARFMappedHash::Header::Dump(lldb_private::Stream &strm, 306 const DIEInfo &hash_data) const { 307 const size_t num_atoms = header_data.atoms.size(); 308 for (size_t i = 0; i < num_atoms; ++i) { 309 if (i > 0) 310 strm.PutCString(", "); 311 312 DWARFFormValue form_value(NULL, header_data.atoms[i].form); 313 switch (header_data.atoms[i].type) { 314 case eAtomTypeDIEOffset: // DIE offset, check form for encoding 315 strm.Printf("{0x%8.8x}", hash_data.offset); 316 break; 317 318 case eAtomTypeTag: // DW_TAG value for the DIE 319 { 320 const char *tag_cstr = lldb_private::DW_TAG_value_to_name(hash_data.tag); 321 if (tag_cstr) 322 strm.PutCString(tag_cstr); 323 else 324 strm.Printf("DW_TAG_(0x%4.4x)", hash_data.tag); 325 } break; 326 327 case eAtomTypeTypeFlags: // Flags from enum TypeFlags 328 strm.Printf("0x%2.2x", hash_data.type_flags); 329 if (hash_data.type_flags) { 330 strm.PutCString(" ("); 331 if (hash_data.type_flags & eTypeFlagClassIsImplementation) 332 strm.PutCString(" implementation"); 333 strm.PutCString(" )"); 334 } 335 break; 336 337 case eAtomTypeQualNameHash: // Flags from enum TypeFlags 338 strm.Printf("0x%8.8x", hash_data.qualified_name_hash); 339 break; 340 341 default: 342 strm.Printf("AtomType(0x%x)", header_data.atoms[i].type); 343 break; 344 } 345 } 346 } 347 348 DWARFMappedHash::MemoryTable::MemoryTable( 349 lldb_private::DWARFDataExtractor &table_data, 350 const lldb_private::DWARFDataExtractor &string_table, const char *name) 351 : MappedHash::MemoryTable<uint32_t, Header, DIEInfoArray>(table_data), 352 m_data(table_data), m_string_table(string_table), m_name(name) {} 353 354 const char * 355 DWARFMappedHash::MemoryTable::GetStringForKeyType(KeyType key) const { 356 // The key in the DWARF table is the .debug_str offset for the string 357 return m_string_table.PeekCStr(key); 358 } 359 360 bool DWARFMappedHash::MemoryTable::ReadHashData(uint32_t hash_data_offset, 361 HashData &hash_data) const { 362 lldb::offset_t offset = hash_data_offset; 363 offset += 4; // Skip string table offset that contains offset of hash name in 364 // .debug_str 365 const uint32_t count = m_data.GetU32(&offset); 366 if (count > 0) { 367 hash_data.resize(count); 368 for (uint32_t i = 0; i < count; ++i) { 369 if (!m_header.Read(m_data, &offset, hash_data[i])) 370 return false; 371 } 372 } else 373 hash_data.clear(); 374 return true; 375 } 376 377 DWARFMappedHash::MemoryTable::Result 378 DWARFMappedHash::MemoryTable::GetHashDataForName( 379 llvm::StringRef name, lldb::offset_t *hash_data_offset_ptr, 380 Pair &pair) const { 381 pair.key = m_data.GetU32(hash_data_offset_ptr); 382 pair.value.clear(); 383 384 // If the key is zero, this terminates our chain of HashData objects for this 385 // hash value. 386 if (pair.key == 0) 387 return eResultEndOfHashData; 388 389 // There definitely should be a string for this string offset, if there 390 // isn't, there is something wrong, return and error 391 const char *strp_cstr = m_string_table.PeekCStr(pair.key); 392 if (strp_cstr == NULL) { 393 *hash_data_offset_ptr = UINT32_MAX; 394 return eResultError; 395 } 396 397 const uint32_t count = m_data.GetU32(hash_data_offset_ptr); 398 const size_t min_total_hash_data_size = 399 count * m_header.header_data.GetMinimumHashDataByteSize(); 400 if (count > 0 && 401 m_data.ValidOffsetForDataOfSize(*hash_data_offset_ptr, 402 min_total_hash_data_size)) { 403 // We have at least one HashData entry, and we have enough data to parse at 404 // least "count" HashData entries. 405 406 // First make sure the entire C string matches... 407 const bool match = name == strp_cstr; 408 409 if (!match && m_header.header_data.HashDataHasFixedByteSize()) { 410 // If the string doesn't match and we have fixed size data, we can just 411 // add the total byte size of all HashData objects to the hash data 412 // offset and be done... 413 *hash_data_offset_ptr += min_total_hash_data_size; 414 } else { 415 // If the string does match, or we don't have fixed size data then we 416 // need to read the hash data as a stream. If the string matches we also 417 // append all HashData objects to the value array. 418 for (uint32_t i = 0; i < count; ++i) { 419 DIEInfo die_info; 420 if (m_header.Read(m_data, hash_data_offset_ptr, die_info)) { 421 // Only happened if the HashData of the string matched... 422 if (match) 423 pair.value.push_back(die_info); 424 } else { 425 // Something went wrong while reading the data 426 *hash_data_offset_ptr = UINT32_MAX; 427 return eResultError; 428 } 429 } 430 } 431 // Return the correct response depending on if the string matched or not... 432 if (match) 433 return eResultKeyMatch; // The key (cstring) matches and we have lookup 434 // results! 435 else 436 return eResultKeyMismatch; // The key doesn't match, this function will 437 // get called 438 // again for the next key/value or the key terminator which in our case is 439 // a zero .debug_str offset. 440 } else { 441 *hash_data_offset_ptr = UINT32_MAX; 442 return eResultError; 443 } 444 } 445 446 DWARFMappedHash::MemoryTable::Result 447 DWARFMappedHash::MemoryTable::AppendHashDataForRegularExpression( 448 const lldb_private::RegularExpression ®ex, 449 lldb::offset_t *hash_data_offset_ptr, Pair &pair) const { 450 pair.key = m_data.GetU32(hash_data_offset_ptr); 451 // If the key is zero, this terminates our chain of HashData objects for this 452 // hash value. 453 if (pair.key == 0) 454 return eResultEndOfHashData; 455 456 // There definitely should be a string for this string offset, if there 457 // isn't, there is something wrong, return and error 458 const char *strp_cstr = m_string_table.PeekCStr(pair.key); 459 if (strp_cstr == NULL) 460 return eResultError; 461 462 const uint32_t count = m_data.GetU32(hash_data_offset_ptr); 463 const size_t min_total_hash_data_size = 464 count * m_header.header_data.GetMinimumHashDataByteSize(); 465 if (count > 0 && 466 m_data.ValidOffsetForDataOfSize(*hash_data_offset_ptr, 467 min_total_hash_data_size)) { 468 const bool match = regex.Execute(llvm::StringRef(strp_cstr)); 469 470 if (!match && m_header.header_data.HashDataHasFixedByteSize()) { 471 // If the regex doesn't match and we have fixed size data, we can just 472 // add the total byte size of all HashData objects to the hash data 473 // offset and be done... 474 *hash_data_offset_ptr += min_total_hash_data_size; 475 } else { 476 // If the string does match, or we don't have fixed size data then we 477 // need to read the hash data as a stream. If the string matches we also 478 // append all HashData objects to the value array. 479 for (uint32_t i = 0; i < count; ++i) { 480 DIEInfo die_info; 481 if (m_header.Read(m_data, hash_data_offset_ptr, die_info)) { 482 // Only happened if the HashData of the string matched... 483 if (match) 484 pair.value.push_back(die_info); 485 } else { 486 // Something went wrong while reading the data 487 *hash_data_offset_ptr = UINT32_MAX; 488 return eResultError; 489 } 490 } 491 } 492 // Return the correct response depending on if the string matched or not... 493 if (match) 494 return eResultKeyMatch; // The key (cstring) matches and we have lookup 495 // results! 496 else 497 return eResultKeyMismatch; // The key doesn't match, this function will 498 // get called 499 // again for the next key/value or the key terminator which in our case is 500 // a zero .debug_str offset. 501 } else { 502 *hash_data_offset_ptr = UINT32_MAX; 503 return eResultError; 504 } 505 } 506 507 size_t DWARFMappedHash::MemoryTable::AppendAllDIEsThatMatchingRegex( 508 const lldb_private::RegularExpression ®ex, 509 DIEInfoArray &die_info_array) const { 510 const uint32_t hash_count = m_header.hashes_count; 511 Pair pair; 512 for (uint32_t offset_idx = 0; offset_idx < hash_count; ++offset_idx) { 513 lldb::offset_t hash_data_offset = GetHashDataOffset(offset_idx); 514 while (hash_data_offset != UINT32_MAX) { 515 const lldb::offset_t prev_hash_data_offset = hash_data_offset; 516 Result hash_result = 517 AppendHashDataForRegularExpression(regex, &hash_data_offset, pair); 518 if (prev_hash_data_offset == hash_data_offset) 519 break; 520 521 // Check the result of getting our hash data 522 switch (hash_result) { 523 case eResultKeyMatch: 524 case eResultKeyMismatch: 525 // Whether we matches or not, it doesn't matter, we keep looking. 526 break; 527 528 case eResultEndOfHashData: 529 case eResultError: 530 hash_data_offset = UINT32_MAX; 531 break; 532 } 533 } 534 } 535 die_info_array.swap(pair.value); 536 return die_info_array.size(); 537 } 538 539 size_t DWARFMappedHash::MemoryTable::AppendAllDIEsInRange( 540 const uint32_t die_offset_start, const uint32_t die_offset_end, 541 DIEInfoArray &die_info_array) const { 542 const uint32_t hash_count = m_header.hashes_count; 543 for (uint32_t offset_idx = 0; offset_idx < hash_count; ++offset_idx) { 544 bool done = false; 545 lldb::offset_t hash_data_offset = GetHashDataOffset(offset_idx); 546 while (!done && hash_data_offset != UINT32_MAX) { 547 KeyType key = m_data.GetU32(&hash_data_offset); 548 // If the key is zero, this terminates our chain of HashData objects for 549 // this hash value. 550 if (key == 0) 551 break; 552 553 const uint32_t count = m_data.GetU32(&hash_data_offset); 554 for (uint32_t i = 0; i < count; ++i) { 555 DIEInfo die_info; 556 if (m_header.Read(m_data, &hash_data_offset, die_info)) { 557 if (die_info.offset == 0) 558 done = true; 559 if (die_offset_start <= die_info.offset && 560 die_info.offset < die_offset_end) 561 die_info_array.push_back(die_info); 562 } 563 } 564 } 565 } 566 return die_info_array.size(); 567 } 568 569 size_t DWARFMappedHash::MemoryTable::FindByName(llvm::StringRef name, 570 DIEArray &die_offsets) { 571 if (name.empty()) 572 return 0; 573 574 DIEInfoArray die_info_array; 575 if (FindByName(name, die_info_array)) 576 DWARFMappedHash::ExtractDIEArray(die_info_array, die_offsets); 577 return die_info_array.size(); 578 } 579 580 size_t DWARFMappedHash::MemoryTable::FindByNameAndTag(llvm::StringRef name, 581 const dw_tag_t tag, 582 DIEArray &die_offsets) { 583 DIEInfoArray die_info_array; 584 if (FindByName(name, die_info_array)) 585 DWARFMappedHash::ExtractDIEArray(die_info_array, tag, die_offsets); 586 return die_info_array.size(); 587 } 588 589 size_t DWARFMappedHash::MemoryTable::FindByNameAndTagAndQualifiedNameHash( 590 llvm::StringRef name, const dw_tag_t tag, 591 const uint32_t qualified_name_hash, DIEArray &die_offsets) { 592 DIEInfoArray die_info_array; 593 if (FindByName(name, die_info_array)) 594 DWARFMappedHash::ExtractDIEArray(die_info_array, tag, qualified_name_hash, 595 die_offsets); 596 return die_info_array.size(); 597 } 598 599 size_t DWARFMappedHash::MemoryTable::FindCompleteObjCClassByName( 600 llvm::StringRef name, DIEArray &die_offsets, bool must_be_implementation) { 601 DIEInfoArray die_info_array; 602 if (FindByName(name, die_info_array)) { 603 if (must_be_implementation && 604 GetHeader().header_data.ContainsAtom(eAtomTypeTypeFlags)) { 605 // If we have two atoms, then we have the DIE offset and the type flags 606 // so we can find the objective C class efficiently. 607 DWARFMappedHash::ExtractTypesFromDIEArray(die_info_array, UINT32_MAX, 608 eTypeFlagClassIsImplementation, 609 die_offsets); 610 } else { 611 // We don't only want the one true definition, so try and see what we can 612 // find, and only return class or struct DIEs. If we do have the full 613 // implementation, then return it alone, else return all possible 614 // matches. 615 const bool return_implementation_only_if_available = true; 616 DWARFMappedHash::ExtractClassOrStructDIEArray( 617 die_info_array, return_implementation_only_if_available, die_offsets); 618 } 619 } 620 return die_offsets.size(); 621 } 622 623 size_t DWARFMappedHash::MemoryTable::FindByName(llvm::StringRef name, 624 DIEInfoArray &die_info_array) { 625 if (name.empty()) 626 return 0; 627 628 Pair kv_pair; 629 size_t old_size = die_info_array.size(); 630 if (Find(name, kv_pair)) { 631 die_info_array.swap(kv_pair.value); 632 return die_info_array.size() - old_size; 633 } 634 return 0; 635 } 636