Giter Site home page Giter Site logo

Comments (23)

daniel5151 avatar daniel5151 commented on May 5, 2024 2

Hmmm, interesting...

As a quick reminder: these built-in arch defns are all community contributions, so I've never actually done any hands-on validation of the x64 arch. That said, I'm more than happy to help you figure out what's going on here.

Could you repro the register write request, while also having debugging enabled on the GDB client as well? I think the most relevant GDB commands would be:

set debug arch 1
set debug remote 1
set debug xml 1
set debug target 1

Also, what does show arch return after connecting to the target?

Maybe logging a warn! or error! if a write_register request comes in for a register that isn't known would be helpful for future users?

That seems like a reasonable addition, though I'd say hold off on opening a PR for it - it's something I can just throw in with some other changes :)

EDIT: and thank you for the support - it's very much appreciated 😄

from gdbstub.

gz avatar gz commented on May 5, 2024 2

Yes, I tried the set osabi none but if I set that I receive the infamous g packet too long response in gdb and things stopped working immediately after. So I gave up on that and tried to find out how to tell the rust linker not to define my kernel ELF as GNU/Linux -- found out that it's not even doing that (it sets it to SystemV Unix) -- tried to figure out how to change that and ultimately gave up :).

As a simple hack I'll probably set the OS ABI in ELF to none with the hex editor just to see what would happen, but got distracted so haven't tried yet.

from gdbstub.

bet4it avatar bet4it commented on May 5, 2024 2

The related backtrace: (GDB 10.2)

#0  remote_target::store_register_using_P (this=this@entry=0x5555578e6690, regcache=regcache@entry=0x5555579685f0, reg=reg@entry=0x55555792d8b0) at remote.c:8333
#1  0x0000555555f68f93 in remote_target::store_registers (this=0x5555578e6690, regcache=0x5555579685f0, regnum=<optimized out>) at remote.c:8431
#2  0x00005555560471c6 in target_store_registers (regcache=regcache@entry=0x5555579685f0, regno=regno@entry=16) at target.c:3410
#3  0x0000555555f4acee in regcache::raw_write (this=0x5555579685f0, regnum=16, buf=0x7fffffffd500 "\330(\fvv\177") at regcache.c:849
#4  0x0000555555f4e2b3 in regcache::cooked_write<unsigned long, void> (this=this@entry=0x5555579685f0, regnum=regnum@entry=16, val=140146763376856) at regcache.c:811
#5  0x0000555555f4cbfa in regcache_cooked_write_unsigned (regcache=regcache@entry=0x5555579685f0, regnum=regnum@entry=16, val=<optimized out>) at regcache.c:819
#6  0x0000555555c34861 in amd64_linux_write_pc (regcache=0x5555579685f0, pc=<optimized out>) at amd64-linux-tdep.c:297
#7  0x0000555555f4cc2c in regcache_write_pc (regcache=regcache@entry=0x5555579685f0, pc=pc@entry=140146763376856) at regcache.c:1331
#8  0x0000555555e15203 in adjust_pc_after_break (thread=0x55555796f830, ws=<optimized out>) at infrun.c:4236
#9  0x0000555555e1c34c in handle_inferior_event (ecs=0x7fffffffd890) at infrun.c:5102
#10 0x0000555555e1dc45 in fetch_inferior_event () at infrun.c:3931
#11 0x0000555555fc86be in run_async_handler_and_reschedule (scb=0x555557919000) at ser-base.c:137
#12 0x0000555556532d06 in gdb_wait_for_event (block=block@entry=1) at event-loop.cc:673
#13 0x0000555556532f6b in gdb_wait_for_event (block=1) at event-loop.cc:569
#14 gdb_do_one_event () at event-loop.cc:215
#15 0x0000555555e681c5 in start_event_loop () at main.c:356
#16 captured_command_loop () at main.c:416
#17 0x0000555555e6a555 in captured_main (data=data@entry=0x7fffffffda00) at main.c:1253
#18 gdb_main (args=args@entry=0x7fffffffda30) at main.c:1268
#19 0x0000555555bed1fc in main (argc=<optimized out>, argv=<optimized out>) at gdb.c:32

You get this because step is done by set a breakpoint on the next line, but you don't implement software breakpoint, so GDB do it by itself, and need to adjust pc after break.

You can solve it by implementing software breakpoint yourself.

If the mapping is read-only and you can't change it, you could implement gdb software breakpoint by hardware breakpoint inside. GDB don't care how you implement it.

from gdbstub.

daniel5151 avatar daniel5151 commented on May 5, 2024 1

Hmmm, very weird indeed.

Let me know if you keep looking into this, as while there is the disclaimer in gdbstub_arch that implementations aren't guaranteed to be correct, it would be best if they were correct :)


Also, in the future, could you wrap log output in a <details> tag? I've gone ahead and edited your past comments to do that, as it does make it easier to skim through the issue discussion.

i.e: the markdown should look like:

<details>
<summary>gdb log</summary>

```
// log text
```

</details>

from gdbstub.

gz avatar gz commented on May 5, 2024 1

Yes I'll definitely follow up this week on this issue. I'd def. want to use the read/write_register as opposed to read/write_registers for efficiency, and currently my gdb stops doing working with read/write_register enabled after it tries to set the reg 57 and gets a response that it can't do that.

One step before that is that I need to get step/next to work properly. Seems that gdb will want over-write some instructions for that in .text (with int3, as opposed to say call set_hw_breakpoint or set_sw_breakpoint), which in my case is mapped as read-only so not an option. But interestingly it looks like if you tell gdb that it can't write there it falls back to single-stepping and doesn't just set hardware breakpoints instead (that could also all be me doing it wrong though so I'll have to look into it some more first).

from gdbstub.

daniel5151 avatar daniel5151 commented on May 5, 2024 1

It should be noted that the GDB step command doesn't map onto the step packet in the GDB RSP (or at least, it doesn't have to).

The GDB step/next commands are source-code level directives. i.e: single step a single line of code. As such, at the protocol level, GDB will actually set a breakpoint, send a continue packet, and then unset the breakpoint once it's hit, since a single line can correspond to multiple instructions.

On the other hand, the GDB stepi command will actually single step over instructions, and will try to use the step packet in the GDB RSP (instead of continue + breakpoints).

sidenote: single stepping is actually an optional part of the protocol, and I have a tracking issue to make it optional in gdbstub as well: #59

As for when GDB tries to use hardware vs. software breakpoints... that is something I'm a bit fuzzy on. My hands-on experience integrating gdbstub into projects has primarily been with emulators, where breakpoints are something handled "unintrusively" via the emulator's interpreter infrastructure. As such, the challenges you're running into are fairly "new ground" for gdbstub, and as AFAIK, only you and xobs (in #56) have done this sort of thing 😅

In other words: your exploration and efforts are much appreciated, as you're providing a very useful practical validation of gdbstub's current bare-metal debugging capabilities!

from gdbstub.

gz avatar gz commented on May 5, 2024 1

Tried with returning Ok(false) and Err(TargetError::NonFatal) in add_sw_breakpoint, but it didn't it to switch to use the hw breakpoint API with these returns and stayed in single-step mode.

from gdbstub.

gz avatar gz commented on May 5, 2024 1

Not yet -- so far I just disabled the single register read/write. But I'll focus on this again now!

from gdbstub.

gz avatar gz commented on May 5, 2024 1

Hm, I wish I had documented the exact steps that led to this failure. I re-enabled single register read/write but can't trigger this error anymore. (I'm not getting any write register requests out-of-the-blue anymore (good), except if I trigger them myself using something like set $reg = 0x99 in gdb). So I'll close it.

from gdbstub.

daniel5151 avatar daniel5151 commented on May 5, 2024

So... should this issue be closed as well?

from gdbstub.

gz avatar gz commented on May 5, 2024

well my only remaining issue is that I still can't really tell what the register with ID 0x39 would be. It still wants to write to it but the register doesn't exist in the x86-64 arch in gdbstub.

from gdbstub.

gz avatar gz commented on May 5, 2024

To explain a bit more, I was trying to look at the xml files here. But they are somewhat confusing -- for example it's not very clear in what order they are applied which would define the IDs of registers. I figured maybe 0x39 is some AVX register or something related since it's right after the xmm registers.

There is this one, which seems to be Linux specific, so while I don't quite understand yet why gdb would try to set that on my bare-metal target I'll dig a bit deeper into it.

from gdbstub.

gz avatar gz commented on May 5, 2024

Somewhat related: Without trace output it was hard to tell that the register wouldn't get set. Since the RegID was missing in gdbstub_arch for x86-64, gdbstub would just return to gdb which would eventually print Protocol error: P (set-register) conflicting enabled responses. (because we were able to set past registers with the function but not this one).

Maybe logging a warn! or error! if a write_register request comes in for a register that isn't known would be helpful for future users?

from gdbstub.

gz avatar gz commented on May 5, 2024

I have to thank you, this library saved me weeks / months of code-writing :)

gdbstub log
 840283670 [INFO ] - nrk::arch::gdb: Waiting for a GDB connection (I/O port 0x2f8)...                                       
 850291296 [INFO ] - nrk::arch::gdb: Use `target remote localhost:1234` in gdb to connect.                                  
4380516342 [INFO ] - nrk::arch::gdb: Debugger connected.                                                                    
4385886304 [WARN ] - nrk::arch::irq: Got debug interrupt Debug condition                                                    
4415342166 [TRACE] - gdbstub::protocol::recv_packet: <-- $qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events
+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+;xmlRegisters=i386#6a                                
4437018188 [TRACE] - gdbstub::protocol::response_writer: --> $PacketSize=1000;vContSupported+;multiprocess+;QStartNoAckMode+
;hwbreak+;qXfer:features:read+#f2                                                                                           
4444059074 [TRACE] - gdbstub::protocol::recv_packet: <-- +                                                                  
4449171420 [TRACE] - gdbstub::protocol::recv_packet: <-- $vMustReplyEmpty#3a                                                
4453363374 [INFO ] - gdbstub::gdbstub_impl: Unknown command: Ok("vMustReplyEmpty")                                          
4457578078 [TRACE] - gdbstub::protocol::response_writer: --> $#00                                                           
4461711716 [TRACE] - gdbstub::protocol::recv_packet: <-- +                                                                  
4466849212 [TRACE] - gdbstub::protocol::recv_packet: <-- $QStartNoAckMode#b0                                                
4471198514 [TRACE] - gdbstub::protocol::response_writer: --> $OK#9a                                                         
4475300722 [TRACE] - gdbstub::protocol::recv_packet: <-- +                                                                  
4479334510 [TRACE] - gdbstub::protocol::recv_packet: <-- $Hgp0.0#ad                                                         
4483206904 [TRACE] - gdbstub::protocol::response_writer: --> $OK#9a                                                         
4580817552 [TRACE] - gdbstub::protocol::recv_packet: <-- $qXfer:features:read:target.xml:0,ffb#79                           
4591204068 [TRACE] - gdbstub::protocol::response_writer: --> $m<target version="1.0"><architecture>i386:x86-64</architecture
><feature name="org.gnu.gdb.i386.sse"></feature></target>#c7                                                                
4605889946 [TRACE] - gdbstub::protocol::recv_packet: <-- $qXfer:features:read:target.xml:76,ffb#b6                          
4612103508 [TRACE] - gdbstub::protocol::response_writer: --> $l#6c                                                          
4619367440 [TRACE] - gdbstub::protocol::recv_packet: <-- $qTStatus#49                                                       
4624229540 [INFO ] - gdbstub::gdbstub_impl: Unknown command: Ok("qTStatus")                                                 
4629359860 [TRACE] - gdbstub::protocol::response_writer: --> $#00                                                           
4725387364 [TRACE] - gdbstub::protocol::recv_packet: <-- $?#3f                                                              
4729103364 [TRACE] - gdbstub::protocol::response_writer: --> $S05#b8                                                        
4734787046 [TRACE] - gdbstub::protocol::recv_packet: <-- $qfThreadInfo#bb                                                   
4738904292 [TRACE] - gdbstub::protocol::response_writer: --> $mp01.01#cd                                                    
4744482530 [TRACE] - gdbstub::protocol::recv_packet: <-- $qsThreadInfo#c8                                                   
4748345052 [TRACE] - gdbstub::protocol::response_writer: --> $l#6c                                                          
4754153852 [TRACE] - gdbstub::protocol::recv_packet: <-- $qAttached:1#fa                                                    
4759208494 [TRACE] - gdbstub::protocol::response_writer: --> $1#31                                                          
4848619454 [TRACE] - gdbstub::protocol::recv_packet: <-- $Hc-1#09                                                           
4852407818 [TRACE] - gdbstub::protocol::response_writer: --> $OK#9a                                                         
4856826472 [TRACE] - gdbstub::protocol::recv_packet: <-- $qC#b4                                                             
4860423770 [INFO ] - gdbstub::gdbstub_impl: Unknown command: Ok("qC")                                                       
4864040356 [TRACE] - gdbstub::protocol::response_writer: --> $#00                                                           
4869162730 [TRACE] - gdbstub::protocol::recv_packet: <-- $qOffsets#4b                                                       
4874955834 [TRACE] - gdbstub::protocol::response_writer: --> $Text=40003cf2b000;Data=40003cf2b000;Bss=40003cf2b000#20       
4962649396 [TRACE] - gdbstub::protocol::recv_packet: <-- $g#67                                                              
4966262708 [TRACE] - nrk::arch::gdb: read_registers X86_64CoreRegs { regs: [0, 0, 70369772420144, 22, 70369771834825, 703697
88726576, 70369788727280, 70369788119552, 0, 0, 70369788115624, 43, 1, 1, 4, 1059062612], eflags: 6, rip: 70369768215027, se
gments: X86SegmentRegs { cs: 8, ss: 16, ds: 0, es: 0, fs: 0, gs: 0 }, st: [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0
, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 
0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], fpu: X87FpuInternalRegs { fctrl: 895, fs
tat: 0, ftag: 0, fiseg: 0, fioff: 0, foseg: 0, fooff: 0, fop: 0 }, xmm: [1298092979278047510573386339303424, 253530120045645
8802993406410752, 70369771938112, 49344, 32896, 18446744073709551617, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], mxcsr: 8096 }          
5007749082 [TRACE] - gdbstub::protocol::response_writer: --> $0000000000000000000000000000000030bc493d0040000016000000000000
00c9cd403d00400000308d423e00400000f08f423e00400000004a393e0040000000000000000000000000000000000000a83a393e004000002b00000000
0000000100000000000000010000000000000004000000000000005403203f00000000f391093d0040000006000000080000001000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000007f0300000000000000000000000000000000000000000000000000000000000000c0a1
3c0040000000c0a13c00400000000000000000000000000000200000004061423d004000000000000000000000c0c0000000000000000000000000000080
8000000000000000000000000000000100000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
0000000000a01f0000xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx#15                                                       
5048228468 [TRACE] - gdbstub::protocol::recv_packet: <-- $m578f50,8#40                                                      
5052025762 [INFO ] - nrk::arch::gdb: read_addr 0x578f50                                                                     
5056889144 [TRACE] - gdbstub::protocol::response_writer: --> $0000000000000000#86                                           
5063247842 [TRACE] - gdbstub::protocol::recv_packet: <-- $vFile:setfs:0#bf                                                  
5071613710 [INFO ] - gdbstub::gdbstub_impl: Unknown command: Ok("vFile:setfs:0")                                            
5081638500 [TRACE] - gdbstub::protocol::response_writer: --> $#00                                                           
5187356342 [TRACE] - gdbstub::protocol::recv_packet: <-- $vFile:open:6a7573742070726f62696e67,0,1c0#ed                      
5192274084 [INFO ] - gdbstub::gdbstub_impl: Unknown command: Ok("vFile:open:6a7573742070726f62696e67,0,1c0")                
5197149724 [TRACE] - gdbstub::protocol::response_writer: --> $#00                                                           
5203231786 [TRACE] - gdbstub::protocol::recv_packet: <-- $qfThreadInfo#bb                                                   
5207477682 [TRACE] - gdbstub::protocol::response_writer: --> $mp01.01#cd                                                    
5214145076 [TRACE] - gdbstub::protocol::recv_packet: <-- $qsThreadInfo#c8                                                   
5219525434 [TRACE] - gdbstub::protocol::response_writer: --> $l#6c                                                          
5328657264 [TRACE] - gdbstub::protocol::recv_packet: <-- $m40003d0991f3,1#91                                                
5338691694 [INFO ] - nrk::arch::gdb: read_addr 0x40003d0991f3                                                               
5348108652 [TRACE] - gdbstub::protocol::response_writer: --> $e8#9d                                                         
5360963978 [TRACE] - gdbstub::protocol::recv_packet: <-- $m40003d0991f3,1#91                                                
5371136192 [INFO ] - nrk::arch::gdb: read_addr 0x40003d0991f3                                                               
5380395126 [TRACE] - gdbstub::protocol::response_writer: --> $e8#9d                                                         
5414077684 [TRACE] - gdbstub::protocol::recv_packet: <-- $m40003e428de0,8#c4                                                
5424238604 [INFO ] - nrk::arch::gdb: read_addr 0x40003e428de0                                                               
5434808738 [TRACE] - gdbstub::protocol::response_writer: --> $0070123e00400000#d1                                           
5535779352 [TRACE] - gdbstub::protocol::recv_packet: <-- $m40003e428de8,8#cc                                                
5545978068 [INFO ] - nrk::arch::gdb: read_addr 0x40003e428de8                                                               
5555703970 [TRACE] - gdbstub::protocol::response_writer: --> $0900000000000000#ed                                           
5569697154 [TRACE] - gdbstub::protocol::recv_packet: <-- $qSymbol::#5b                                                      
5579379020 [INFO ] - gdbstub::gdbstub_impl: Unknown command: Ok("qSymbol::")                                                
5589545262 [TRACE] - gdbstub::protocol::response_writer: --> $#00                                                           
42093724802 [TRACE] - gdbstub::protocol::recv_packet: <-- $vCont?#49                                                        
42105033726 [TRACE] - gdbstub::protocol::response_writer: --> $vCont;c;C;s;S#62                                             
42119887870 [TRACE] - gdbstub::protocol::recv_packet: <-- $vCont;s:p1.1;c:p1.-1#f7                                          
42129809842 [TRACE] - nrk::arch::gdb: resume_with =  Step                                                                   
42136401128 [TRACE] - nrk::arch::gdb: Step execution, set TF flag.                                                          
42141253958 [WARN ] - nrk::arch::irq: Got debug interrupt Debug condition                                                   
42146425614 [INFO ] - nrk::arch::gdb: stop reason is DoneStep                                                               
42151355210 [TRACE] - gdbstub::protocol::response_writer: --> $S05#b8                                                       
42249755202 [TRACE] - gdbstub::protocol::recv_packet: <-- $g#67                                                             
42253294396 [TRACE] - nrk::arch::gdb: read_registers X86_64CoreRegs { regs: [0, 0, 70369772420144, 22, 70369771834825, 70369
788726576, 70369788727280, 70369788119544, 0, 0, 70369788115624, 43, 1, 1, 4, 1059062612], eflags: 262, rip: 70369767709744,
 segments: X86SegmentRegs { cs: 8, ss: 16, ds: 0, es: 0, fs: 0, gs: 0 }, st: [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0
, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 
0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], fpu: X87FpuInternalRegs { fctrl: 895,
 fstat: 0, ftag: 0, fiseg: 0, fioff: 0, foseg: 0, fooff: 0, fop: 0 }, xmm: [1298092979278047510573386339303424, 253530120045
6458802993406410752, 70369771938112, 49344, 32896, 18446744073709551617, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], mxcsr: 8096 }
42293532064 [TRACE] - gdbstub::protocol::response_writer: --> $0000000000000000000000000000000030bc493d004000001600000000000000c9cd403d00400000308d423e00400000f08f423e00400000f849393e0040000000000000000000000000000000000000a83a393e004000002b000000000000000100000000000000010000000000000004000000000000005403203f0000000030dc013d004000000601000008000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f0300000000000000000000000000000000000000000000000000000000000000c0a13c0040000000c0a13c00400000000000000000000000000000200000004061423d004000000000000000000000c0c00000000000000000000000000000808000000000000000000000000000000100000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a01f0000xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx#4b
42337450760 [TRACE] - gdbstub::protocol::recv_packet: <-- $m40003d01dc30,1#b0
42341564990 [INFO ] - nrk::arch::gdb: read_addr 0x40003d01dc30
42345293410 [TRACE] - gdbstub::protocol::response_writer: --> $55#6a
42353595808 [TRACE] - gdbstub::protocol::recv_packet: <-- $m40003d01dc30,1#b0
42358735182 [INFO ] - nrk::arch::gdb: read_addr 0x40003d01dc30
42363465598 [TRACE] - gdbstub::protocol::response_writer: --> $55#6a
42461912360 [TRACE] - gdbstub::protocol::recv_packet: <-- $m40003e3949c0,40#c5
42465781814 [INFO ] - nrk::arch::gdb: read_addr 0x40003e3949c0
42473719054 [TRACE] - gdbstub::protocol::response_writer: --> $0449393e004000000413000000000000c9cd403d004000001600000000000000800d3b3e00400000800d3b3e00400000f08f423e00400000f891093d00400000#4e
42485930024 [TRACE] - gdbstub::protocol::recv_packet: <-- $m40003d01dc3b,1#e2
42489843358 [INFO ] - nrk::arch::gdb: read_addr 0x40003d01dc3b
42493380556 [TRACE] - gdbstub::protocol::response_writer: --> $48#6c
42500420146 [TRACE] - gdbstub::protocol::recv_packet: <-- $Z0,40003d01dc3b,1#2b
42504803946 [TRACE] - gdbstub::protocol::response_writer: --> $#00
42601405102 [TRACE] - gdbstub::protocol::recv_packet: <-- $m40003d01dc3b,1#e2
42605169092 [INFO ] - nrk::arch::gdb: read_addr 0x40003d01dc3b
42608622344 [TRACE] - gdbstub::protocol::response_writer: --> $48#6c
42615341420 [TRACE] - gdbstub::protocol::recv_packet: <-- $X40003d01dc3b,0:#06
42619336952 [INFO ] - gdbstub::gdbstub_impl: Unknown command: Ok("X40003d01dc3b,0:")
42623310732 [TRACE] - gdbstub::protocol::response_writer: --> $#00
42629564632 [TRACE] - gdbstub::protocol::recv_packet: <-- $M40003d01dc3b,1:cc#c2
42633690906 [INFO ] - nrk::arch::gdb: write_addrs 0x40003d01dc3b
42638410278 [TRACE] - gdbstub::protocol::response_writer: --> $OK#9a
42734541116 [TRACE] - gdbstub::protocol::recv_packet: <-- $vCont;c:p1.-1#0f
42738378838 [TRACE] - nrk::arch::gdb: resume_with =  Continue
42741749240 [TRACE] - nrk::arch::gdb: Resume execution.
42744919016 [WARN ] - nrk::arch::irq: Got breakpoint interrupt INT 3 instruction.
42750004450 [TRACE] - gdbstub::protocol::response_writer: --> $T05thread:p01.01;hwbreak:;#5f
42756525234 [TRACE] - gdbstub::protocol::recv_packet: <-- $g#67
42759985258 [TRACE] - nrk::arch::gdb: read_registers X86_64CoreRegs { regs: [0, 0, 70369772420144, 22, 70369771834825, 70369788726576, 70369788119536, 70369788119040, 0, 0, 70369788115624, 43, 1, 1, 4, 1059062612], eflags: 6, rip: 70369767709756, segments: X86SegmentRegs { cs: 8, ss: 16, ds: 0, es: 0, fs: 0, gs: 0 }, st: [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], fpu: X87FpuInternalRegs { fctrl: 895, fstat: 0, ftag: 0, fiseg: 0, fioff: 0, foseg: 0, fooff: 0, fop: 0 }, xmm: [1298092979278047510573386339303424, 2535301200456458802993406410752, 70369771938112, 49344, 32896, 18446744073709551617, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], mxcsr: 8096 }
42799271962 [TRACE] - gdbstub::protocol::response_writer: --> $0000000000000000000000000000000030bc493d004000001600000000000000c9cd403d00400000308d423e00400000f049393e004000000048393e0040000000000000000000000000000000000000a83a393e004000002b000000000000000100000000000000010000000000000004000000000000005403203f000000003cdc013d004000000600000008000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f0300000000000000000000000000000000000000000000000000000000000000c0a13c0040000000c0a13c00400000000000000000000000000000200000004061423d004000000000000000000000c0c00000000000000000000000000000808000000000000000000000000000000100000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a01f0000xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx#13
42839102166 [TRACE] - gdbstub::protocol::recv_packet: <-- $P10=3bdc013d00400000#c6
42843061070 [ERROR] - nrk::arch::gdb: write_register Rip [59, 220, 1, 61, 0, 64, 0, 0]
42847715380 [INFO ] - nrk::arch::gdb: before rip 0x40003d01dc3c
42852282096 [INFO ] - nrk::arch::gdb: set rip 0x40003d01dc3b
42856862716 [TRACE] - gdbstub::protocol::response_writer: --> $OK#9a
42953620070 [TRACE] - gdbstub::protocol::recv_packet: <-- $P39=ffffffffffffffff#59
42957493132 [TRACE] - gdbstub::protocol::response_writer: --> $#00
42964482862 [TRACE] - gdbstub::protocol::recv_packet: <-- $M40003d01dc3b,1:48#68
42968349320 [INFO ] - nrk::arch::gdb: write_addrs 0x40003d01dc3b
42971794630 [TRACE] - gdbstub::protocol::response_writer: --> $OK#9a

