Giter Site home page Giter Site logo

Comments (5)

bet4it avatar bet4it commented on May 5, 2024 2

You could use into:

let reason = StopReason::DoneStep;
match gdb_inner.deferred_stop_reason(emu, reason.into())? {
    ...
}

from gdbstub.

daniel5151 avatar daniel5151 commented on May 5, 2024 1

If you peek under-the-hood of gdbstub, you'll find that singlethread::StopReason gets converted into a multithread::ThreadStopReason with a constant SINGLE_THREAD_TID:

use crate::target::ext::base::singlethread::StopReason;
impl<U> From<StopReason<U>> for ThreadStopReason<U> {
fn from(st_stop_reason: StopReason<U>) -> ThreadStopReason<U> {
match st_stop_reason {
StopReason::DoneStep => ThreadStopReason::DoneStep,
StopReason::GdbInterrupt => ThreadStopReason::GdbInterrupt,
StopReason::Exited(code) => ThreadStopReason::Exited(code),
StopReason::Terminated(sig) => ThreadStopReason::Terminated(sig),
StopReason::SwBreak => ThreadStopReason::SwBreak(SINGLE_THREAD_TID),
StopReason::HwBreak => ThreadStopReason::HwBreak(SINGLE_THREAD_TID),
StopReason::Watch { kind, addr } => ThreadStopReason::Watch {
tid: SINGLE_THREAD_TID,
kind,
addr,
},
StopReason::Signal(sig) => ThreadStopReason::Signal(sig),
StopReason::ReplayLog(pos) => ThreadStopReason::ReplayLog(pos),
StopReason::CatchSyscall { number, position } => {
ThreadStopReason::CatchSyscall { number, position }
}
}
}
}

It's been a while since I've hacked on this code directly, but IIRC I couldn't think of a great way to parameterize deferred_stop_reason over single/multi-threaded targets, so I took the "cop out" approach of simply using the more specific multithread::ThreadStopReason type.

That said, after reviewing the code with fresh eyes this morning, I suspect that long-term, I'll actually end up removing singlethread::StopReason entirely, and swapping all APIs over to using a single StopReason type which encodes both the TID, and PID of the stopped thread (in anticipation of eventually supporting multi-process debugging as well).

So, to answer your concrete question: yes, I'm aware of this weird aspect of the API, and I'm planning to solve it in one of two ways:

  1. updating the documentation to make it very clear how to use the state machine with single-threaded targets
  2. making the point moot by removing "singlethread::StopReason" type entirely (along with any requisite doc changes)

from gdbstub.

gz avatar gz commented on May 5, 2024 1

Great, thanks for clarifying!

from gdbstub.

gz avatar gz commented on May 5, 2024

agreed I didn't see the into() implementation. What was mainly confusing here for me was that in the single-threaded API there was a type from crate::target::ext::base::multithread. But I suppose that Daniels refactoring will probably move this type somewhere more general.

from gdbstub.

daniel5151 avatar daniel5151 commented on May 5, 2024

This has been fixed in 2eca733 and a24b724

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.