=?utf-8?q?José?= L. Junior <jljunio...@gmail.com>,
=?utf-8?q?José?= L. Junior <jljunio...@gmail.com>,
=?utf-8?q?José?= L. Junior <jljunio...@gmail.com>
Message-ID:
In-Reply-To: <llvm/llvm-project/pull/67019/l...@github.com>


jimingham wrote:

Yes that's right.  Normally what happens in program execution is the main 
executable gets loaded along with the dynamic loader, and then the loader runs, 
leading the program through several rounds of shared library loading (that can 
be a lot of shared libraries these days) and THEN runs the user entry point.  
Adding this filter means that we won't try to resolve a "main" breakpoint in 
every one of those shared libraries.

Jim

> On Sep 26, 2023, at 7:39 AM, José Lira Junior ***@***.***> wrote:
> 
> 
> @junior-jl commented on this pull request.
> 
> In lldb/source/Commands/CommandOptionsProcessLaunch.cpp 
> <https://github.com/llvm/llvm-project/pull/67019#discussion_r1337326182>:
> 
> > @@ -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,
> 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?
> 
> 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);
> —
> Reply to this email directly, view it on GitHub 
> <https://github.com/llvm/llvm-project/pull/67019#discussion_r1337326182>, or 
> unsubscribe 
> <https://github.com/notifications/unsubscribe-auth/ADUPVW5NFBYC7PEIMKPRGZTX4LSIZANCNFSM6AAAAAA5BUJK5M>.
> You are receiving this because you were mentioned.
> 



https://github.com/llvm/llvm-project/pull/67019
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to