=?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>


================
@@ -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,
----------------
jimingham wrote:

We have a list of "Supported Languages" (Language::GetSupportedLangauges) which 
are the ones we actually have plugins for as opposed to the ones whose names we 
know.  That's the list you should be querying. 

We should add a new API to the Language plugin: 
Language::GetUserEntrypointName() and then this code should iterate over all 
the supported languages building up a unique list of entry point names using 
this API.  At present there's going to be one: "main" repeated many times but I 
think Walter promised us another one soon...  

If you find more than one name, there's a Target::CreateBreakpoint overload 
that takes a `const char *func_names[]` - that you can use to make one 
portmanteau breakpoint for all the entry point names.  

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.

You'll need to pass eLanguageTypeUnknown for the language.

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