From 7618b2931d65c2ba1ae109339c614a9d39ce8382 Mon Sep 17 00:00:00 2001 From: Sergei Shadrin Date: Wed, 23 Nov 2022 18:57:25 +0000 Subject: [PATCH] Fix source file path in debug info Change-Id: Id19bce62edc14af72f2aa1e1328f1476783b72f0 Signed-off-by: Sergei Shadrin --- aot/options.cpp | 4 +--- compiler/core/emitter.cpp | 4 ++++ compiler/core/regScope.cpp | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/aot/options.cpp b/aot/options.cpp index 053713541..d202f240e 100644 --- a/aot/options.cpp +++ b/aot/options.cpp @@ -120,12 +120,10 @@ bool Options::Parse(int argc, const char **argv) ss << inputStream.rdbuf(); parserInput_ = ss.str(); - sourceFile_ = BaseName(sourceFile_); - if (!outputFile.GetValue().empty()) { compilerOutput_ = outputFile.GetValue(); } else { - compilerOutput_ = RemoveExtension(sourceFile_).append(".abc"); + compilerOutput_ = RemoveExtension(BaseName(sourceFile_)).append(".abc"); } if (!logLevel.GetValue().empty()) { diff --git a/compiler/core/emitter.cpp b/compiler/core/emitter.cpp index d854586e2..bbb367d6d 100644 --- a/compiler/core/emitter.cpp +++ b/compiler/core/emitter.cpp @@ -168,6 +168,10 @@ static size_t GetIRNodeWholeLength(const IRNode *node) static std::string WholeLine(const util::StringView &source, lexer::SourceRange range) { + if (source.Empty()) { + return {}; + } + ASSERT(range.end.index <= source.Length()); return source.Substr(range.start.index, range.end.index).EscapeSymbol(); } diff --git a/compiler/core/regScope.cpp b/compiler/core/regScope.cpp index 7fe199097..55e607f35 100644 --- a/compiler/core/regScope.cpp +++ b/compiler/core/regScope.cpp @@ -59,7 +59,7 @@ LocalRegScope::LocalRegScope(CodeGen *cg, binder::Scope *scope) : RegScope(cg) } } - if (cg_->IsDebug()) { + if (cg_->IsDebug() && !cg_->insns_.empty()) { cg_->scope_->SetScopeStart(cg_->insns_.back()); cg_->debugInfo_.VariableDebugInfo().push_back(cg_->scope_); } -- Gitee