88 lines · cpp
1// Tests that ProcessModID.m_memory_id is not bumped when evaluating expressions without side effects.2 3// REQUIRES: target-windows && (target-x86 || target-x86_64)4// Due to different implementations exact numbers (m_stop_id) are different on different OSs. So we lock this test to specific platform (Windows). It is limited to x86/x64 because on x86/x64, running get()5// requires that we write the return address to the stack, this does not happen on AArch64.6 7// RUN: %build %s -o %t8// RUN: %lldb %t \9// RUN: -o "settings set target.process.track-memory-cache-changes false" \10// RUN: -o "run" \11// RUN: -o "process status -d" \12// RUN: -o "expr x.i != 42" \13// RUN: -o "process status -d" \14// RUN: -o "process status -d" \15// RUN: -o "expr x.get()" \16// RUN: -o "process status -d" \17// RUN: -o "process status -d" \18// RUN: -o "expr x.i = 10" \19// RUN: -o "process status -d" \20// RUN: -o "process status -d" \21// RUN: -o "continue" \22// RUN: -o "process status -d" \23// RUN: -o "exit" | FileCheck %s -dump-input=fail24 25class X {26 int i = 0;27 28public:29 int get() { return i; }30};31 32int main() {33 X x;34 x.get();35 36 __builtin_debugtrap();37 __builtin_debugtrap();38 return 0;39}40 41// CHECK-LABEL: process status -d42// CHECK: m_stop_id: [[#STOP_ID:]]43// CHECK: m_memory_id: [[#MEMORY_ID:]]44 45// CHECK-LABEL: expr x.i != 4246// IDs are not changed when executing simple expressions47 48// CHECK-LABEL: process status -d49// CHECK: m_stop_id: [[#STOP_ID]]50// CHECK: m_memory_id: [[#MEMORY_ID]]51 52// CHECK-LABEL: process status -d53// Remember new values54// CHECK: m_stop_id: [[#STOP_ID:]]55// CHECK: m_memory_id: [[#MEMORY_ID:]]56 57// CHECK-LABEL: expr x.get()58// Expression causes ID to be bumped because LLDB has to execute function and in doing59// so must write the return address to the stack.60 61// CHECK-LABEL: process status -d62// CHECK-NOT: m_stop_id: [[#STOP_ID]]63// CHECK-NOT: m_memory_id: [[#MEMORY_ID]]64 65// CHECK-LABEL: process status -d66// Remember new values67// CHECK: m_stop_id: [[#STOP_ID:]]68// CHECK: m_memory_id: [[#MEMORY_ID:]]69 70// CHECK-LABEL: expr x.i = 1071// Expression causes MemoryID to be bumped because LLDB writes to non-cache memory72 73// CHECK-LABEL: process status -d74// CHECK: m_stop_id: [[#STOP_ID]]75// CHECK-NOT: m_memory_id: [[#MEMORY_ID]]76 77// CHECK-LABEL: process status -d78// Remember new values79// CHECK: m_stop_id: [[#STOP_ID:]]80// CHECK: m_memory_id: [[#MEMORY_ID:]]81 82// CHECK-LABEL: continue83// Continue causes StopID to be bumped because process is resumed84 85// CHECK-LABEL: process status -d86// CHECK-NOT: m_stop_id: [[#STOP_ID]]87// CHECK: m_memory_id: [[#MEMORY_ID]]88