Message ID | 150642388560.3900.1889412060549174598.stgit@Misha-PC.lan02.inno |
---|---|
State | New |
Headers | show |
Series | Windbg supporting | expand |
On Tue, Sep 26, 2017 at 4:04 AM, Mihail Abakumov <mikhail.abakumov@ispras.ru> wrote: > Added chardev for listening to windbg. Target device is a parameter in the '-windbg' option. > > Signed-off-by: Mihail Abakumov <mikhail.abakumov@ispras.ru> > Signed-off-by: Pavel Dovgalyuk <dovgaluk@ispras.ru> > Signed-off-by: Dmitriy Koltunov <koltunov@ispras.ru> Acked-by: Alistair Francis <alistair.francis@xilinx.com> Thanks, Alistair > --- > windbgstub.c | 26 ++++++++++++++++++++++++++ > 1 file changed, 26 insertions(+) > > diff --git a/windbgstub.c b/windbgstub.c > index 60a380c213..378d1b911f 100755 > --- a/windbgstub.c > +++ b/windbgstub.c > @@ -10,6 +10,7 @@ > */ > > #include "qemu/osdep.h" > +#include "qapi/error.h" > #include "chardev/char.h" > #include "chardev/char-fe.h" > #include "exec/windbgstub.h" > @@ -18,12 +19,26 @@ > typedef struct WindbgState { > bool is_loaded; > > + CharBackend chr; > + > uint32_t ctrl_packet_id; > uint32_t data_packet_id; > } WindbgState; > > static WindbgState *windbg_state; > > +static int windbg_chr_can_receive(void *opaque) > +{ > + return PACKET_MAX_SIZE; > +} > + > +static void windbg_chr_receive(void *opaque, const uint8_t *buf, int size) > +{ > + if (windbg_state->is_loaded) { > + /* T0D0: parse data */ > + } > +} > + > static void windbg_exit(void) > { > g_free(windbg_state); > @@ -31,6 +46,8 @@ static void windbg_exit(void) > > int windbg_server_start(const char *device) > { > + Chardev *chr = NULL; > + > if (windbg_state) { > WINDBG_ERROR("Multiple instances are not supported"); > exit(1); > @@ -40,6 +57,15 @@ int windbg_server_start(const char *device) > windbg_state->ctrl_packet_id = RESET_PACKET_ID; > windbg_state->data_packet_id = INITIAL_PACKET_ID; > > + chr = qemu_chr_new_noreplay(WINDBG, device); > + if (!chr) { > + return -1; > + } > + > + qemu_chr_fe_init(&windbg_state->chr, chr, &error_abort); > + qemu_chr_fe_set_handlers(&windbg_state->chr, windbg_chr_can_receive, > + windbg_chr_receive, NULL, NULL, NULL, NULL, true); > + > atexit(windbg_exit); > return 0; > } > >
On Tue, Sep 26, 2017 at 1:04 PM, Mihail Abakumov <mikhail.abakumov@ispras.ru> wrote: > Added chardev for listening to windbg. Target device is a parameter in the '-windbg' option. > > Signed-off-by: Mihail Abakumov <mikhail.abakumov@ispras.ru> > Signed-off-by: Pavel Dovgalyuk <dovgaluk@ispras.ru> > Signed-off-by: Dmitriy Koltunov <koltunov@ispras.ru> > --- > windbgstub.c | 26 ++++++++++++++++++++++++++ > 1 file changed, 26 insertions(+) > > diff --git a/windbgstub.c b/windbgstub.c > index 60a380c213..378d1b911f 100755 > --- a/windbgstub.c > +++ b/windbgstub.c > @@ -10,6 +10,7 @@ > */ > > #include "qemu/osdep.h" > +#include "qapi/error.h" > #include "chardev/char.h" > #include "chardev/char-fe.h" > #include "exec/windbgstub.h" > @@ -18,12 +19,26 @@ > typedef struct WindbgState { > bool is_loaded; > > + CharBackend chr; > + > uint32_t ctrl_packet_id; > uint32_t data_packet_id; > } WindbgState; > > static WindbgState *windbg_state; > > +static int windbg_chr_can_receive(void *opaque) > +{ > + return PACKET_MAX_SIZE; > +} > + > +static void windbg_chr_receive(void *opaque, const uint8_t *buf, int size) > +{ > + if (windbg_state->is_loaded) { > + /* T0D0: parse data */ > + } > +} > + > static void windbg_exit(void) > { > g_free(windbg_state); > @@ -31,6 +46,8 @@ static void windbg_exit(void) > > int windbg_server_start(const char *device) > { > + Chardev *chr = NULL; > + > if (windbg_state) { > WINDBG_ERROR("Multiple instances are not supported"); > exit(1); > @@ -40,6 +57,15 @@ int windbg_server_start(const char *device) > windbg_state->ctrl_packet_id = RESET_PACKET_ID; > windbg_state->data_packet_id = INITIAL_PACKET_ID; > > + chr = qemu_chr_new_noreplay(WINDBG, device); > + if (!chr) { This should generate error output. Passing "-windbg bogus" makes QEMU exit silently. -gdb seems to have the same problem. > + return -1; > + } > + > + qemu_chr_fe_init(&windbg_state->chr, chr, &error_abort); > + qemu_chr_fe_set_handlers(&windbg_state->chr, windbg_chr_can_receive, > + windbg_chr_receive, NULL, NULL, NULL, NULL, true); > + > atexit(windbg_exit); > return 0; > } >
Ladi Prosek писал 2017-10-03 14:49: >> >> + chr = qemu_chr_new_noreplay(WINDBG, device); >> + if (!chr) { > > This should generate error output. Passing "-windbg bogus" makes QEMU > exit silently. > -gdb seems to have the same problem. > I added additional checking on chardev. At the moment, supporting only pipe. Thanks, Mihail Abakumov >> + return -1; >> + } >> +
diff --git a/windbgstub.c b/windbgstub.c index 60a380c213..378d1b911f 100755 --- a/windbgstub.c +++ b/windbgstub.c @@ -10,6 +10,7 @@ */ #include "qemu/osdep.h" +#include "qapi/error.h" #include "chardev/char.h" #include "chardev/char-fe.h" #include "exec/windbgstub.h" @@ -18,12 +19,26 @@ typedef struct WindbgState { bool is_loaded; + CharBackend chr; + uint32_t ctrl_packet_id; uint32_t data_packet_id; } WindbgState; static WindbgState *windbg_state; +static int windbg_chr_can_receive(void *opaque) +{ + return PACKET_MAX_SIZE; +} + +static void windbg_chr_receive(void *opaque, const uint8_t *buf, int size) +{ + if (windbg_state->is_loaded) { + /* T0D0: parse data */ + } +} + static void windbg_exit(void) { g_free(windbg_state); @@ -31,6 +46,8 @@ static void windbg_exit(void) int windbg_server_start(const char *device) { + Chardev *chr = NULL; + if (windbg_state) { WINDBG_ERROR("Multiple instances are not supported"); exit(1); @@ -40,6 +57,15 @@ int windbg_server_start(const char *device) windbg_state->ctrl_packet_id = RESET_PACKET_ID; windbg_state->data_packet_id = INITIAL_PACKET_ID; + chr = qemu_chr_new_noreplay(WINDBG, device); + if (!chr) { + return -1; + } + + qemu_chr_fe_init(&windbg_state->chr, chr, &error_abort); + qemu_chr_fe_set_handlers(&windbg_state->chr, windbg_chr_can_receive, + windbg_chr_receive, NULL, NULL, NULL, NULL, true); + atexit(windbg_exit); return 0; }