100 changes: 26 additions & 74 deletions lldb/test/API/tools/lldb-server/TestGdbRemoteThreadsInStopReply.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import json
import re

Expand Down Expand Up @@ -166,77 +165,54 @@ def gather_threads_info_pcs(self, pc_register, little_endian):

return thread_pcs

def QListThreadsInStopReply_supported(self):

@skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
def test_QListThreadsInStopReply_supported(self):
self.build()
self.set_inferior_startup_launch()
procs = self.prep_debug_monitor_and_inferior()
self.test_sequence.add_log_lines(
self.ENABLE_THREADS_IN_STOP_REPLY_ENTRIES, True)

context = self.expect_gdbremote_sequence()
self.assertIsNotNone(context)

# In current implementation of llgs on Windows, as a response to '\x03' packet, the debugger
# of the native process will trigger a call to DebugBreakProcess that will create a new thread
# to handle the exception debug event. So one more stop thread will be notified to the
# delegate, e.g. llgs. So tests below to assert the stop threads number will all fail.
@expectedFailureAll(oslist=["windows"])
@skipIfNetBSD
@skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
@debugserver_test
def test_QListThreadsInStopReply_supported_debugserver(self):
def test_stop_reply_reports_multiple_threads(self):
self.build()
self.set_inferior_startup_launch()
self.QListThreadsInStopReply_supported()

@llgs_test
def test_QListThreadsInStopReply_supported_llgs(self):
self.build()
self.set_inferior_startup_launch()
self.QListThreadsInStopReply_supported()

def stop_reply_reports_multiple_threads(self, thread_count):
# Gather threads from stop notification when QThreadsInStopReply is
# enabled.
stop_reply_threads = self.gather_stop_reply_threads(
self.ENABLE_THREADS_IN_STOP_REPLY_ENTRIES, thread_count)
self.assertEqual(len(stop_reply_threads), thread_count)
self.ENABLE_THREADS_IN_STOP_REPLY_ENTRIES, 5)
self.assertEqual(len(stop_reply_threads), 5)

@skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
@debugserver_test
def test_stop_reply_reports_multiple_threads_debugserver(self):
self.build()
self.set_inferior_startup_launch()
self.stop_reply_reports_multiple_threads(5)

# In current implementation of llgs on Windows, as a response to '\x03' packet, the debugger
# of the native process will trigger a call to DebugBreakProcess that will create a new thread
# to handle the exception debug event. So one more stop thread will be notified to the
# delegate, e.g. llgs. So tests below to assert the stop threads number will all fail.
@expectedFailureAll(oslist=["windows"])
@skipIfNetBSD
@llgs_test
def test_stop_reply_reports_multiple_threads_llgs(self):
def test_no_QListThreadsInStopReply_supplies_no_threads(self):
self.build()
self.set_inferior_startup_launch()
self.stop_reply_reports_multiple_threads(5)

def no_QListThreadsInStopReply_supplies_no_threads(self, thread_count):
# Gather threads from stop notification when QThreadsInStopReply is not
# enabled.
stop_reply_threads = self.gather_stop_reply_threads(None, thread_count)
stop_reply_threads = self.gather_stop_reply_threads(None, 5)
self.assertEqual(len(stop_reply_threads), 0)

@skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
@debugserver_test
def test_no_QListThreadsInStopReply_supplies_no_threads_debugserver(self):
self.build()
self.set_inferior_startup_launch()
self.no_QListThreadsInStopReply_supplies_no_threads(5)

@expectedFailureAll(oslist=["windows"])
@skipIfNetBSD
@llgs_test
def test_no_QListThreadsInStopReply_supplies_no_threads_llgs(self):
@skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
def test_stop_reply_reports_correct_threads(self):
self.build()
self.set_inferior_startup_launch()
self.no_QListThreadsInStopReply_supplies_no_threads(5)

def stop_reply_reports_correct_threads(self, thread_count):
# Gather threads from stop notification when QThreadsInStopReply is
# enabled.
thread_count = 5
stop_reply_threads = self.gather_stop_reply_threads(
self.ENABLE_THREADS_IN_STOP_REPLY_ENTRIES, thread_count)
self.assertEqual(len(stop_reply_threads), thread_count)
Expand All @@ -254,24 +230,15 @@ def stop_reply_reports_correct_threads(self, thread_count):

# Ensure each thread in q{f,s}ThreadInfo appears in stop reply threads
for tid in threads:
self.assertTrue(tid in stop_reply_threads)

@skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
@debugserver_test
def test_stop_reply_reports_correct_threads_debugserver(self):
self.build()
self.set_inferior_startup_launch()
self.stop_reply_reports_correct_threads(5)
self.assertIn(tid, stop_reply_threads)

@expectedFailureAll(oslist=["windows"])
@skipIfNetBSD
@llgs_test
def test_stop_reply_reports_correct_threads_llgs(self):
@skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
def test_stop_reply_contains_thread_pcs(self):
self.build()
self.set_inferior_startup_launch()
self.stop_reply_reports_correct_threads(5)

def stop_reply_contains_thread_pcs(self, thread_count):
thread_count = 5
results = self.gather_stop_reply_pcs(
self.ENABLE_THREADS_IN_STOP_REPLY_ENTRIES, thread_count)
stop_reply_pcs = results["thread_pcs"]
Expand All @@ -284,21 +251,6 @@ def stop_reply_contains_thread_pcs(self, thread_count):

self.assertEqual(len(threads_info_pcs), thread_count)
for thread_id in stop_reply_pcs:
self.assertTrue(thread_id in threads_info_pcs)
self.assertTrue(int(stop_reply_pcs[thread_id], 16)
== int(threads_info_pcs[thread_id], 16))

