CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
74 lines
2.3 KiB
C++
74 lines
2.3 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "MSVCRTCFrameRecognizer.h"
|
|
|
|
#include "lldb/Symbol/VariableList.h"
|
|
#include "lldb/Target/Process.h"
|
|
#include "lldb/Target/StackFrameRecognizer.h"
|
|
#include "lldb/Target/Target.h"
|
|
#include "lldb/Target/Thread.h"
|
|
#include "lldb/Utility/ConstString.h"
|
|
#include "lldb/ValueObject/ValueObject.h"
|
|
|
|
using namespace lldb;
|
|
using namespace lldb_private;
|
|
|
|
namespace lldb_private {
|
|
|
|
void RegisterMSVCRTCFrameRecognizer(Target &target) {
|
|
target.GetFrameRecognizerManager().AddRecognizer(
|
|
std::make_shared<MSVCRTCFrameRecognizer>(), ConstString(""),
|
|
{ConstString("failwithmessage")}, Mangled::ePreferDemangled,
|
|
/*first_instruction_only=*/false);
|
|
}
|
|
|
|
lldb::RecognizedStackFrameSP
|
|
MSVCRTCFrameRecognizer::RecognizeFrame(lldb::StackFrameSP frame_sp) {
|
|
// failwithmessage calls __debugbreak() which lands at frame 0.
|
|
if (frame_sp->GetFrameIndex() != 0)
|
|
return RecognizedStackFrameSP();
|
|
|
|
const char *fn_name = frame_sp->GetFunctionName();
|
|
if (!fn_name)
|
|
return RecognizedStackFrameSP();
|
|
if (!llvm::StringRef(fn_name).contains("failwithmessage"))
|
|
return RecognizedStackFrameSP();
|
|
|
|
VariableListSP vars = frame_sp->GetInScopeVariableList(false);
|
|
if (!vars)
|
|
return RecognizedStackFrameSP();
|
|
|
|
for (size_t i = 0; i < vars->GetSize(); ++i) {
|
|
VariableSP var = vars->GetVariableAtIndex(i);
|
|
if (!var || var->GetName() != ConstString("msg"))
|
|
continue;
|
|
|
|
ValueObjectSP val =
|
|
frame_sp->GetValueObjectForFrameVariable(var, eNoDynamicValues);
|
|
if (!val)
|
|
break;
|
|
|
|
uint64_t ptr = val->GetValueAsUnsigned(0);
|
|
if (!ptr)
|
|
break;
|
|
|
|
std::string msg;
|
|
Status err;
|
|
frame_sp->GetThread()->GetProcess()->ReadCStringFromMemory(ptr, msg, err);
|
|
if (err.Success() && !msg.empty())
|
|
return lldb::RecognizedStackFrameSP(
|
|
new MSVCRTCRecognizedFrame("Run-time check failure: " + msg));
|
|
break;
|
|
}
|
|
|
|
return RecognizedStackFrameSP();
|
|
}
|
|
|
|
} // namespace lldb_private
|