1076 lines · python
1#!/usr/bin/env python2# ===-- x86_64_qemu_target_definition.py -----------------------------*- C++ -*-===//3#4# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5# See https://llvm.org/LICENSE.txt for license information.6# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7#8# ===----------------------------------------------------------------------===//9 10# ----------------------------------------------------------------------11# DESCRIPTION12#13# This file can be used with the following setting:14# plugin.process.gdb-remote.target-definition-file15# This setting should be used when you are trying to connect to a16# remote GDB server that doesn't support any of the register discovery17# packets that LLDB normally uses.18#19# Why is this necessary? LLDB doesn't require a new build of LLDB that20# targets each new architecture you will debug with. Instead, all21# architectures are supported and LLDB relies on extra GDB server22# packets to discover the target we are connecting to so that is can23# show the right registers for each target. This allows the remote stub24# to change and add new registers without requiring a new LLDB build25# just so we can see new registers.26#27# This file implements the x86_64 registers for the user mode qemu on linux.28# The only difference with the Linux file is the absense of orig_rax register.29#30# USAGE31#32# (lldb) settings set plugin.process.gdb-remote.target-definition-file /path/to/x86_64_qemu_target_definition.py33# (lldb) gdb-remote other.baz.com:123434#35# The target definition file will get used if and only if the36# qRegisterInfo packets are not supported when connecting to a remote37# GDB stub.38# ----------------------------------------------------------------------39from lldb import *40 41# Compiler and DWARF register numbers42name_to_gcc_dwarf_regnum = {43 "rax": 0,44 "rdx": 1,45 "rcx": 2,46 "rbx": 3,47 "rsi": 4,48 "rdi": 5,49 "rbp": 6,50 "rsp": 7,51 "r8": 8,52 "r9": 9,53 "r10": 10,54 "r11": 11,55 "r12": 12,56 "r13": 13,57 "r14": 14,58 "r15": 15,59 "rip": 16,60 "xmm0": 17,61 "xmm1": 18,62 "xmm2": 19,63 "xmm3": 20,64 "xmm4": 21,65 "xmm5": 22,66 "xmm6": 23,67 "xmm7": 24,68 "xmm8": 25,69 "xmm9": 26,70 "xmm10": 27,71 "xmm11": 28,72 "xmm12": 29,73 "xmm13": 30,74 "xmm14": 31,75 "xmm15": 32,76 "stmm0": 33,77 "stmm1": 34,78 "stmm2": 35,79 "stmm3": 36,80 "stmm4": 37,81 "stmm5": 38,82 "stmm6": 39,83 "stmm7": 30,84 "ymm0": 41,85 "ymm1": 42,86 "ymm2": 43,87 "ymm3": 44,88 "ymm4": 45,89 "ymm5": 46,90 "ymm6": 47,91 "ymm7": 48,92 "ymm8": 49,93 "ymm9": 40,94 "ymm10": 41,95 "ymm11": 42,96 "ymm12": 43,97 "ymm13": 44,98 "ymm14": 45,99 "ymm15": 46,100}101 102name_to_gdb_regnum = {103 "rax": 0,104 "rbx": 1,105 "rcx": 2,106 "rdx": 3,107 "rsi": 4,108 "rdi": 5,109 "rbp": 6,110 "rsp": 7,111 "r8": 8,112 "r9": 9,113 "r10": 10,114 "r11": 11,115 "r12": 12,116 "r13": 13,117 "r14": 14,118 "r15": 15,119 "rip": 16,120 "rflags": 17,121 "cs": 18,122 "ss": 19,123 "ds": 20,124 "es": 21,125 "fs": 22,126 "gs": 23,127 "stmm0": 24,128 "stmm1": 25,129 "stmm2": 26,130 "stmm3": 27,131 "stmm4": 28,132 "stmm5": 29,133 "stmm6": 30,134 "stmm7": 31,135 "fctrl": 32,136 "fstat": 33,137 "ftag": 34,138 "fiseg": 35,139 "fioff": 36,140 "foseg": 37,141 "fooff": 38,142 "fop": 39,143 "xmm0": 40,144 "xmm1": 41,145 "xmm2": 42,146 "xmm3": 43,147 "xmm4": 44,148 "xmm5": 45,149 "xmm6": 46,150 "xmm7": 47,151 "xmm8": 48,152 "xmm9": 49,153 "xmm10": 50,154 "xmm11": 51,155 "xmm12": 52,156 "xmm13": 53,157 "xmm14": 54,158 "xmm15": 55,159 "mxcsr": 56,160 "ymm0": 57,161 "ymm1": 58,162 "ymm2": 59,163 "ymm3": 60,164 "ymm4": 61,165 "ymm5": 62,166 "ymm6": 63,167 "ymm7": 64,168 "ymm8": 65,169 "ymm9": 66,170 "ymm10": 67,171 "ymm11": 68,172 "ymm12": 69,173 "ymm13": 70,174 "ymm14": 71,175 "ymm15": 72,176}177 178name_to_generic_regnum = {179 "rip": LLDB_REGNUM_GENERIC_PC,180 "rsp": LLDB_REGNUM_GENERIC_SP,181 "rbp": LLDB_REGNUM_GENERIC_FP,182 "rdi": LLDB_REGNUM_GENERIC_ARG1,183 "rsi": LLDB_REGNUM_GENERIC_ARG2,184 "rdx": LLDB_REGNUM_GENERIC_ARG3,185 "rcx": LLDB_REGNUM_GENERIC_ARG4,186 "r8": LLDB_REGNUM_GENERIC_ARG5,187 "r9": LLDB_REGNUM_GENERIC_ARG6,188}189 190 191def get_reg_num(reg_num_dict, reg_name):192 if reg_name in reg_num_dict:193 return reg_num_dict[reg_name]194 return LLDB_INVALID_REGNUM195 196 197x86_64_register_infos = [198 {199 "name": "rax",200 "set": 0,201 "bitsize": 64,202 "encoding": eEncodingUint,203 "format": eFormatAddressInfo,204 },205 {206 "name": "rbx",207 "set": 0,208 "bitsize": 64,209 "encoding": eEncodingUint,210 "format": eFormatAddressInfo,211 },212 {213 "name": "rcx",214 "set": 0,215 "bitsize": 64,216 "encoding": eEncodingUint,217 "format": eFormatAddressInfo,218 "alt-name": "arg4",219 },220 {221 "name": "rdx",222 "set": 0,223 "bitsize": 64,224 "encoding": eEncodingUint,225 "format": eFormatAddressInfo,226 "alt-name": "arg3",227 },228 {229 "name": "rsi",230 "set": 0,231 "bitsize": 64,232 "encoding": eEncodingUint,233 "format": eFormatAddressInfo,234 "alt-name": "arg2",235 },236 {237 "name": "rdi",238 "set": 0,239 "bitsize": 64,240 "encoding": eEncodingUint,241 "format": eFormatAddressInfo,242 "alt-name": "arg1",243 },244 {245 "name": "rbp",246 "set": 0,247 "bitsize": 64,248 "encoding": eEncodingUint,249 "format": eFormatAddressInfo,250 "alt-name": "fp",251 },252 {253 "name": "rsp",254 "set": 0,255 "bitsize": 64,256 "encoding": eEncodingUint,257 "format": eFormatAddressInfo,258 "alt-name": "sp",259 },260 {261 "name": "r8",262 "set": 0,263 "bitsize": 64,264 "encoding": eEncodingUint,265 "format": eFormatAddressInfo,266 "alt-name": "arg5",267 },268 {269 "name": "r9",270 "set": 0,271 "bitsize": 64,272 "encoding": eEncodingUint,273 "format": eFormatAddressInfo,274 "alt-name": "arg6",275 },276 {277 "name": "r10",278 "set": 0,279 "bitsize": 64,280 "encoding": eEncodingUint,281 "format": eFormatAddressInfo,282 },283 {284 "name": "r11",285 "set": 0,286 "bitsize": 64,287 "encoding": eEncodingUint,288 "format": eFormatAddressInfo,289 },290 {291 "name": "r12",292 "set": 0,293 "bitsize": 64,294 "encoding": eEncodingUint,295 "format": eFormatAddressInfo,296 },297 {298 "name": "r13",299 "set": 0,300 "bitsize": 64,301 "encoding": eEncodingUint,302 "format": eFormatAddressInfo,303 },304 {305 "name": "r14",306 "set": 0,307 "bitsize": 64,308 "encoding": eEncodingUint,309 "format": eFormatAddressInfo,310 },311 {312 "name": "r15",313 "set": 0,314 "bitsize": 64,315 "encoding": eEncodingUint,316 "format": eFormatAddressInfo,317 },318 {319 "name": "rip",320 "set": 0,321 "bitsize": 64,322 "encoding": eEncodingUint,323 "format": eFormatAddressInfo,324 "alt-name": "pc",325 },326 {327 "name": "rflags",328 "set": 0,329 "bitsize": 32,330 "encoding": eEncodingUint,331 "format": eFormatHex,332 },333 {334 "name": "cs",335 "set": 0,336 "bitsize": 32,337 "encoding": eEncodingUint,338 "format": eFormatHex,339 },340 {341 "name": "ss",342 "set": 0,343 "bitsize": 32,344 "encoding": eEncodingUint,345 "format": eFormatHex,346 },347 {348 "name": "ds",349 "set": 0,350 "bitsize": 32,351 "encoding": eEncodingUint,352 "format": eFormatHex,353 },354 {355 "name": "es",356 "set": 0,357 "bitsize": 32,358 "encoding": eEncodingUint,359 "format": eFormatHex,360 },361 {362 "name": "fs",363 "set": 0,364 "bitsize": 32,365 "encoding": eEncodingUint,366 "format": eFormatHex,367 },368 {369 "name": "gs",370 "set": 0,371 "bitsize": 32,372 "encoding": eEncodingUint,373 "format": eFormatHex,374 },375 {376 "name": "stmm0",377 "set": 1,378 "bitsize": 80,379 "encoding": eEncodingVector,380 "format": eFormatVectorOfUInt8,381 },382 {383 "name": "stmm1",384 "set": 1,385 "bitsize": 80,386 "encoding": eEncodingVector,387 "format": eFormatVectorOfUInt8,388 },389 {390 "name": "stmm2",391 "set": 1,392 "bitsize": 80,393 "encoding": eEncodingVector,394 "format": eFormatVectorOfUInt8,395 },396 {397 "name": "stmm3",398 "set": 1,399 "bitsize": 80,400 "encoding": eEncodingVector,401 "format": eFormatVectorOfUInt8,402 },403 {404 "name": "stmm4",405 "set": 1,406 "bitsize": 80,407 "encoding": eEncodingVector,408 "format": eFormatVectorOfUInt8,409 },410 {411 "name": "stmm5",412 "set": 1,413 "bitsize": 80,414 "encoding": eEncodingVector,415 "format": eFormatVectorOfUInt8,416 },417 {418 "name": "stmm6",419 "set": 1,420 "bitsize": 80,421 "encoding": eEncodingVector,422 "format": eFormatVectorOfUInt8,423 },424 {425 "name": "stmm7",426 "set": 1,427 "bitsize": 80,428 "encoding": eEncodingVector,429 "format": eFormatVectorOfUInt8,430 },431 {432 "name": "fctrl",433 "set": 1,434 "bitsize": 32,435 "encoding": eEncodingUint,436 "format": eFormatHex,437 },438 {439 "name": "fstat",440 "set": 1,441 "bitsize": 32,442 "encoding": eEncodingUint,443 "format": eFormatHex,444 },445 {446 "name": "ftag",447 "set": 1,448 "bitsize": 32,449 "encoding": eEncodingUint,450 "format": eFormatHex,451 },452 {453 "name": "fiseg",454 "set": 1,455 "bitsize": 32,456 "encoding": eEncodingUint,457 "format": eFormatHex,458 },459 {460 "name": "fioff",461 "set": 1,462 "bitsize": 32,463 "encoding": eEncodingUint,464 "format": eFormatHex,465 },466 {467 "name": "foseg",468 "set": 1,469 "bitsize": 32,470 "encoding": eEncodingUint,471 "format": eFormatHex,472 },473 {474 "name": "fooff",475 "set": 1,476 "bitsize": 32,477 "encoding": eEncodingUint,478 "format": eFormatHex,479 },480 {481 "name": "fop",482 "set": 1,483 "bitsize": 32,484 "encoding": eEncodingUint,485 "format": eFormatHex,486 },487 {488 "name": "xmm0",489 "set": 1,490 "bitsize": 128,491 "encoding": eEncodingVector,492 "format": eFormatVectorOfUInt8,493 },494 {495 "name": "xmm1",496 "set": 1,497 "bitsize": 128,498 "encoding": eEncodingVector,499 "format": eFormatVectorOfUInt8,500 },501 {502 "name": "xmm2",503 "set": 1,504 "bitsize": 128,505 "encoding": eEncodingVector,506 "format": eFormatVectorOfUInt8,507 },508 {509 "name": "xmm3",510 "set": 1,511 "bitsize": 128,512 "encoding": eEncodingVector,513 "format": eFormatVectorOfUInt8,514 },515 {516 "name": "xmm4",517 "set": 1,518 "bitsize": 128,519 "encoding": eEncodingVector,520 "format": eFormatVectorOfUInt8,521 },522 {523 "name": "xmm5",524 "set": 1,525 "bitsize": 128,526 "encoding": eEncodingVector,527 "format": eFormatVectorOfUInt8,528 },529 {530 "name": "xmm6",531 "set": 1,532 "bitsize": 128,533 "encoding": eEncodingVector,534 "format": eFormatVectorOfUInt8,535 },536 {537 "name": "xmm7",538 "set": 1,539 "bitsize": 128,540 "encoding": eEncodingVector,541 "format": eFormatVectorOfUInt8,542 },543 {544 "name": "xmm8",545 "set": 1,546 "bitsize": 128,547 "encoding": eEncodingVector,548 "format": eFormatVectorOfUInt8,549 },550 {551 "name": "xmm9",552 "set": 1,553 "bitsize": 128,554 "encoding": eEncodingVector,555 "format": eFormatVectorOfUInt8,556 },557 {558 "name": "xmm10",559 "set": 1,560 "bitsize": 128,561 "encoding": eEncodingVector,562 "format": eFormatVectorOfUInt8,563 },564 {565 "name": "xmm11",566 "set": 1,567 "bitsize": 128,568 "encoding": eEncodingVector,569 "format": eFormatVectorOfUInt8,570 },571 {572 "name": "xmm12",573 "set": 1,574 "bitsize": 128,575 "encoding": eEncodingVector,576 "format": eFormatVectorOfUInt8,577 },578 {579 "name": "xmm13",580 "set": 1,581 "bitsize": 128,582 "encoding": eEncodingVector,583 "format": eFormatVectorOfUInt8,584 },585 {586 "name": "xmm14",587 "set": 1,588 "bitsize": 128,589 "encoding": eEncodingVector,590 "format": eFormatVectorOfUInt8,591 },592 {593 "name": "xmm15",594 "set": 1,595 "bitsize": 128,596 "encoding": eEncodingVector,597 "format": eFormatVectorOfUInt8,598 },599 {600 "name": "mxcsr",601 "set": 1,602 "bitsize": 32,603 "encoding": eEncodingUint,604 "format": eFormatHex,605 },606 # Registers that are contained in or composed of one of more other607 # registers608 {609 "name": "eax",610 "set": 0,611 "bitsize": 32,612 "encoding": eEncodingUint,613 "format": eFormatHex,614 "slice": "rax[31:0]",615 },616 {617 "name": "ebx",618 "set": 0,619 "bitsize": 32,620 "encoding": eEncodingUint,621 "format": eFormatHex,622 "slice": "rbx[31:0]",623 },624 {625 "name": "ecx",626 "set": 0,627 "bitsize": 32,628 "encoding": eEncodingUint,629 "format": eFormatHex,630 "slice": "rcx[31:0]",631 },632 {633 "name": "edx",634 "set": 0,635 "bitsize": 32,636 "encoding": eEncodingUint,637 "format": eFormatHex,638 "slice": "rdx[31:0]",639 },640 {641 "name": "edi",642 "set": 0,643 "bitsize": 32,644 "encoding": eEncodingUint,645 "format": eFormatHex,646 "slice": "rdi[31:0]",647 },648 {649 "name": "esi",650 "set": 0,651 "bitsize": 32,652 "encoding": eEncodingUint,653 "format": eFormatHex,654 "slice": "rsi[31:0]",655 },656 {657 "name": "ebp",658 "set": 0,659 "bitsize": 32,660 "encoding": eEncodingUint,661 "format": eFormatHex,662 "slice": "rbp[31:0]",663 },664 {665 "name": "esp",666 "set": 0,667 "bitsize": 32,668 "encoding": eEncodingUint,669 "format": eFormatHex,670 "slice": "rsp[31:0]",671 },672 {673 "name": "r8d",674 "set": 0,675 "bitsize": 32,676 "encoding": eEncodingUint,677 "format": eFormatHex,678 "slice": "r8[31:0]",679 },680 {681 "name": "r9d",682 "set": 0,683 "bitsize": 32,684 "encoding": eEncodingUint,685 "format": eFormatHex,686 "slice": "r9[31:0]",687 },688 {689 "name": "r10d",690 "set": 0,691 "bitsize": 32,692 "encoding": eEncodingUint,693 "format": eFormatHex,694 "slice": "r10[31:0]",695 },696 {697 "name": "r11d",698 "set": 0,699 "bitsize": 32,700 "encoding": eEncodingUint,701 "format": eFormatHex,702 "slice": "r11[31:0]",703 },704 {705 "name": "r12d",706 "set": 0,707 "bitsize": 32,708 "encoding": eEncodingUint,709 "format": eFormatHex,710 "slice": "r12[31:0]",711 },712 {713 "name": "r13d",714 "set": 0,715 "bitsize": 32,716 "encoding": eEncodingUint,717 "format": eFormatHex,718 "slice": "r13[31:0]",719 },720 {721 "name": "r14d",722 "set": 0,723 "bitsize": 32,724 "encoding": eEncodingUint,725 "format": eFormatHex,726 "slice": "r14[31:0]",727 },728 {729 "name": "r15d",730 "set": 0,731 "bitsize": 32,732 "encoding": eEncodingUint,733 "format": eFormatHex,734 "slice": "r15[31:0]",735 },736 {737 "name": "ax",738 "set": 0,739 "bitsize": 16,740 "encoding": eEncodingUint,741 "format": eFormatHex,742 "slice": "rax[15:0]",743 },744 {745 "name": "bx",746 "set": 0,747 "bitsize": 16,748 "encoding": eEncodingUint,749 "format": eFormatHex,750 "slice": "rbx[15:0]",751 },752 {753 "name": "cx",754 "set": 0,755 "bitsize": 16,756 "encoding": eEncodingUint,757 "format": eFormatHex,758 "slice": "rcx[15:0]",759 },760 {761 "name": "dx",762 "set": 0,763 "bitsize": 16,764 "encoding": eEncodingUint,765 "format": eFormatHex,766 "slice": "rdx[15:0]",767 },768 {769 "name": "di",770 "set": 0,771 "bitsize": 16,772 "encoding": eEncodingUint,773 "format": eFormatHex,774 "slice": "rdi[15:0]",775 },776 {777 "name": "si",778 "set": 0,779 "bitsize": 16,780 "encoding": eEncodingUint,781 "format": eFormatHex,782 "slice": "rsi[15:0]",783 },784 {785 "name": "bp",786 "set": 0,787 "bitsize": 16,788 "encoding": eEncodingUint,789 "format": eFormatHex,790 "slice": "rbp[15:0]",791 },792 {793 "name": "sp",794 "set": 0,795 "bitsize": 16,796 "encoding": eEncodingUint,797 "format": eFormatHex,798 "slice": "rsp[15:0]",799 },800 {801 "name": "r8w",802 "set": 0,803 "bitsize": 16,804 "encoding": eEncodingUint,805 "format": eFormatHex,806 "slice": "r8[15:0]",807 },808 {809 "name": "r9w",810 "set": 0,811 "bitsize": 16,812 "encoding": eEncodingUint,813 "format": eFormatHex,814 "slice": "r9[15:0]",815 },816 {817 "name": "r10w",818 "set": 0,819 "bitsize": 16,820 "encoding": eEncodingUint,821 "format": eFormatHex,822 "slice": "r10[15:0]",823 },824 {825 "name": "r11w",826 "set": 0,827 "bitsize": 16,828 "encoding": eEncodingUint,829 "format": eFormatHex,830 "slice": "r11[15:0]",831 },832 {833 "name": "r12w",834 "set": 0,835 "bitsize": 16,836 "encoding": eEncodingUint,837 "format": eFormatHex,838 "slice": "r12[15:0]",839 },840 {841 "name": "r13w",842 "set": 0,843 "bitsize": 16,844 "encoding": eEncodingUint,845 "format": eFormatHex,846 "slice": "r13[15:0]",847 },848 {849 "name": "r14w",850 "set": 0,851 "bitsize": 16,852 "encoding": eEncodingUint,853 "format": eFormatHex,854 "slice": "r14[15:0]",855 },856 {857 "name": "r15w",858 "set": 0,859 "bitsize": 16,860 "encoding": eEncodingUint,861 "format": eFormatHex,862 "slice": "r15[15:0]",863 },864 {865 "name": "ah",866 "set": 0,867 "bitsize": 8,868 "encoding": eEncodingUint,869 "format": eFormatHex,870 "slice": "rax[15:8]",871 },872 {873 "name": "bh",874 "set": 0,875 "bitsize": 8,876 "encoding": eEncodingUint,877 "format": eFormatHex,878 "slice": "rbx[15:8]",879 },880 {881 "name": "ch",882 "set": 0,883 "bitsize": 8,884 "encoding": eEncodingUint,885 "format": eFormatHex,886 "slice": "rcx[15:8]",887 },888 {889 "name": "dh",890 "set": 0,891 "bitsize": 8,892 "encoding": eEncodingUint,893 "format": eFormatHex,894 "slice": "rdx[15:8]",895 },896 {897 "name": "al",898 "set": 0,899 "bitsize": 8,900 "encoding": eEncodingUint,901 "format": eFormatHex,902 "slice": "rax[7:0]",903 },904 {905 "name": "bl",906 "set": 0,907 "bitsize": 8,908 "encoding": eEncodingUint,909 "format": eFormatHex,910 "slice": "rbx[7:0]",911 },912 {913 "name": "cl",914 "set": 0,915 "bitsize": 8,916 "encoding": eEncodingUint,917 "format": eFormatHex,918 "slice": "rcx[7:0]",919 },920 {921 "name": "dl",922 "set": 0,923 "bitsize": 8,924 "encoding": eEncodingUint,925 "format": eFormatHex,926 "slice": "rdx[7:0]",927 },928 {929 "name": "dil",930 "set": 0,931 "bitsize": 8,932 "encoding": eEncodingUint,933 "format": eFormatHex,934 "slice": "rdi[7:0]",935 },936 {937 "name": "sil",938 "set": 0,939 "bitsize": 8,940 "encoding": eEncodingUint,941 "format": eFormatHex,942 "slice": "rsi[7:0]",943 },944 {945 "name": "bpl",946 "set": 0,947 "bitsize": 8,948 "encoding": eEncodingUint,949 "format": eFormatHex,950 "slice": "rbp[7:0]",951 },952 {953 "name": "spl",954 "set": 0,955 "bitsize": 8,956 "encoding": eEncodingUint,957 "format": eFormatHex,958 "slice": "rsp[7:0]",959 },960 {961 "name": "r8l",962 "set": 0,963 "bitsize": 8,964 "encoding": eEncodingUint,965 "format": eFormatHex,966 "slice": "r8[7:0]",967 },968 {969 "name": "r9l",970 "set": 0,971 "bitsize": 8,972 "encoding": eEncodingUint,973 "format": eFormatHex,974 "slice": "r9[7:0]",975 },976 {977 "name": "r10l",978 "set": 0,979 "bitsize": 8,980 "encoding": eEncodingUint,981 "format": eFormatHex,982 "slice": "r10[7:0]",983 },984 {985 "name": "r11l",986 "set": 0,987 "bitsize": 8,988 "encoding": eEncodingUint,989 "format": eFormatHex,990 "slice": "r11[7:0]",991 },992 {993 "name": "r12l",994 "set": 0,995 "bitsize": 8,996 "encoding": eEncodingUint,997 "format": eFormatHex,998 "slice": "r12[7:0]",999 },1000 {1001 "name": "r13l",1002 "set": 0,1003 "bitsize": 8,1004 "encoding": eEncodingUint,1005 "format": eFormatHex,1006 "slice": "r13[7:0]",1007 },1008 {1009 "name": "r14l",1010 "set": 0,1011 "bitsize": 8,1012 "encoding": eEncodingUint,1013 "format": eFormatHex,1014 "slice": "r14[7:0]",1015 },1016 {1017 "name": "r15l",1018 "set": 0,1019 "bitsize": 8,1020 "encoding": eEncodingUint,1021 "format": eFormatHex,1022 "slice": "r15[7:0]",1023 },1024]1025 1026g_target_definition = None1027 1028 1029def get_target_definition():1030 global g_target_definition1031 if g_target_definition is None:1032 g_target_definition = {}1033 offset = 01034 for reg_info in x86_64_register_infos:1035 reg_name = reg_info["name"]1036 1037 # Only fill in the offset if there is no 'slice' in the register1038 # info1039 if "slice" not in reg_info and "composite" not in reg_info:1040 reg_info["offset"] = offset1041 offset += reg_info["bitsize"] // 81042 1043 # Set the GCC/DWARF register number for this register if it has one1044 reg_num = get_reg_num(name_to_gcc_dwarf_regnum, reg_name)1045 if reg_num != LLDB_INVALID_REGNUM:1046 reg_info["gcc"] = reg_num1047 reg_info["dwarf"] = reg_num1048 1049 # Set the generic register number for this register if it has one1050 reg_num = get_reg_num(name_to_generic_regnum, reg_name)1051 if reg_num != LLDB_INVALID_REGNUM:1052 reg_info["generic"] = reg_num1053 1054 # Set the GDB register number for this register if it has one1055 reg_num = get_reg_num(name_to_gdb_regnum, reg_name)1056 if reg_num != LLDB_INVALID_REGNUM:1057 reg_info["gdb"] = reg_num1058 1059 g_target_definition["sets"] = [1060 "General Purpose Registers",1061 "Floating Point Registers",1062 ]1063 g_target_definition["registers"] = x86_64_register_infos1064 g_target_definition["host-info"] = {1065 "triple": "x86_64-*-linux",1066 "endian": eByteOrderLittle,1067 }1068 g_target_definition["g-packet-size"] = offset1069 g_target_definition["breakpoint-pc-offset"] = -11070 return g_target_definition1071 1072 1073def get_dynamic_setting(target, setting_name):1074 if setting_name == "gdb-server-target-definition":1075 return get_target_definition()1076