@expectedFailureAll(oslist=["windows"])
@skipIfNetBSD
@llgs_test
def test_stop_reply_contains_thread_pcs_llgs(self):
self.build()
self.set_inferior_startup_launch()
self.stop_reply_contains_thread_pcs(5)

@skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
@debugserver_test
def test_stop_reply_contains_thread_pcs_debugserver(self):
self.build()
self.set_inferior_startup_launch()
self.stop_reply_contains_thread_pcs(5)
self.assertIn(thread_id, threads_info_pcs)
self.assertEqual(int(stop_reply_pcs[thread_id], 16),
int(threads_info_pcs[thread_id], 16))
10 changes: 5 additions & 5 deletions llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2477,13 +2477,13 @@ void DwarfDebug::emitDebugLocValue(const AsmPrinter &AP, const DIBasicType *BT,
DwarfExpr.addExpression(std::move(ExprCursor));
return;
} else if (Value.isConstantFP()) {
if (AP.getDwarfVersion() >= 4 && !AP.getDwarfDebug()->tuneForSCE()) {
if (AP.getDwarfVersion() >= 4 && !AP.getDwarfDebug()->tuneForSCE() &&
!ExprCursor) {
DwarfExpr.addConstantFP(Value.getConstantFP()->getValueAPF(), AP);
return;
} else if (Value.getConstantFP()
->getValueAPF()
.bitcastToAPInt()
.getBitWidth() <= 64 /*bits*/)
}
if (Value.getConstantFP()->getValueAPF().bitcastToAPInt().getBitWidth() <=
64 /*bits*/)
DwarfExpr.addUnsignedConstant(
Value.getConstantFP()->getValueAPF().bitcastToAPInt());
else
Expand Down
24 changes: 13 additions & 11 deletions llvm/test/DebugInfo/X86/implicit_value-double.ll
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
;; This test checks for emission of DW_OP_implicit_value operation
;; for double type.

; RUN: llc -debugger-tune=gdb -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s
; RUN: llc -debugger-tune=lldb -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s
; RUN: llc -O0 -debugger-tune=gdb -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s --check-prefixes=CHECK,BOTH
; RUN: llc -O0 -debugger-tune=lldb -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s --check-prefixes=CHECK,BOTH

; CHECK: .debug_info contents:
; CHECK: DW_TAG_variable
; CHECK-NEXT: DW_AT_location ({{.*}}
; CHECK-NEXT: [{{.*}}): DW_OP_implicit_value 0x8 0x1f 0x85 0xeb 0x51 0xb8 0x1e 0x09 0x40)
; CHECK-NEXT: DW_AT_name ("d")

; RUN: llc -debugger-tune=sce -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s -check-prefix=SCE-CHECK
; RUN: llc -O0 -debugger-tune=sce -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s -check-prefixes=SCE-CHECK,BOTH

; SCE-CHECK: .debug_info contents:
; SCE-CHECK: DW_TAG_variable
; SCE-CHECK-NEXT: DW_AT_location ({{.*}}
; SCE-CHECK-NEXT: [{{.*}}): DW_OP_constu 0x40091eb851eb851f, DW_OP_stack_value)
; SCE-CHECK-NEXT: DW_AT_name ("d")

;; Generated from: clang -ggdb -O1
;;int main() {
;; double d = 3.14;
;; printf("dummy\n");
;; d *= d;
;; return 0;
;;}
;; Using DW_OP_implicit_value for fragments is not currently supported.
; BOTH: DW_TAG_variable
; BOTH-NEXT: DW_AT_location ({{.*}}
; BOTH-NEXT: [{{.*}}): DW_OP_constu 0x4047800000000000, DW_OP_stack_value, DW_OP_piece 0x8, DW_OP_constu 0x4052800000000000, DW_OP_stack_value, DW_OP_piece 0x8)
; BOTH-NEXT: DW_AT_name ("c")

; ModuleID = 'implicit_value-double.c'
source_filename = "implicit_value-double.c"
Expand All @@ -37,6 +35,8 @@ target triple = "x86_64-unknown-linux-gnu"
define dso_local i32 @main() local_unnamed_addr #0 !dbg !7 {
entry:
call void @llvm.dbg.value(metadata double 3.140000e+00, metadata !12, metadata !DIExpression()), !dbg !14
call void @llvm.dbg.value(metadata double 4.700000e+01, metadata !17, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 64)), !dbg !14
call void @llvm.dbg.value(metadata double 7.400000e+01, metadata !17, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64)), !dbg !14
%puts = call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0)), !dbg !15
call void @llvm.dbg.value(metadata double undef, metadata !12, metadata !DIExpression()), !dbg !14
ret i32 0, !dbg !16
Expand Down Expand Up @@ -67,9 +67,11 @@ attributes #2 = { nofree nounwind }
!8 = !DISubroutineType(types: !9)
!9 = !{!10}
!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!11 = !{!12}
!11 = !{!12, !17}
!12 = !DILocalVariable(name: "d", scope: !7, file: !1, line: 2, type: !13)
!13 = !DIBasicType(name: "double", size: 64, encoding: DW_ATE_float)
!14 = !DILocation(line: 0, scope: !7)
!15 = !DILocation(line: 3, column: 2, scope: !7)
!16 = !DILocation(line: 5, column: 2, scope: !7)
!17 = !DILocalVariable(name: "c", scope: !7, file: !1, line: 2, type: !18)
!18 = !DIBasicType(name: "complex", size: 128, encoding: DW_ATE_complex_float)