armv7m: optional -kernel if -gdb present
PATCH 1/1 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.
--- hw/arm/armv7m.c | 3 ++- include/sysemu/sysemu.h | 1 + vl.c | 7 ++++++- 3 files changed, 9 insertions(+), 2 deletions(-)
hw/arm/armv7m.c +2 -1
@@ -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 ); }
include/sysemu/sysemu.h +1 -0
@@ -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,
vl.c +6 -1
@@ -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 (); }
Signature · 1 line
1.9.3 (Apple Git-50)
Quoted 3 lines · Liviu Ionescu
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:
hw/arm/armv7m.c qemu_irq *armv7m_init(MemoryRegion *system_memory, · line 248
Quoted 5 lines
hw/arm/armv7m.c +1
-1-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
Quoted 10 lines · Peter Maydell
hw/arm/armv7m.c qemu_irq *armv7m_init(MemoryRegion *system_memory, · line 248
Quoted 5 lines
hw/arm/armv7m.c +1
-1-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
Quoted 9 lines · Liviu Ionescu
Quoted 6 lines · Peter Maydell
Quoted 5 lines
hw/arm/armv7m.c +1
-1-if (!kernel_filename && !qtest_enabled ()) { +if (!kernel_filename && !qtest_enabled () && !with_gdb) {fprintf (stderr,"Guest image must be specified (using -kernel)\n" );exit (1 ); }
Quoted 7 lines
Quoted 4 lines
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
Quoted 3 lines · Peter Maydell
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
Quoted 10 lines · Liviu Ionescu
Quoted 3 lines · Peter Maydell
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.)
Quoted 3 lines
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
Quoted 2 lines · Peter Maydell
... 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