Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make QStartNoAckMode optional #134

Closed
bet4it opened this issue Mar 28, 2023 · 1 comment · Fixed by #135
Closed

Make QStartNoAckMode optional #134

bet4it opened this issue Mar 28, 2023 · 1 comment · Fixed by #135
Labels
API-non-breaking Non-breaking API change new-api Add a new feature to the API (possibly non-breaking)

Comments

@bet4it
Copy link
Contributor

bet4it commented Mar 28, 2023

I want to use IDA Pro as a GDB client to connect the example program in my project udbserver:

$ cargo run --example server

IDA Pro asked me the PID to attach to, and failed to attach after I provided a pid:

 TRACE gdbstub::protocol::recv_packet > <-- +
 TRACE gdbstub::protocol::recv_packet > <-- $qSupported:xmlRegisters=i386,arm,mips#12
 TRACE gdbstub::protocol::response_writer > --> $PacketSize=1000;vContSupported+;multiprocess+;QStartNoAckMode+;swbreak+;hwbreak+;qXfer:features:read+#47
 TRACE gdbstub::protocol::recv_packet     > <-- +
 TRACE gdbstub::protocol::recv_packet     > <-- $QStartNoAckMode#b0
 TRACE gdbstub::protocol::response_writer > --> $OK#9a
 TRACE gdbstub::protocol::recv_packet     > <-- $!#21
 INFO  gdbstub::stub::core_impl           > Unknown command: Ok("!")
 TRACE gdbstub::protocol::response_writer > --> $#00
 TRACE gdbstub::protocol::recv_packet     > <-- $Hg0#df
 TRACE gdbstub::protocol::response_writer > --> $OK#9a
 TRACE gdbstub::protocol::recv_packet     > <-- $qXfer:features:read:target.xml:0,fff#7d
 TRACE gdbstub::protocol::response_writer > --> $m
        <target version="1.0">
            <architecture>arm</architecture>
            <feature name="org.gnu.gdb.arm.core">
              <reg name="r0" bitsize="32" type="uint32"/>
              <reg name="r1" bitsize="32" type="uint32"/>
              <reg name="r2" bitsize="32" type="uint32"/>
              <reg name="r3" bitsize="32" type="uint32"/>
              <reg name="r4" bitsize="32" type="uint32"/>
              <reg name="r5" bitsize="32" type="uint32"/>
              <reg name="r6" bitsize="32" type="uint32"/>
              <reg name="r7" bitsize="32" type="uint32"/>
              <reg name="r8" bitsize="32" type="uint32"/>
              <reg name="r9" bitsize="32" type="uint32"/>
              <reg name="r10" bitsize="32" type="uint32"/>
              <reg name="r11" bitsize="32" type="uint32"/>
              <reg name="r12" bitsize="32" type="uint32"/>
              <reg name="sp" bitsize="32" type="data_ptr"/>
              <reg name="lr" bitsize="32"/>
              <reg name="pc" bitsize="32" type="code_ptr"/>
              <reg name="cpsr" bitsize="32"/>
            </feature>
        </target>
    #5f
 TRACE gdbstub::protocol::recv_packet     > <-- $?#3f
 TRACE gdbstub::protocol::response_writer > --> $T05thread:01;#07
 TRACE gdbstub::protocol::recv_packet     > <-- $vAttach;1#37
 INFO  gdbstub::stub::core_impl           > Unknown command: Ok("vAttach;1")
 TRACE gdbstub::protocol::response_writer > --> $#00

