Coder Social home page Coder Social logo

Comments (6)

xobs avatar xobs commented on June 20, 2024 1

Well, there's a bit more nuance here: the correct response of vAttach is any valid Stop Reason - not just those two.

True, but it's unclear exactly what registers are required, and gdb gets upset if you omit those registers. It also gets grumpy if you don't enumerate all the threads properly, and replying with S00 tells it to ask for that information separately.

from gdbstub.

xobs avatar xobs commented on June 20, 2024

(It's also interesting to note that because gdbstub doesn't support having no process active, it necessarily asks "A program is being debugged already. Kill it? (y or n)", but gdbserver supports having no process active, and therefore does not ask that question.)

from gdbstub.

daniel5151 avatar daniel5151 commented on June 20, 2024

I took a gander at the code, and it seems we're returning a HandlerStatus::Handled instead of a HandlerStatus::DeferredStopReason from the ExtendedMode::vAttach handler:

HandlerStatus::Handled

Can you change that line and see if it helps?

from gdbstub.

xobs avatar xobs commented on June 20, 2024

A few notes:

  1. The correct return for vAttach is S00 (or T00......), which does work!
(gdb) att 2
Attaching to program: E:\Code\Xous\Core\target\riscv32imac-unknown-xous-elf\release\xous-ticktimer, process 2
[remote] Sending packet: $vAttach;2#38
[remote] Packet received: S00
[remote] packet_ok: Packet vAttach (attach) is supported
  1. We need to handle qC, and this response must return the PID requested (i.e. we can't unilaterally use FAKE_PID):

FAKE_PID:

[remote] Sending packet: $vAttach;2#38
[remote] Packet received: S00
[remote] packet_ok: Packet vAttach (attach) is supported
[remote] Sending packet: $qC#b4
[remote] Packet received: QCp01.02
/__w/riscv-none-elf-gcc-xpack/riscv-none-elf-gcc-xpack/build/win32-x64/sources/gdb-12.1/gdb/thread.c:530: internal-error: find_thread_ptid: Assertion `inf != nullptr' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) y

Actual PID (i.e. 2):

(gdb) att 2
Attaching to program: E:\Code\Xous\Core\target\riscv32imac-unknown-xous-elf\release\xous-ticktimer, process 2
[remote] Sending packet: $vAttach;2#38
[remote] Packet received: S00
[remote] packet_ok: Packet vAttach (attach) is supported
[remote] Sending packet: $qC#b4
[remote] Packet received: QCp02.02
[remote] Sending packet: $Hgp2.2#b1
[remote] Packet received: OK

I've added a new function to MultiThreadBase that allows me to get the current active PID, and with that I'm now able to switch processes by using attach [PID].

The result of this is in #129

from gdbstub.

daniel5151 avatar daniel5151 commented on June 20, 2024
  1. The correct return for vAttach is S00 (or T00......), which does work!

Well, there's a bit more nuance here: the correct response of vAttach is any valid Stop Reason - not just those two.

2. We need to handle qC, and this response must return the PID requested (i.e. we can't unilaterally use FAKE_PID):

Indeed, I'm not surprised that GDB gets angry if you give it back a thread-id it's not expecting...


Will continue the discussion over on #129 itself

from gdbstub.

daniel5151 avatar daniel5151 commented on June 20, 2024

Closed via #129

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.