show arch:

➜  kernel git:(gdbstub) ✗ gdb ../target/x86_64-uefi/debug/esp/kernel
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ../target/x86_64-uefi/debug/esp/kernel...
warning: remote target does not support file transfer, attempting to access files from local filesystem.
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
nrk::arch::_start (argc=70369785573376, _argv=0x9) at kernel/src/arch/x86_64/mod.rs:801
801	    let _r = xmain();
(gdb) show arch
The target architecture is set automatically (currently i386:x86-64)

gdb output:

➜  kernel git:(gdbstub) ✗ gdb ../target/x86_64-uefi/debug/esp/kernel 
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ../target/x86_64-uefi/debug/esp/kernel...
warning: remote target does not support file transfer, attempting to access files from local filesystem.
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
nrk::arch::_start (argc=70369785573376, _argv=0x9) at kernel/src/arch/x86_64/mod.rs:801
801	    let _r = xmain();
(gdb) set debug arch 1
(gdb) set debug remote 1
(gdb) set debug xml 1
(gdb) set debug target 1
(gdb) step
-> remote->log_command (...)
<- remote->log_command (step)
-> remote->record_is_replaying (...)
<- remote->record_is_replaying (-1) = false
-> remote->record_will_replay (...)
<- remote->record_will_replay (-1, 0) = false
-> remote->supports_multi_process (...)
<- remote->supports_multi_process () = true
-> remote->thread_address_space (...)
<- remote->thread_address_space (1) = 1
-> remote->record_will_replay (...)
<- remote->record_will_replay (-1, 0) = false
-> remote->supports_multi_process (...)
<- remote->supports_multi_process () = true
-> remote->terminal_inferior (...)
<- remote->terminal_inferior ()
-> remote->record_will_replay (...)
<- remote->record_will_replay (-1, 0) = false
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->thread_address_space (...)
<- remote->thread_address_space (1) = 1
-> remote->thread_address_space (...)
<- remote->thread_address_space (1) = 1
-> remote->thread_address_space (...)
<- remote->thread_address_space (1) = 1
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->record_will_replay (...)
<- remote->record_will_replay (-1, 0) = false
-> remote->supports_multi_process (...)
<- remote->supports_multi_process () = true
-> remote->pass_signals (...)
<- remote->pass_signals ({ SIGALRM SIGURG SIGCHLD SIGIO SIGVTALRM SIGPROF SIGWINCH SIGPOLL SIGWAITING SIGLWP SIGPRIO SIGCANCEL SIGLIBRT })
-> remote->resume (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = false
Sending packet: $vCont?#49...Packet received: vCont;c;C;s;S
Packet vCont (verbose-resume) is supported
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = false
Sending packet: $vCont;s:p1.1;c:p1.-1#f7...-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->can_async_p (...)
<- remote->can_async_p () = true
-> remote->async (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
<- remote->async (1)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
<- remote->resume (1, step, 0)
-> remote->is_async_p (...)
<- remote->is_async_p () = true
-> remote->commit_resume (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
<- remote->commit_resume ()
-> remote->can_async_p (...)
<- remote->can_async_p () = true
-> remote->execution_direction (...)
<- remote->execution_direction () = 0
-> remote->can_async_p (...)
<- remote->can_async_p () = true
-> remote->wait (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = true
<- remote->wait (-1, status->kind = ignore, TARGET_WNOHANG) = -1
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = true
-> remote->execution_direction (...)
<- remote->execution_direction () = 0
-> remote->can_async_p (...)
<- remote->can_async_p () = true
-> remote->wait (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
Packet received: S05
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = true
<- remote->wait (-1, status->kind = stopped, signal = GDB_SIGNAL_TRAP, TARGET_WNOHANG) = 1
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->supports_stopped_by_sw_breakpoint (...)
<- remote->supports_stopped_by_sw_breakpoint () = false
-> remote->thread_architecture (...)
<- remote->thread_architecture (1) = i386:x86-64
-> remote->thread_address_space (...)
<- remote->thread_address_space (1) = 1
-> remote->fetch_registers (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = true
Sending packet: $g#67...Packet received: 0000000000000000000000000000000030bc493d004000001600000000000000c9cd403d00400000308d423e00400000f08f423e00400000f849393e0040000000000000000000000000000000000000a83a393e004000002b000000000000000100000000000000010000000000000004000000000000005403203f0000000030dc013d004000000601000008000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f0300000000000000000000[608 bytes omitted]
<- remote->fetch_registers (0x564a0de1cef0, 16)
target_fetch_registers (rip) = 30dc013d00400000 0x40003d01dc30 70369767709744
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->thread_address_space (...)
<- remote->thread_address_space (1) = 1
-> remote->thread_address_space (...)
<- remote->thread_address_space (1) = 1
-> remote->thread_address_space (...)
<- remote->thread_address_space (1) = 1
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->stopped_by_watchpoint (...)
<- remote->stopped_by_watchpoint () = false
-> remote->thread_address_space (...)
<- remote->thread_address_space (1) = 1
-> remote->supports_stopped_by_sw_breakpoint (...)
<- remote->supports_stopped_by_sw_breakpoint () = false
-> remote->thread_address_space (...)
<- remote->thread_address_space (1) = 1
-> remote->supports_stopped_by_sw_breakpoint (...)
<- remote->supports_stopped_by_sw_breakpoint () = false
-> remote->stopped_by_sw_breakpoint (...)
<- remote->stopped_by_sw_breakpoint () = false
-> remote->stopped_by_hw_breakpoint (...)
<- remote->stopped_by_hw_breakpoint () = false
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->get_unwinder (...)
<- remote->get_unwinder () = 0x0
-> remote->get_tailcall_unwinder (...)
<- remote->get_tailcall_unwinder () = 0x0
-> remote->thread_address_space (...)
<- remote->thread_address_space (1) = 1
-> remote->xfer_partial (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = true
Sending packet: $m40003d01dc30,1#b0...Packet received: 55
<- remote->xfer_partial (1, (null), 0x7ffd06628c57, 0x0, 0x40003d01dc30, 0x1, 0x1) = 1
remote:target_xfer_partial (1, (null), 0x7ffd06628c57, 0x0, 0x40003d01dc30, 1) = 1, 1, bytes = 55
-> remote->xfer_partial (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = true
Sending packet: $m40003d01dc30,1#b0...Packet received: 55
<- remote->xfer_partial (1, (null), 0x7ffd06628c57, 0x0, 0x40003d01dc30, 0x1, 0x1) = 1
remote:target_xfer_partial (1, (null), 0x7ffd06628c57, 0x0, 0x40003d01dc30, 1) = 1, 1, bytes = 55
-> remote->get_unwinder (...)
<- remote->get_unwinder () = 0x0
-> remote->get_tailcall_unwinder (...)
<- remote->get_tailcall_unwinder () = 0x0
-> remote->thread_address_space (...)
<- remote->thread_address_space (1) = 1
-> remote->xfer_partial (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = true
Sending packet: $m40003e3949c0,40#c5...Packet received: 0449393e004000000413000000000000c9cd403d004000001600000000000000800d3b3e00400000800d3b3e00400000f08f423e00400000f891093d00400000
<- remote->xfer_partial (1, (null), 0x564a0d9d5a5c, 0x0, 0x40003e3949c0, 0x40, 0x40) = 1
remote:target_xfer_partial (2, (null), 0x564a0d9d5a5c, 0x0, 0x40003e3949c0, 64) = 1, 64, bytes = 04 49 39 3e ...
remote:target_xfer_partial (3, (null), 0x564a0da15250, 0x0, 0x40003e3949f8, 8) = 1, 8, bytes =
 f8 91 09 3d 00 40 00 00
remote:target_xfer_partial (3, (null), 0x564a0da15250, 0x0, 0x40003e3949f8, 8) = 1, 8, bytes =
 f8 91 09 3d 00 40 00 00
-> remote->supports_evaluation_of_breakpoint_conditions (...)
<- remote->supports_evaluation_of_breakpoint_conditions () = false
-> remote->xfer_partial (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = true
Sending packet: $m40003d01dc3b,1#e2...Packet received: 48
<- remote->xfer_partial (1, (null), 0x7ffd06628970, 0x0, 0x40003d01dc3b, 0x1, 0x1) = 1
remote:target_xfer_partial (1, (null), 0x7ffd06628970, 0x0, 0x40003d01dc3b, 1) = 1, 1, bytes =
 48
-> remote->thread_address_space (...)
<- remote->thread_address_space (1) = 1
-> remote->thread_address_space (...)
<- remote->thread_address_space (1) = 1
-> remote->insert_breakpoint (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = true
Sending packet: $Z0,40003d01dc3b,1#2b...Packet received: 
Packet Z0 (software-breakpoint) is NOT supported
-> remote->xfer_partial (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = true
Sending packet: $m40003d01dc3b,1#e2...Packet received: 48
<- remote->xfer_partial (1, (null), 0x7ffd06628950, 0x0, 0x40003d01dc3b, 0x1, 0x1) = 1
remote:target_xfer_partial (1, (null), 0x7ffd06628950, 0x0, 0x40003d01dc3b, 1) = 1, 1, bytes =
 48
-> remote->xfer_partial (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = true
Sending packet: $X40003d01dc3b,0:#06...Packet received: 
binary downloading NOT supported by target
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = true
Sending packet: $M40003d01dc3b,1:cc#c2...Packet received: OK
<- remote->xfer_partial (1, (null), 0x0, 0x564a0c666d40, 0x40003d01dc3b, 0x1, 0x1) = 1
remote:target_xfer_partial (2, (null), 0x0, 0x564a0c666d40, 0x40003d01dc3b, 1) = 1, 1, bytes =
 cc
<- remote->insert_breakpoint (i386:x86-64, 0x000040003d01dc3b) = 0
-> remote->thread_address_space (...)
<- remote->thread_address_space (1) = 1
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->record_will_replay (...)
<- remote->record_will_replay (-1, 0) = false
-> remote->supports_multi_process (...)
<- remote->supports_multi_process () = true
-> remote->pass_signals (...)
<- remote->pass_signals ({ SIGALRM SIGURG SIGCHLD SIGIO SIGVTALRM SIGPROF SIGWINCH SIGPOLL SIGWAITING SIGLWP SIGPRIO SIGCANCEL SIGLIBRT })
-> remote->resume (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = true
Sending packet: $vCont;c:p1.-1#0f...-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->can_async_p (...)
<- remote->can_async_p () = true
-> remote->async (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
<- remote->async (1)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
<- remote->resume (1, continue, 0)
-> remote->commit_resume (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
<- remote->commit_resume ()
-> remote->is_async_p (...)
<- remote->is_async_p () = true
-> remote->execution_direction (...)
<- remote->execution_direction () = 0
-> remote->can_async_p (...)
<- remote->can_async_p () = true
-> remote->wait (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
Packet received: T05thread:p01.01;hwbreak:;
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = true
<- remote->wait (-1, status->kind = stopped, signal = GDB_SIGNAL_TRAP, TARGET_WNOHANG) = 1
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->supports_stopped_by_sw_breakpoint (...)
<- remote->supports_stopped_by_sw_breakpoint () = false
-> remote->thread_architecture (...)
<- remote->thread_architecture (1) = i386:x86-64
-> remote->thread_address_space (...)
<- remote->thread_address_space (1) = 1
-> remote->fetch_registers (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = true
Sending packet: $g#67...Packet received: 0000000000000000000000000000000030bc493d004000001600000000000000c9cd403d00400000308d423e00400000f049393e004000000048393e0040000000000000000000000000000000000000a83a393e004000002b000000000000000100000000000000010000000000000004000000000000005403203f000000003cdc013d004000000600000008000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f0300000000000000000000[608 bytes omitted]
<- remote->fetch_registers (0x564a0de1cef0, 16)
target_fetch_registers (rip) = 3cdc013d00400000 0x40003d01dc3c 70369767709756
-> remote->prepare_to_store (...)
<- remote->prepare_to_store (0x564a0de1cef0)
-> remote->store_registers (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = true
Sending packet: $P10=3bdc013d00400000#c6...Packet received: OK
Packet P (set-register) is supported
<- remote->store_registers (0x564a0de1cef0, 16)
target_store_registers (rip) = 3bdc013d00400000 0x40003d01dc3b 70369767709755
-> remote->prepare_to_store (...)
<- remote->prepare_to_store (0x564a0de1cef0)
-> remote->store_registers (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = true
Sending packet: $P39=ffffffffffffffff#59...Packet received: 
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->supports_evaluation_of_breakpoint_conditions (...)
<- remote->supports_evaluation_of_breakpoint_conditions () = false
-> remote->remove_breakpoint (...)
-> remote->xfer_partial (...)
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->is_async_p (...)
<- remote->is_async_p () = true
Sending packet: $M40003d01dc3b,1:48#68...Packet received: OK
<- remote->xfer_partial (1, (null), 0x0, 0x564a0dd00844, 0x40003d01dc3b, 0x1, 0x1) = 1
remote:target_xfer_partial (2, (null), 0x0, 0x564a0dd00844, 0x40003d01dc3b, 1) = 1, 1, bytes = 48
<- remote->remove_breakpoint (i386:x86-64, 0x000040003d01dc3b, 0) = 0
-> remote->always_non_stop_p (...)
<- remote->always_non_stop_p () = false
-> remote->supports_terminal_ours (...)
<- remote->supports_terminal_ours () = false
Protocol error: P (set-register) conflicting enabled responses.
-> remote->terminal_save_inferior (...)
<- remote->terminal_save_inferior ()
-> remote->terminal_ours (...)
<- remote->terminal_ours ()
(gdb) 

from gdbstub.

daniel5151 avatar daniel5151 commented on May 5, 2024

Ahh, it seems you've only enabled those debug logs after connecting to the target. It'd be nice to see some of the initial handshake as well. You may need to modify your .gdbinit script to enable debugging a bit earlier.

Also, some other ideas on how we might get to the bottom of this:

  • Define a custom Arch implementation that uses a super-explicit target.xml implementation, spelling out exactly which registers ought to be available. A good starting point may be the x64 config that QEMU, though keep in mind you will need to tweak the implementations + layout of the Registers + RegId structs to match the XML file. https://github.com/qemu/qemu/blob/master/gdb-xml/i386-64bit.xml
  • If you are able to boot your kernel in something like QEMU, see if you can trigger the same packet request.

Though I would start with posting more detailed logs :)

from gdbstub.

gz avatar gz commented on May 5, 2024

Ah here is the log with debugging enabled in .gdbinit:

gdb log
GNU gdb (Ubuntu 9.2-0ubuntu1~20.04) 9.2
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ../target/x86_64-uefi/debug/esp/kernel...
-> exec->log_command (...)
<- exec->log_command (target remote localhost:1234)
-> remote->open (...)
target_close ()
Sending packet: $qSupported:multiprocess+;swbreak+;hwbreak+;qRelocInsn+;fork-events+;vfork-events+;exec-events+;vContSupported+;QThreadEvents+;no-resumed+;xmlRegisters=i386#6a...Ack
Packet received: PacketSize=1000;vContSupported+;multiprocess+;QStartNoAckMode+;hwbreak+;qXfer:features:read+
Packet qSupported (supported-packets) is supported
Sending packet: $vMustReplyEmpty#3a...Ack
Packet received: 
Sending packet: $QStartNoAckMode#b0...Ack
Packet received: OK
Sending packet: $Hgp0.0#ad...Packet received: OK
Sending packet: $qXfer:features:read:target.xml:0,ffb#79...Packet received: m<target version="1.0"><architecture>i386:x86-64</architecture><feature name="org.gnu.gdb.i386.sse"></feature></target>
remote:target_xfer_partial (10, target.xml, 0x556fd408fd90, 0x0, 0x0, 4096) = 1, 118, bytes =
 3c 74 61 72 67 65 74 20 76 65 72 73 69 6f 6e 3d ...
Sending packet: $qXfer:features:read:target.xml:76,ffb#b6...Packet received: l
remote:target_xfer_partial (10, target.xml, 0x556fd4233cb6, 0x0, 0x76, 4096) = 0, 0
target description (line 1): Starting:
<target version="1.0"><architecture>i386:x86-64</architecture><feature name="org.gnu.gdb.i386.sse"></feature></target>
target description (line 1): Entering element <target>
target description (line 1): Entering element <architecture>
target description (line 1): Leaving element <architecture>
target description (line 1): Entering element <feature>
target description (line 1): Leaving element <feature>
target description (line 1): Leaving element <target>
target description (line 1): XInclude processing succeeded.
target description (line 1): Starting:
<target version="1.0"><architecture>i386:x86-64</architecture><feature name="org.gnu.gdb.i386.sse"></feature></target>
target description (line 1): Entering element <target>
target description (line 1): Parsing attribute version="1.0"
target description (line 1): Entering element <architecture>
target description (line 1): Leaving element <architecture>
target description (line 1): Entering element <feature>
target description (line 1): Parsing attribute name="org.gnu.gdb.i386.sse"
target description (line 1): Leaving element <feature>
target description (line 1): Leaving element <target>
gdbarch_find_by_info: info.bfd_arch_info i386:x86-64
gdbarch_find_by_info: info.byte_order 1 (little)
gdbarch_find_by_info: info.osabi 5 (GNU/Linux)
gdbarch_find_by_info: info.abfd 0x556fd3f9f2d0
gdbarch_find_by_info: info.tdep_info 0x0
gdbarch_find_by_info: New architecture 0x556fd40dfed0 (i386:x86-64) selected
gdbarch_dump: GDB_NM_FILE = config/nm-linux.h
gdbarch_dump: addr_bit = 64
gdbarch_dump: addr_bits_remove = <0x556fd321b910>
gdbarch_dump: gdbarch_address_class_name_to_type_flags_p() = 0
gdbarch_dump: address_class_name_to_type_flags = <0x0>
gdbarch_dump: gdbarch_address_class_type_flags_p() = 0
gdbarch_dump: address_class_type_flags = <0x0>
gdbarch_dump: gdbarch_address_class_type_flags_to_name_p() = 0
gdbarch_dump: address_class_type_flags_to_name = <0x0>
gdbarch_dump: address_to_pointer = <0x556fd33278d0>
gdbarch_dump: addressable_memory_unit_size = <0x556fd321cab0>
gdbarch_dump: gdbarch_adjust_breakpoint_address_p() = 0
gdbarch_dump: adjust_breakpoint_address = <0x0>
gdbarch_dump: adjust_dwarf2_addr = <0x556fd321b960>
gdbarch_dump: adjust_dwarf2_line = <0x556fd321b970>
gdbarch_dump: auto_charset = <0x556fd326c8f0>
gdbarch_dump: auto_wide_charset = <0x556fd326c900>
gdbarch_dump: gdbarch_auxv_parse_p() = 0
gdbarch_dump: auxv_parse = <0x0>
gdbarch_dump: gdbarch_ax_pseudo_register_collect_p() = 1
gdbarch_dump: ax_pseudo_register_collect = <0x556fd3216930>
gdbarch_dump: gdbarch_ax_pseudo_register_push_stack_p() = 0
gdbarch_dump: ax_pseudo_register_push_stack = <0x0>
gdbarch_dump: believe_pcc_promotion = 0
gdbarch_dump: bfd_arch_info = i386:x86-64
gdbarch_dump: breakpoint_from_pc = <0x556fd321c8c0>
gdbarch_dump: breakpoint_kind_from_current_state = <0x556fd321c8f0>
gdbarch_dump: breakpoint_kind_from_pc = <0x556fd3362d40>
gdbarch_dump: byte_order = 1
gdbarch_dump: byte_order_for_code = 1
gdbarch_dump: call_dummy_location = 1
gdbarch_dump: cannot_fetch_register = <0x556fd321b990>
gdbarch_dump: cannot_step_breakpoint = 0
gdbarch_dump: cannot_store_register = <0x556fd321b990>
gdbarch_dump: char_signed = 1
gdbarch_dump: code_of_frame_writable = <0x556fd321b8e0>
gdbarch_dump: coff_make_msymbol_special = <0x556fd321b940>
gdbarch_dump: convert_from_func_ptr_addr = <0x556fd321b920>
gdbarch_dump: convert_register_p = <0x556fd3370db0>
gdbarch_dump: gdbarch_core_info_proc_p() = 1
gdbarch_dump: core_info_proc = <0x556fd33b56c0>
gdbarch_dump: gdbarch_core_pid_to_str_p() = 1
gdbarch_dump: core_pid_to_str = <0x556fd33b4130>
gdbarch_dump: gdbarch_core_read_description_p() = 1
gdbarch_dump: core_read_description = <0x556fd3215780>
gdbarch_dump: gdbarch_core_thread_name_p() = 0
gdbarch_dump: core_thread_name = <0x0>
gdbarch_dump: gdbarch_core_xfer_shared_libraries_p() = 0
gdbarch_dump: core_xfer_shared_libraries = <0x0>
gdbarch_dump: gdbarch_core_xfer_shared_libraries_aix_p() = 0
gdbarch_dump: core_xfer_shared_libraries_aix = <0x0>
gdbarch_dump: gdbarch_core_xfer_siginfo_p() = 1
gdbarch_dump: core_xfer_siginfo = <0x556fd33b6c50>
gdbarch_dump: decr_pc_after_break = 0x1
gdbarch_dump: deprecated_fp_regnum = -1
gdbarch_dump: deprecated_function_start_offset = 0x0
gdbarch_dump: disassembler_options = (null)
gdbarch_dump: disassembler_options_implicit = (null)
gdbarch_dump: gdbarch_displaced_step_copy_insn_p() = 1
gdbarch_dump: displaced_step_copy_insn = <0x556fd3218f50>
gdbarch_dump: gdbarch_displaced_step_fixup_p() = 1
gdbarch_dump: displaced_step_fixup = <0x556fd32193e0>
gdbarch_dump: displaced_step_hw_singlestep = <0x556fd321b790>
gdbarch_dump: displaced_step_location = <0x556fd33b7430>
gdbarch_dump: double_bit = 64
gdbarch_dump: double_format = floatformat_ieee_double_big
gdbarch_dump: gdbarch_dtrace_disable_probe_p() = 1
gdbarch_dump: dtrace_disable_probe = <0x556fd3215480>
gdbarch_dump: gdbarch_dtrace_enable_probe_p() = 1
gdbarch_dump: dtrace_enable_probe = <0x556fd32154a0>
gdbarch_dump: gdbarch_dtrace_parse_probe_argument_p() = 1
gdbarch_dump: dtrace_parse_probe_argument = <0x556fd32155a0>
gdbarch_dump: gdbarch_dtrace_probe_is_enabled_p() = 1
gdbarch_dump: dtrace_probe_is_enabled = <0x556fd32154c0>
gdbarch_dump: dummy_id = <0x556fd3216730>
gdbarch_dump: dwarf2_addr_size = 8
gdbarch_dump: dwarf2_reg_to_regnum = <0x556fd32167a0>
gdbarch_dump: ecoff_reg_to_regnum = <0x556fd321b930>
gdbarch_dump: gdbarch_elf_make_msymbol_special_p() = 0
gdbarch_dump: elf_make_msymbol_special = <0x0>
gdbarch_dump: execute_dwarf_cfa_vendor_op = <0x556fd321b980>
gdbarch_dump: fast_tracepoint_valid_at = <0x556fd3366ee0>
gdbarch_dump: gdbarch_fetch_pointer_argument_p() = 1
gdbarch_dump: fetch_pointer_argument = <0x556fd33646d0>
gdbarch_dump: gdbarch_fetch_tls_load_module_address_p() = 1
gdbarch_dump: fetch_tls_load_module_address = <0x556fd348c970>
gdbarch_dump: gdbarch_find_memory_regions_p() = 1
gdbarch_dump: find_memory_regions = <0x556fd33b5100>
gdbarch_dump: float_bit = 32
gdbarch_dump: float_format = floatformat_ieee_single_big
gdbarch_dump: floatformat_for_type = <0x556fd33657e0>
gdbarch_dump: fp0_regnum = 24
gdbarch_dump: gdbarch_frame_align_p() = 1
gdbarch_dump: frame_align = <0x556fd3215d50>
gdbarch_dump: frame_args_skip = 0x8
gdbarch_dump: gdbarch_frame_num_args_p() = 0
gdbarch_dump: frame_num_args = <0x0>
gdbarch_dump: frame_red_zone_size = 128
gdbarch_dump: gcc_target_options = <0x556fd321ca10>
gdbarch_dump: gdbarch_gcore_bfd_target_p() = 0
gdbarch_dump: gcore_bfd_target = (null)
gdbarch_dump: gdbarch_gdb_signal_from_target_p() = 1
gdbarch_dump: gdb_signal_from_target = <0x556fd33b3870>
gdbarch_dump: gdbarch_gdb_signal_to_target_p() = 1
gdbarch_dump: gdb_signal_to_target = <0x556fd33b3aa0>
gdbarch_dump: gen_return_address = <0x556fd3215e80>
gdbarch_dump: gdbarch_get_longjmp_target_p() = 1
gdbarch_dump: get_longjmp_target = <0x556fd3216290>
gdbarch_dump: get_pc_address_flags = <0x556fd321cca0>
gdbarch_dump: gdbarch_get_siginfo_type_p() = 1
gdbarch_dump: get_siginfo_type = <0x556fd3361a20>
gdbarch_dump: gdbarch_get_syscall_number_p() = 1
gdbarch_dump: get_syscall_number = <0x556fd3214b80>
gdbarch_dump: gdbarch_get_thread_local_address_p() = 0
gdbarch_dump: get_thread_local_address = <0x0>
gdbarch_dump: gnu_triplet_regexp = <0x556fd3362d30>
gdbarch_dump: guess_tracepoint_registers = <0x556fd321cac0>
gdbarch_dump: half_bit = 16
gdbarch_dump: half_format = floatformat_ieee_half_big
gdbarch_dump: gdbarch_handle_segmentation_fault_p() = 1
gdbarch_dump: handle_segmentation_fault = <0x556fd3361830>
gdbarch_dump: has_dos_based_file_system = 0
gdbarch_dump: has_global_breakpoints = 0
gdbarch_dump: has_global_solist = 0
gdbarch_dump: has_shared_address_space = <0x556fd33b7420>
gdbarch_dump: have_nonsteppable_watchpoint = 0
gdbarch_dump: in_indirect_branch_thunk = <0x556fd3215d60>
gdbarch_dump: in_solib_return_trampoline = <0x556fd321b8c0>
gdbarch_dump: infcall_mmap = <0x556fd33b3dd0>
gdbarch_dump: infcall_munmap = <0x556fd33b3cd0>
gdbarch_dump: gdbarch_info_proc_p() = 1
gdbarch_dump: info_proc = <0x556fd33b7650>
gdbarch_dump: inner_than = <0x556fd321b8f0>
gdbarch_dump: insn_is_call = <0x556fd3215e70>
gdbarch_dump: insn_is_jump = <0x556fd3215e50>
gdbarch_dump: insn_is_ret = <0x556fd3215e60>
gdbarch_dump: int_bit = 32
gdbarch_dump: gdbarch_integer_to_address_p() = 0
gdbarch_dump: integer_to_address = <0x0>
gdbarch_dump: iterate_over_objfiles_in_search_order = <0x556fd348af20>
gdbarch_dump: gdbarch_iterate_over_regset_sections_p() = 1
gdbarch_dump: iterate_over_regset_sections = <0x556fd3212a70>
gdbarch_dump: long_bit = 64
gdbarch_dump: long_double_bit = 128
gdbarch_dump: long_double_format = floatformat_i387_ext
gdbarch_dump: long_long_bit = 64
gdbarch_dump: gdbarch_make_corefile_notes_p() = 1
gdbarch_dump: make_corefile_notes = <0x556fd33b6010>
gdbarch_dump: make_symbol_special = <0x556fd321b950>
gdbarch_dump: gdbarch_max_insn_length_p() = 1
gdbarch_dump: max_insn_length = 16
gdbarch_dump: memory_insert_breakpoint = <0x556fd33d6910>
gdbarch_dump: memory_remove_breakpoint = <0x556fd33d6a00>
gdbarch_dump: num_pseudo_regs = 52
gdbarch_dump: num_regs = 155
gdbarch_dump: osabi = 5
gdbarch_dump: gdbarch_overlay_update_p() = 0
gdbarch_dump: overlay_update = <0x0>
gdbarch_dump: pc_regnum = 16
gdbarch_dump: pointer_to_address = <0x556fd3327870>
gdbarch_dump: print_auxv_entry = <0x556fd3225780>
gdbarch_dump: print_float_info = <0x556fd3370250>
gdbarch_dump: print_insn = <0x556fd3366e80>
gdbarch_dump: print_registers_info = <0x556fd337b1d0>
gdbarch_dump: gdbarch_print_vector_info_p() = 0
gdbarch_dump: print_vector_info = <0x0>
gdbarch_dump: gdbarch_process_record_p() = 1
gdbarch_dump: process_record = <0x556fd336a8e0>
gdbarch_dump: gdbarch_process_record_signal_p() = 1
gdbarch_dump: process_record_signal = <0x556fd3214aa0>
gdbarch_dump: ps_regnum = 17
gdbarch_dump: gdbarch_pseudo_register_read_p() = 0
gdbarch_dump: pseudo_register_read = <0x0>
gdbarch_dump: gdbarch_pseudo_register_read_value_p() = 1
gdbarch_dump: pseudo_register_read_value = <0x556fd3216c30>
gdbarch_dump: gdbarch_pseudo_register_write_p() = 1
gdbarch_dump: pseudo_register_write = <0x556fd32169f0>
gdbarch_dump: ptr_bit = 64
gdbarch_dump: gdbarch_push_dummy_call_p() = 1
gdbarch_dump: push_dummy_call = <0x556fd3218080>
gdbarch_dump: gdbarch_push_dummy_code_p() = 1
gdbarch_dump: push_dummy_code = <0x556fd3362d10>
gdbarch_dump: ravenscar_ops = 0x0
gdbarch_dump: gdbarch_read_pc_p() = 0
gdbarch_dump: read_pc = <0x0>
gdbarch_dump: gdbarch_record_special_symbol_p() = 0
gdbarch_dump: record_special_symbol = <0x0>
gdbarch_dump: register_name = <0x556fd34c4fa0>
gdbarch_dump: register_reggroup_p = <0x556fd3215550>
gdbarch_dump: register_sim_regno = <0x556fd321b810>
gdbarch_dump: register_to_value = <0x556fd3370e00>
gdbarch_dump: gdbarch_register_type_p() = 1
gdbarch_dump: register_type = <0x556fd34c4a40>
gdbarch_dump: gdbarch_relocate_instruction_p() = 1
gdbarch_dump: relocate_instruction = <0x556fd3215ee0>
gdbarch_dump: remote_register_number = <0x556fd34c4990>
gdbarch_dump: return_in_first_hidden_param_p = <0x556fd321c920>
gdbarch_dump: gdbarch_return_value_p() = 1
gdbarch_dump: return_value = <0x556fd3217740>
gdbarch_dump: sdb_reg_to_regnum = <0x556fd3368e20>
gdbarch_dump: short_bit = 16
gdbarch_dump: significant_addr_bit = 0
gdbarch_dump: gdbarch_single_step_through_delay_p() = 0
gdbarch_dump: single_step_through_delay = <0x0>
gdbarch_dump: gdbarch_skip_entrypoint_p() = 0
gdbarch_dump: skip_entrypoint = <0x0>
gdbarch_dump: gdbarch_skip_main_prologue_p() = 0
gdbarch_dump: skip_main_prologue = <0x0>
gdbarch_dump: skip_permanent_breakpoint = <0x556fd321c960>
gdbarch_dump: skip_prologue = <0x556fd3218c70>
gdbarch_dump: skip_solib_resolver = <0x556fd3359bf0>
gdbarch_dump: skip_trampoline_code = <0x556fd33f1ea0>
gdbarch_dump: gdbarch_software_single_step_p() = 0
gdbarch_dump: software_single_step = <0x0>
gdbarch_dump: sofun_address_maybe_missing = 0
gdbarch_dump: solib_symbols_extension = (null)
gdbarch_dump: sp_regnum = 7
gdbarch_dump: stab_reg_to_regnum = <0x556fd32167a0>
gdbarch_dump: stabs_argument_has_addr = <0x556fd321bb10>
gdbarch_dump: stack_frame_destroyed_p = <0x556fd321b8d0>
gdbarch_dump: gdbarch_stap_adjust_register_p() = 0
gdbarch_dump: stap_adjust_register = <0x0>
gdbarch_dump: stap_gdb_register_prefix = (null)
gdbarch_dump: stap_gdb_register_suffix = (null)
gdbarch_dump: stap_integer_prefixes = $, 
gdbarch_dump: stap_integer_suffixes = (null)
gdbarch_dump: gdbarch_stap_is_single_operand_p() = 1
gdbarch_dump: stap_is_single_operand = <0x556fd33633f0>
gdbarch_dump: gdbarch_stap_parse_special_token_p() = 1
gdbarch_dump: stap_parse_special_token = <0x556fd3363d60>
gdbarch_dump: stap_register_indirection_prefixes = (, 
gdbarch_dump: stap_register_indirection_suffixes = ), 
gdbarch_dump: stap_register_prefixes = %, 
gdbarch_dump: stap_register_suffixes = (null)
gdbarch_dump: gdbarch_static_transform_name_p() = 0
gdbarch_dump: static_transform_name = <0x0>
gdbarch_dump: sw_breakpoint_from_kind = <0x556fd3362d50>
gdbarch_dump: syscalls_info = 0x0
gdbarch_dump: target_desc = 0x556fd4090fd0
gdbarch_dump: type_align = <0x556fd3365890>
gdbarch_dump: unwind_pc = <0x556fd3365070>
gdbarch_dump: unwind_sp = <0x556fd33297d0>
gdbarch_dump: valid_disassembler_options = 0x0
gdbarch_dump: value_from_register = <0x556fd3327a80>
gdbarch_dump: value_to_register = <0x556fd3370f40>
gdbarch_dump: vbit_in_delta = 0
gdbarch_dump: virtual_frame_pointer = <0x556fd321b9a0>
gdbarch_dump: vsyscall_range = <0x556fd33b5150>
gdbarch_dump: vtable_function_descriptors = 0
gdbarch_dump: wchar_bit = 32
gdbarch_dump: wchar_signed = 1
gdbarch_dump: gdbarch_write_pc_p() = 1
gdbarch_dump: write_pc = <0x556fd3214c00>
gdbarch_dump: xml_syscall_file = syscalls/amd64-linux.xml
gdbarch_update_p: New architecture 0x556fd40dfed0 (i386:x86-64) selected
remote:target_xfer_partial (6, (null), 0x556fd408fd90, 0x0, 0x0, 4096) = -1, 0
Sending packet: $qTStatus#49...Packet received: 
Packet qTStatus (trace-status) is NOT supported
Sending packet: $?#3f...Packet received: S05
Sending packet: $qfThreadInfo#bb...Packet received: mp01.01
Sending packet: $qsThreadInfo#c8...Packet received: l
Sending packet: $qAttached:1#fa...Packet received: 1
Packet qAttached (query-attached) is supported
Sending packet: $Hc-1#09...Packet received: OK
Sending packet: $qC#b4...Packet received: 
warning: couldn't determine remote current thread; picking first in list.
Sending packet: $qOffsets#4b...Packet received: Text=40003cf2b000;Data=40003cf2b000;Bss=40003cf2b000
Sending packet: $g#67...Packet received: 0000000000000000000000000000000030bc493d00400000160000000000000049ce403d00400000308d423e00400000f08f423e00400000004a393e0040000000000000000000000000000000000000a83a393e00400000a6000000000000000100000000000000010000000000000004000000000000005403203f000000000392093d004000000600000008000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f0300000000000000000000[608 bytes omitted]
target_fetch_registers (rip) = 0392093d00400000 0x40003d099203 70369768215043
remote:target_xfer_partial (6, (null), 0x556fd408fd90, 0x0, 0x0, 4096) = -1, 0
remote:target_xfer_partial (12, (null), 0x556fd408fd90, 0x0, 0x0, 4096) = -1, 0
remote:target_xfer_partial (8, (null), 0x556fd485d880, 0x0, 0x0, 4096) = -1, 0
Sending packet: $m578f50,8#40...Packet received: 0000000000000000
remote:target_xfer_partial (1, (null), 0x7fff771efab0, 0x0, 0x578f50, 8) = 1, 8, bytes =
 00 00 00 00 00 00 00 00
Sending packet: $vFile:setfs:0#bf...Packet received: 
Packet vFile:setfs (hostio-setfs) is NOT supported
Sending packet: $vFile:open:6a7573742070726f62696e67,0,1c0#ed...Packet received: 
Packet vFile:open (hostio-open) is NOT supported
warning: remote target does not support file transfer, attempting to access files from local filesystem.
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
Sending packet: $qfThreadInfo#bb...Packet received: mp01.01
Sending packet: $qsThreadInfo#c8...Packet received: l
Sending packet: $m40003d099203,1#5c...Packet received: e8
remote:target_xfer_partial (1, (null), 0x7fff771ef987, 0x0, 0x40003d099203, 1) = 1, 1, bytes = e8
Sending packet: $m40003d099203,1#5c...Packet received: e8
remote:target_xfer_partial (1, (null), 0x7fff771ef987, 0x0, 0x40003d099203, 1) = 1, 1, bytes = e8
nrk::arch::_start (Sending packet: $m40003e428de0,8#c4...Packet received: 0070123e00400000
remote:target_xfer_partial (1, (null), 0x556fd4088ec0, 0x0, 0x40003e428de0, 8) = 1, 8, bytes =
 00 70 12 3e 00 40 00 00
argc=70369785573376, Sending packet: $m40003e428de8,8#cc...Packet received: 0900000000000000
remote:target_xfer_partial (1, (null), 0x556fd4088d80, 0x0, 0x40003e428de8, 8) = 1, 8, bytes =
 09 00 00 00 00 00 00 00
_argv=0x9) at kernel/src/arch/x86_64/mod.rs:801
801	    let _r = xmain();
Sending packet: $qSymbol::#5b...Packet received: 
Packet qSymbol (symbol-lookup) is NOT supported
<- remote->open (localhost:1234, 0)
(gdb) step
Sending packet: $vCont?#49...Packet received: vCont;c;C;s;S
Packet vCont (verbose-resume) is supported
Sending packet: $vCont;s:p1.1;c:p1.-1#f7...Packet received: S05
Sending packet: $g#67...Packet received: 0000000000000000000000000000000030bc493d00400000160000000000000049ce403d00400000308d423e00400000f08f423e00400000f849393e0040000000000000000000000000000000000000a83a393e00400000a6000000000000000100000000000000010000000000000004000000000000005403203f0000000040dc013d004000000601000008000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f0300000000000000000000[608 bytes omitted]
target_fetch_registers (rip) = 40dc013d00400000 0x40003d01dc40 70369767709760
Sending packet: $m40003d01dc40,1#b1...Packet received: 55
remote:target_xfer_partial (1, (null), 0x7fff771efb87, 0x0, 0x40003d01dc40, 1) = 1, 1, bytes = 55
Sending packet: $m40003d01dc40,1#b1...Packet received: 55
remote:target_xfer_partial (1, (null), 0x7fff771efb87, 0x0, 0x40003d01dc40, 1) = 1, 1, bytes = 55
Sending packet: $m40003e3949c0,40#c5...Packet received: 0449393e00400000041300000000000049ce403d004000001600000000000000800d3b3e00400000800d3b3e00400000f08f423e004000000892093d00400000
remote:target_xfer_partial (2, (null), 0x556fd485e90c, 0x0, 0x40003e3949c0, 64) = 1, 64, bytes = 04 49 39 3e ...
remote:target_xfer_partial (3, (null), 0x556fd49d1d40, 0x0, 0x40003e3949f8, 8) = 1, 8, bytes =
 08 92 09 3d 00 40 00 00
remote:target_xfer_partial (3, (null), 0x556fd49d1d40, 0x0, 0x40003e3949f8, 8) = 1, 8, bytes =
 08 92 09 3d 00 40 00 00
Sending packet: $m40003d01dc4b,1#e3...Packet received: 48
remote:target_xfer_partial (1, (null), 0x7fff771ef8a0, 0x0, 0x40003d01dc4b, 1) = 1, 1, bytes =
 48
Sending packet: $Z0,40003d01dc4b,1#2c...Packet received: 
Packet Z0 (software-breakpoint) is NOT supported
Sending packet: $m40003d01dc4b,1#e3...Packet received: 48
remote:target_xfer_partial (1, (null), 0x7fff771ef8c0, 0x0, 0x40003d01dc4b, 1) = 1, 1, bytes =
 48
Sending packet: $X40003d01dc4b,0:#07...Packet received: 
binary downloading NOT supported by target
Sending packet: $M40003d01dc4b,1:cc#c3...Packet received: OK
remote:target_xfer_partial (2, (null), 0x0, 0x556fd3689d40, 0x40003d01dc4b, 1) = 1, 1, bytes =
 cc
Sending packet: $vCont;c:p1.-1#0f...Packet received: T05thread:p01.01;hwbreak:;
Sending packet: $g#67...Packet received: 0000000000000000000000000000000030bc493d00400000160000000000000049ce403d00400000308d423e00400000f049393e004000000048393e0040000000000000000000000000000000000000a83a393e00400000a6000000000000000100000000000000010000000000000004000000000000005403203f000000004cdc013d004000000600000008000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f0300000000000000000000[608 bytes omitted]
target_fetch_registers (rip) = 4cdc013d00400000 0x40003d01dc4c 70369767709772
Sending packet: $P10=4bdc013d00400000#c7...Packet received: OK
Packet P (set-register) is supported
target_store_registers (rip) = 4bdc013d00400000 0x40003d01dc4b 70369767709771
Sending packet: $P39=ffffffffffffffff#59...Packet received: 
Sending packet: $M40003d01dc4b,1:48#69...Packet received: OK
remote:target_xfer_partial (2, (null), 0x0, 0x556fd421fdc4, 0x40003d01dc4b, 1) = 1, 1, bytes = 48
Protocol error: P (set-register) conflicting enabled responses.
(gdb) 

from gdbstub.

gz avatar gz commented on May 5, 2024

Now that I look at it, this might be due to the osabi in the elf file...

gdbarch_find_by_info: info.osabi 5 (GNU/Linux)
gdbarch_find_by_info: info.abfd 0x556fd3f9f2d0
gdbarch_find_by_info: info.tdep_info 0x0
gdbarch_find_by_info: New architecture 0x556fd40dfed0 (i386:x86-64) selected
gdbarch_dump: GDB_NM_FILE = config/nm-linux.h

from gdbstub.

daniel5151 avatar daniel5151 commented on May 5, 2024

Ahh, interesting.

That would line up with your earlier guess that this might be related to https://github.com/bminor/binutils-gdb/blob/master/gdb/features/i386/64bit-linux.xml#L10, given that the value being written in a 64-bit 0xffffffffffffffff.

What happens if you run set osabi none prior to stepping?

from gdbstub.

daniel5151 avatar daniel5151 commented on May 5, 2024

Any update on this?

from gdbstub.

gz avatar gz commented on May 5, 2024

Thanks that's helpful!

It was surprising to learn that it would still go off and insert int3 instructions in random locations (without software breakpoints enabled). But, implementing SwBreak by using hardware breakpoints is a good idea :)!

from gdbstub.

daniel5151 avatar daniel5151 commented on May 5, 2024

Indeed, it is very surprising! This is actually something xobs came across in #56 (comment), and is definitely something I'll need to clarify in the documentation. It's quite the footgun!


Note that you may be able to force the GDB client to automatically use hardware breakpoints by implementing the SwBreakpoints IDET to always return Ok(false) (or possibly returning an Err or some kind). This may result in the GDB client falling back to trying to set a hwbreak.

Strong emphasis on the may, as this behavior is very much up to the whims of the GDB client implementation, and nailing down the precise behavior will require some experimentation and/or reading through the GDB client source.

from gdbstub.

gz avatar gz commented on May 5, 2024

Ah good point, I'll try that and report back :)

from gdbstub.

daniel5151 avatar daniel5151 commented on May 5, 2024

I know this issue got a bit sidetracked, so lets refocus and understand the heart of the issue:

Were you able to figure out why your particular target / arch / binary was requesting that extra register?

from gdbstub.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.