<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/96616>96616</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Hardware breakpoint not hint when set specify load addresses for sections
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
YaowenGuo
</td>
</tr>
</table>
<pre>
I'm using lldb connect QEMU to debug linux kernel. The linux kernel been load to 0x40200000, So I have to use `target modules load` to defining load addresses for sections. But when set this, the hardware breakpoint can't be hint. Is is a bug?
1. Build the latest linux kernel for ARM64.
2. Launch QEMU to debug kernel
```
qemu-system-aarch64 -machine virt,accel=hvf -cpu host \
-kernel arch/arm64/boot/Image \
-append "nokaslr"\
-nographic \
-m 2G \
-s \
-S
```
3. Launch lldb and connect to QEMU
```
lldb vmlinux
(lldb) gdb-remote 1234
(lldb) breakpoint set -H -a 0x41e300e8
(lldb) c
```
4. This will successfully hint this breakpoint. But when use `target modules load` to specify debug symbol addresses for sections.
```
(lldb) target modules load --file vmlinux .head.text 0x40200000 .text 0x40210000 .rodata.text 0x41e2b800 .init.text 0x41e40000
```
the section load address `.text 0x40210000 .rodata.text 0x41e2b800 .init.text 0x41e40000` may be different when linux version is different. You need use readelf to virtual address in vmlinux. and calculate:
```
Section load address = Sections start address - (Linux Entry address - Qemu load address)
e.g. .rodata.text
readelf -S out/arm64/vmlinux
There are 51 section headers, starting at offset 0x17316b88:
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[ 1] .head.text PROGBITS ffff800080000000 010000 010000 00 AX 0 0 65536
[19] .rodata.text PROGBITS ffff800081c2b800 1c3b800 005800 00 AX 0 0 2048
0xffff800081c2b800 - ( 0xffff800080000000 - 0x40200000) = 0x41e2b800
```
5. After set this. The breakpoint will not be hit regardless of whether the virtual or physical address is used to set the breakpoint.
set breakpoint by physical address:
```
(lldb) breakpoint set -H -a 0x41e300f4
```
set breakpoint by virtual address:
```
(lldb) breakpoint set -H -a 0xffff800081c300f4
(lldb) c
```
The breakpoint will not be hit now!!!
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVt1v2zYQ_2vol4MEivqI9eAHp6nbAP1Y6wxYHynpJHGhSI-knHh__UBaduTGbYdNcCLojvf9uztya0WnEFckvyX53YKPrtdm9Y3rJ1TvRr2odHNY3RN2M8BohepAyqaCWiuFtYMvbz_-Dk5Dg9XYgRRqfIZHNAplDA89XlCgQlQgNW-8BH3OKKP-IewNbDXcQ8_36FmjRSAFddx06GDQzSjRBkFS0KO1Vqjgi1fGm8agtWih1QYs1k5oZWO4HR089ajAogPXC-sNuR6h56Z54gahMsgfd1ooBzVXhN04qBB6oVwM9xaEBQ7V2JF0Q-gdoevj_8SrFrIJuiR3aN1lnN6N9dePRRYfBVgMH_io6v67dB2PT6oLOv3C5184jJE9WIdDxLmp-yKDaOB1LxTCXhhH2Bte1yhJetfvW4jq3Qi9tg5I_uaoAiCa_PHyhG24GYqMsE2ltSNscz_wDi-O890OVQOEMaUfuZWGMPbCj5TuDN_1or4QGoC9uyDYi6_t1fDSc0YCmrhqzohyOmTpqlg4vB9CsqcDbOmJhJXQNVVkcNAOIWFp9oo_K7YHRPQeIu5RmGBKKS5fna-vupB5XAsLT0JKsGNdo7XtKOUhwCbAbGZpBsJfgtrusBbtYcKGPQyVlj_C9lXXZr5fsQJR1AqJp_RB3CNvYofPbtaKMCMkR4LRDXf8TE-QVUtPF0q4GTULnXzNLd8lk-MX_eqz8T_NFRQGfvA924i2RYNqSvYxxD0a660K-8KPAb7pERRiE0pikDcoW18A31YjP-cchDolKz4ilMt69P1O0vXVSLdXo0zvYGJYsI4bd2ZFQNjyQ3D1rXLmcGZABF9wGC8UEVbOhxDGXXyRrSP5FE60BT26WdNfdM1DjwbBT8A8OdfG4wFNGJLBTT9fuQPdtr5d6HNykyZFtVyeoz-F-34SPNEBSH77yZD8Dj7x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