================ @@ -233,24 +235,57 @@ OptionArgParser::DoToAddress(const ExecutionContext *exe_ctx, llvm::StringRef s, // Since the compiler can't handle things like "main + 12" we should try to // do this for now. The compiler doesn't like adding offsets to function // pointer types. + // Some languages also don't have a natural representation for register + // values (e.g. swift) so handle simple uses of them here as well. static RegularExpression g_symbol_plus_offset_regex( - "^(.*)([-\\+])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*$"); + "^(\\$[^ +-]+)|(([^ +-]+)([-\\+])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*)$"); llvm::SmallVector<llvm::StringRef, 4> matches; if (g_symbol_plus_offset_regex.Execute(sref, &matches)) { uint64_t offset = 0; - llvm::StringRef name = matches[1]; - llvm::StringRef sign = matches[2]; - llvm::StringRef str_offset = matches[3]; - if (!str_offset.getAsInteger(0, offset)) { + llvm::StringRef name; + if (!matches[1].empty()) + name = matches[1]; + else + name = matches[3]; + + llvm::StringRef sign = matches[4]; + llvm::StringRef str_offset = matches[5]; + std::optional<lldb::addr_t> register_value; + StackFrame *frame = exe_ctx->GetFramePtr(); + if (frame && !name.empty() && name[0] == '$') { ---------------- adrian-prantl wrote:
or even better: StringRef regname = name.consume_front("$"); if (!regname.empty) ... https://github.com/llvm/llvm-project/pull/85492 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits