Greg Kurz <gr...@kaod.org> writes: > On Wed, 31 May 2017 16:09:33 +0100 > Alex Bennée <alex.ben...@linaro.org> wrote: > >> The thread-id of 0 means any CPU but we then ignore the fact we find >> the first_cpu in this case who can have an index of 0. Instead of > > The index can never be 0 in system mode actually, but you're right that this > check doesn't make sense. > > The code still looks a bit convoluted IMHO. What about something like the > following ? > > /* 0 means any thread, so we pick the first valid CPU */ > cpu = tmp ? find_cpu(tmp) : first_cpu; > > /* invalid CPU/thread specified */ > if (!cpu) { > res = -EINVAL; > goto out; > }
Yeah that will make it cleaner, I'll apply to v2. > > Anyway, the fix looks ok. > > Reviewed-by: Greg Kurz <gr...@kaod.org> > >> bailing out just test if we have managed to match up thread-id to a >> CPU. >> >> Otherwise you get: >> gdb_handle_packet: command='vCont;C04:0;c' >> put_packet: reply='E22' >> >> Signed-off-by: Alex Bennée <alex.ben...@linaro.org> >> --- >> gdbstub.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/gdbstub.c b/gdbstub.c >> index a249846954..29c9ed3002 100644 >> --- a/gdbstub.c >> +++ b/gdbstub.c >> @@ -934,8 +934,8 @@ static int gdb_handle_vcont(GDBState *s, const char *p) >> * CPU first, and only then we can use its index. >> */ >> cpu = find_cpu(idx); >> - /* invalid CPU/thread specified */ >> - if (!idx || !cpu) { >> + /* invalid thread specified, cpu not found. */ >> + if (!cpu) { >> res = -EINVAL; >> goto out; >> } -- Alex Bennée