[PATCH v3 1/1] gdb: abort start command if there is no symbol for 'main_name ()'

Rohr, Stephan stephan.rohr@intel.com
Fri Jan 10 09:50:31 GMT 2025


Hi Tom,

I would vote for removing the check entirely:

  * Adding a try / catch block in 'tbreak' or in 'run_command_1' is not straight
     forward.  If 'main' cannot be resolved, a 'NOT_FOUND_ERROR' is thrown.
  * A 'No symbol table is loaded.  Use the "file" command' error is printed.
  * The error is consumed in 'create_breakpoint' and the user may insert a 
     pending breakpoint.  The error only rethrown if pending breakpoints are not
     supported.

We would need to rethrow the error in 'create_breakpoint'.  This requires
additional changes and may impact other calls to 'create_breakpoint'.
I would like to avoid this.

I could not observer regressions for Ada if I entirely remove the check.

Do you have any concerns?

Thanks
Stephan


> -----Original Message-----
> From: Tom Tromey <tom@tromey.com>
> Sent: Friday, 13 December 2024 15:51
> To: Rohr, Stephan <stephan.rohr@intel.com>
> Cc: gdb-patches@sourceware.org; guinevere@redhat.com; eliz@gnu.org
> Subject: Re: [PATCH v3 1/1] gdb: abort start command if there is no symbol
> for 'main_name ()'
> 
> >>>>> "Stephan" == Stephan Rohr <stephan.rohr@intel.com> writes:
> 
> Thanks for the patch.
> 
> Stephan> -  /* Some languages such as Ada need to search inside the program
> Stephan> -     minimal symbols for the location where to put the temporary
> Stephan> -     breakpoint before starting.  */
> Stephan> -  if (!have_minimal_symbols (current_program_space))
> Stephan> +  /* Abort the start command if 'main' cannot be resolved.  */
> Stephan> +  struct symbol *sym
> Stephan> +    = lookup_symbol_search_name (main_name (), nullptr,
> Stephan> +
> SEARCH_FUNCTION_DOMAIN).symbol;
> Stephan> +
> Stephan> +  if (sym == nullptr)
> Stephan>      error (_("No symbol table loaded.  Use the \"file\" command."));
> 
> I agree that the check currently in the code isn't really correct, but I
> think this change means that 'start' will now fail if the inferior
> doesn't have debug symbols.
> 
> I wonder what happens if you simply remove the check entirely.  If we
> want to preserve the text about using "file", this could maybe be done
> by wrapping the call to tbreak_command in a try/catch.
> 
> Tom
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


More information about the Gdb-patches mailing list