================
@@ -38,7 +38,18 @@ Status CommandOptionsProcessLaunch::SetOptionValue(
case 's': // Stop at program entry point
launch_info.GetFlags().Set(eLaunchFlagStopAtEntry);
break;
-
+ case 'm': // Stop at main function
+ {
+ TargetSP target_sp =
+ execution_context ? execution_context->GetTargetSP() : TargetSP();
+ BreakpointSP bp_sp = target_sp->CreateBreakpoint(
+ nullptr, nullptr, "main", eFunctionNameTypeAuto, eLanguageTypeUnknown,
----------------
junior-jl wrote:
> It's also a good idea to add a shared library filter instead of the first
> `nullptr` in the code above, and specify the main executable. You know the
> entry point has to be in the main executable, and so it would be inefficient
> to search the whole world for this breakpoint. It could also end up not being
> what you want, because some other shared library might call a function named
> "main" as part of it's shared library loading code (which happens before the
> language's entry point) so you would in fact stop too early.
I see. Something like this?
```cpp
ModuleSP main_module_sp = target_sp->GetExecutableModule();
FileSpecList shared_lib_filter;
shared_lib_filter.Append(main_module_sp->GetFileSpec());
BreakpointSP bp_sp = target_sp->CreateBreakpoint(
&shared_lib_filter, nullptr, "main", eFunctionNameTypeFull,
eLanguageTypeUnknown,
0, eLazyBoolNo, false, false);
```
https://github.com/llvm/llvm-project/pull/67019
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits