[Qemu-devel] [PATCH] armv7m: optional -kernel if -gdb present
For standalone emulation, the image must be specified via -kernel, but when using QEMU as a GDB server, the presence of -kernel is no longer mandatory, since the image can be loaded by the GDB client. Signed-off-by: Liviu Ionescu i...@livius.net --- hw/arm/armv7m.c | 3 ++- include/sysemu/sysemu.h | 1 + vl.c| 7 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c index 696de12..9d1669c 100644 --- a/hw/arm/armv7m.c +++ b/hw/arm/armv7m.c @@ -14,6 +14,7 @@ #include sysemu/qtest.h #include qemu/error-report.h #include hw/boards.h +#include sysemu/sysemu.h static struct arm_boot_info armv7m_binfo; @@ -241,7 +242,7 @@ qemu_irq *armv7m_init(MemoryRegion *system_memory, big_endian = 0; #endif -if (!kernel_filename !qtest_enabled()) { +if (!kernel_filename !qtest_enabled() !with_gdb) { fprintf(stderr, Guest image must be specified (using -kernel)\n); exit(1); } diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index c145d94..08bbe71 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -104,6 +104,7 @@ typedef enum DisplayType } DisplayType; extern int autostart; +extern int with_gdb; typedef enum { VGA_NONE, VGA_STD, VGA_CIRRUS, VGA_VMWARE, VGA_XENFB, VGA_QXL, diff --git a/vl.c b/vl.c index a88e5da..4a03fb8 100644 --- a/vl.c +++ b/vl.c @@ -138,6 +138,7 @@ bool enable_mlock = false; int nb_nics; NICInfo nd_table[MAX_NICS]; int autostart; +int with_gdb; static int rtc_utc = 1; static int rtc_date_offset = -1; /* -1 means no change */ QEMUClockType rtc_clock; @@ -2797,6 +2798,7 @@ int main(int argc, char **argv, char **envp) uint64_t ram_slots = 0; FILE *vmstate_dump_file = NULL; Error *main_loop_err = NULL; +with_gdb = false; atexit(qemu_run_exit_notifiers); error_set_progname(argv[0]); @@ -3241,9 +3243,11 @@ int main(int argc, char **argv, char **envp) break; case QEMU_OPTION_s: add_device_config(DEV_GDB, tcp:: DEFAULT_GDBSTUB_PORT); +with_gdb = true; break; case QEMU_OPTION_gdb: add_device_config(DEV_GDB, optarg); +with_gdb = true; break; case QEMU_OPTION_L: if (data_dir_idx ARRAY_SIZE(data_dir)) { @@ -4443,7 +4447,8 @@ int main(int argc, char **argv, char **envp) error_free(local_err); exit(1); } -} else if (autostart) { +} else if (autostart kernel_filename) { +/* If an image is defined and no -S is requested, start it. */ vm_start(); } -- 1.9.3 (Apple Git-50)
Re: [Qemu-devel] [PATCH] armv7m: optional -kernel if -gdb present
On 20 November 2014 12:05, Liviu Ionescu i...@livius.net wrote: For standalone emulation, the image must be specified via -kernel, but when using QEMU as a GDB server, the presence of -kernel is no longer mandatory, since the image can be loaded by the GDB client. I think the correct fix for this issue is: -if (!kernel_filename !qtest_enabled()) { +if (!kernel_filename !qtest_enabled() !with_gdb) { fprintf(stderr, Guest image must be specified (using -kernel)\n); exit(1); } just delete this entire if() statement. This is how we've handled similar issues with the ARM A profile boards. (Some of the boards still have those checks but that's just because nobody's bothered to fix them yet.) thanks -- PMM
Re: [Qemu-devel] [PATCH] armv7m: optional -kernel if -gdb present
On 20 Nov 2014, at 14:29, Peter Maydell peter.mayd...@linaro.org wrote: -if (!kernel_filename !qtest_enabled()) { +if (!kernel_filename !qtest_enabled() !with_gdb) { fprintf(stderr, Guest image must be specified (using -kernel)\n); exit(1); } just delete this entire if() statement. This is how we've handled similar issues with the ARM A profile boards. (Some of the boards still have those checks but that's just because nobody's bothered to fix them yet.) I'm a bit confused. if not running with gdb, what is the expected behaviour if the image is missing? Liviu
Re: [Qemu-devel] [PATCH] armv7m: optional -kernel if -gdb present
On 20 November 2014 12:34, Liviu Ionescu i...@livius.net wrote: On 20 Nov 2014, at 14:29, Peter Maydell peter.mayd...@linaro.org wrote: -if (!kernel_filename !qtest_enabled()) { +if (!kernel_filename !qtest_enabled() !with_gdb) { fprintf(stderr, Guest image must be specified (using -kernel)\n); exit(1); } just delete this entire if() statement. This is how we've handled similar issues with the ARM A profile boards. (Some of the boards still have those checks but that's just because nobody's bothered to fix them yet.) I'm a bit confused. if not running with gdb, what is the expected behaviour if the image is missing? Same thing as if you start a hardware board with nothing loaded into the flash. (Probably this means go into an infinite loop of taking exceptions.) -- PMM
Re: [Qemu-devel] [PATCH] armv7m: optional -kernel if -gdb present
On 20 Nov 2014, at 14:50, Peter Maydell peter.mayd...@linaro.org wrote: Same thing as if you start a hardware board with nothing loaded into the flash. (Probably this means go into an infinite loop of taking exceptions.) hmmm... and you consider this behaviour to meet the user-friendly requirements? I tried it, and the program simply hangs, without any stdout/stderr messages. if you find this behaviour acceptable for unix users, ok, you don't have to update the other profiles, but for most cortex-m users it is confusing, and user-friendliness is not only appreciated, but required. I would appreciate you reconsider the patch. thank you, Liviu
Re: [Qemu-devel] [PATCH] armv7m: optional -kernel if -gdb present
On 20 November 2014 13:09, Liviu Ionescu i...@livius.net wrote: On 20 Nov 2014, at 14:50, Peter Maydell peter.mayd...@linaro.org wrote: Same thing as if you start a hardware board with nothing loaded into the flash. (Probably this means go into an infinite loop of taking exceptions.) hmmm... and you consider this behaviour to meet the user-friendly requirements? I tried it, and the program simply hangs, without any stdout/stderr messages. Yes. That's what hardware does in that situation. I don't think that whether or not a debugger has been connected should change our behaviour. (And even with your patch, if you connect a debugger and just hit its 'run' button without loading an image then we'll do the same exception-loop.) if you find this behaviour acceptable for unix users, ok, you don't have to update the other profiles, but for most cortex-m users it is confusing, and user-friendliness is not only appreciated, but required. I agree it's not very user friendly. But I don't like inconsistency between our behaviour for different boards either. (And for some boards we're going to have a bios or other firmware which will run if you don't specify -kernel.) In general I think many of the concerns you're raising here are real problems, and our user-friendliness is indeed poor in a lot of places. However the solutions you're proposing are often specific to M-profile ARM, whereas I have to consider the whole project and would prefer solutions which clean up and deal with an issue for all boards and all CPUs. That's obviously harder than a more local and restricted fix, but the benefit is greater. thanks -- PMM
Re: [Qemu-devel] [PATCH] armv7m: optional -kernel if -gdb present
On 20 Nov 2014, at 15:20, Peter Maydell peter.mayd...@linaro.org wrote: ... However the solutions you're proposing are often specific to M-profile ARM, ok, I'll keep this local to my branch. what about the previous patch, is it acceptable? regards, Liviu