But if QStartNoAckMode is disabled, IDA Pro won't ask for the PID and everything works well:

 TRACE gdbstub::protocol::recv_packet > <-- +
 TRACE gdbstub::protocol::recv_packet > <-- $qSupported:xmlRegisters=i386,arm,mips#12
 TRACE gdbstub::protocol::response_writer > --> $PacketSize=1000;vContSupported+;multiprocess+;swbreak+;hwbreak+;qXfer:features:read+#31
 TRACE gdbstub::protocol::recv_packet     > <-- +
 TRACE gdbstub::protocol::recv_packet     > <-- $!#21
 INFO  gdbstub::stub::core_impl           > Unknown command: Ok("!")
 TRACE gdbstub::protocol::response_writer > --> $#00
 TRACE gdbstub::protocol::recv_packet     > <-- +
 TRACE gdbstub::protocol::recv_packet     > <-- $Hg0#df
 TRACE gdbstub::protocol::response_writer > --> $OK#9a
 TRACE gdbstub::protocol::recv_packet     > <-- +
 TRACE gdbstub::protocol::recv_packet     > <-- $qXfer:features:read:target.xml:0,fff#7d
 TRACE gdbstub::protocol::response_writer > --> $m
        <target version="1.0">
            <architecture>arm</architecture>
            <feature name="org.gnu.gdb.arm.core">
              <reg name="r0" bitsize="32" type="uint32"/>
              <reg name="r1" bitsize="32" type="uint32"/>
              <reg name="r2" bitsize="32" type="uint32"/>
              <reg name="r3" bitsize="32" type="uint32"/>
              <reg name="r4" bitsize="32" type="uint32"/>
              <reg name="r5" bitsize="32" type="uint32"/>
              <reg name="r6" bitsize="32" type="uint32"/>
              <reg name="r7" bitsize="32" type="uint32"/>
              <reg name="r8" bitsize="32" type="uint32"/>
              <reg name="r9" bitsize="32" type="uint32"/>
              <reg name="r10" bitsize="32" type="uint32"/>
              <reg name="r11" bitsize="32" type="uint32"/>
              <reg name="r12" bitsize="32" type="uint32"/>
              <reg name="sp" bitsize="32" type="data_ptr"/>
              <reg name="lr" bitsize="32"/>
              <reg name="pc" bitsize="32" type="code_ptr"/>
              <reg name="cpsr" bitsize="32"/>
            </feature>
        </target>
    #5f
 TRACE gdbstub::protocol::recv_packet     > <-- $?#3f
 TRACE gdbstub::protocol::response_writer > --> $T05thread:01;#07
 TRACE gdbstub::protocol::recv_packet     > <-- +
 TRACE gdbstub::protocol::recv_packet     > <-- $?#3f
 TRACE gdbstub::protocol::response_writer > --> $T05thread:01;#07
 TRACE gdbstub::protocol::recv_packet     > <-- +
 TRACE gdbstub::protocol::recv_packet     > <-- $qfThreadInfo#bb
 TRACE gdbstub::protocol::response_writer > --> $m01#ce
 TRACE gdbstub::protocol::recv_packet     > <-- +
 TRACE gdbstub::protocol::recv_packet     > <-- $qsThreadInfo#c8
 TRACE gdbstub::protocol::response_writer > --> $l#6c
 TRACE gdbstub::protocol::recv_packet     > <-- +
 TRACE gdbstub::protocol::recv_packet     > <-- $g#67
 TRACE gdbstub::protocol::response_writer > --> $00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000d3010040#ce
 TRACE gdbstub::protocol::recv_packet     > <-- +
 TRACE gdbstub::protocol::recv_packet     > <-- $qXfer:features:read:target.xml:0,fff#7d
 TRACE gdbstub::protocol::response_writer > --> $m
        <target version="1.0">
            <architecture>arm</architecture>
            <feature name="org.gnu.gdb.arm.core">
              <reg name="r0" bitsize="32" type="uint32"/>
              <reg name="r1" bitsize="32" type="uint32"/>
              <reg name="r2" bitsize="32" type="uint32"/>
              <reg name="r3" bitsize="32" type="uint32"/>
              <reg name="r4" bitsize="32" type="uint32"/>
              <reg name="r5" bitsize="32" type="uint32"/>
              <reg name="r6" bitsize="32" type="uint32"/>
              <reg name="r7" bitsize="32" type="uint32"/>
              <reg name="r8" bitsize="32" type="uint32"/>
              <reg name="r9" bitsize="32" type="uint32"/>
              <reg name="r10" bitsize="32" type="uint32"/>
              <reg name="r11" bitsize="32" type="uint32"/>
              <reg name="r12" bitsize="32" type="uint32"/>
              <reg name="sp" bitsize="32" type="data_ptr"/>
              <reg name="lr" bitsize="32"/>
              <reg name="pc" bitsize="32" type="code_ptr"/>
              <reg name="cpsr" bitsize="32"/>
            </feature>
        </target>
    #5f
 TRACE gdbstub::protocol::recv_packet     > <-- $pf#d6
 TRACE gdbstub::protocol::response_writer > --> $00100000#0c
 TRACE gdbstub::protocol::recv_packet     > <-- +
 TRACE gdbstub::protocol::recv_packet     > <-- $g#67
 TRACE gdbstub::protocol::response_writer > --> $00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000d3010040#ce
 TRACE gdbstub::protocol::recv_packet     > <-- +

Should we make QStartNoAckMode optional to support IDA Pro? Do we have other ways to solve it?

@daniel5151
Copy link
Owner

Sure, I wouldn't opposed to merging something like Target::supports_no_ack_mode (along the same lines as Target::supports_x_packet) that lets the target dictate whether it wants to support no ack mode.

Shouldn't be too hard to do, if you want to send a PR for it?


Though for what it's worth: that behavior doesn't seem like a gdbstub bug per-se. It seems IDA is making some weird assumptions about how GDB targets behave...

Maybe it assumes that bare-metal targets are typically debugged over serial, and therefore would use ack packets, and hence wouldn't support vAttach?

@daniel5151 daniel5151 added API-non-breaking Non-breaking API change new-api Add a new feature to the API (possibly non-breaking) labels Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API-non-breaking Non-breaking API change new-api Add a new feature to the API (possibly non-breaking)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants