[Lldb-commits] [PATCH] D138407: [LLDB] Add LoongArch register definitions and operations

2022-11-23 Thread Tiezhu Yang via Phabricator via lldb-commits
seehearfeel updated this revision to Diff 477690.
seehearfeel added a comment.

(1) define *_OFFSET in RegisterInfoPOSIX_loongarch64.cpp
(2) remove the alias u0 for r21, use fp and s9 for r22


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138407/new/

https://reviews.llvm.org/D138407

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.h
  lldb/source/Plugins/Process/Utility/CMakeLists.txt
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_loongarch64.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_loongarch64.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_loongarch64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_loongarch64.h
  lldb/source/Plugins/Process/Utility/RegisterInfos_loongarch64.h
  lldb/source/Plugins/Process/Utility/lldb-loongarch-register-enums.h
  lldb/source/Utility/LoongArch_DWARF_Registers.h

Index: lldb/source/Utility/LoongArch_DWARF_Registers.h
===
--- /dev/null
+++ lldb/source/Utility/LoongArch_DWARF_Registers.h
@@ -0,0 +1,178 @@
+//===-- LoongArch_DWARF_Registers.h -*- 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
+//
+//===--===//
+
+#ifndef LLDB_SOURCE_UTILITY_LOONGARCH_DWARF_REGISTERS_H
+#define LLDB_SOURCE_UTILITY_LOONGARCH_DWARF_REGISTERS_H
+
+#include "lldb/lldb-private.h"
+
+namespace loongarch_dwarf {
+
+enum {
+  dwarf_gpr_r0 = 0,
+  dwarf_gpr_r1,
+  dwarf_gpr_r2,
+  dwarf_gpr_r3,
+  dwarf_gpr_r4,
+  dwarf_gpr_r5,
+  dwarf_gpr_r6,
+  dwarf_gpr_r7,
+  dwarf_gpr_r8,
+  dwarf_gpr_r9,
+  dwarf_gpr_r10,
+  dwarf_gpr_r11,
+  dwarf_gpr_r12,
+  dwarf_gpr_r13,
+  dwarf_gpr_r14,
+  dwarf_gpr_r15,
+  dwarf_gpr_r16,
+  dwarf_gpr_r17,
+  dwarf_gpr_r18,
+  dwarf_gpr_r19,
+  dwarf_gpr_r20,
+  dwarf_gpr_r21,
+  dwarf_gpr_r22,
+  dwarf_gpr_r23,
+  dwarf_gpr_r24,
+  dwarf_gpr_r25,
+  dwarf_gpr_r26,
+  dwarf_gpr_r27,
+  dwarf_gpr_r28,
+  dwarf_gpr_r29,
+  dwarf_gpr_r30,
+  dwarf_gpr_r31 = 31,
+
+  dwarf_gpr_orig_a0,
+  dwarf_gpr_pc,
+  dwarf_gpr_badv,
+
+  dwarf_gpr_reserved0 = 35,
+  dwarf_gpr_reserved1,
+  dwarf_gpr_reserved2,
+  dwarf_gpr_reserved3,
+  dwarf_gpr_reserved4,
+  dwarf_gpr_reserved5,
+  dwarf_gpr_reserved6,
+  dwarf_gpr_reserved7,
+  dwarf_gpr_reserved8,
+  dwarf_gpr_reserved9,
+
+  dwarf_fpr_f0 = 45,
+  dwarf_fpr_f1,
+  dwarf_fpr_f2,
+  dwarf_fpr_f3,
+  dwarf_fpr_f4,
+  dwarf_fpr_f5,
+  dwarf_fpr_f6,
+  dwarf_fpr_f7,
+  dwarf_fpr_f8,
+  dwarf_fpr_f9,
+  dwarf_fpr_f10,
+  dwarf_fpr_f11,
+  dwarf_fpr_f12,
+  dwarf_fpr_f13,
+  dwarf_fpr_f14,
+  dwarf_fpr_f15,
+  dwarf_fpr_f16,
+  dwarf_fpr_f17,
+  dwarf_fpr_f18,
+  dwarf_fpr_f19,
+  dwarf_fpr_f20,
+  dwarf_fpr_f21,
+  dwarf_fpr_f22,
+  dwarf_fpr_f23,
+  dwarf_fpr_f24,
+  dwarf_fpr_f25,
+  dwarf_fpr_f26,
+  dwarf_fpr_f27,
+  dwarf_fpr_f28,
+  dwarf_fpr_f29,
+  dwarf_fpr_f30,
+  dwarf_fpr_f31 = 76,
+
+  dwarf_fpr_fcc0,
+  dwarf_fpr_fcc1,
+  dwarf_fpr_fcc2,
+  dwarf_fpr_fcc3,
+  dwarf_fpr_fcc4,
+  dwarf_fpr_fcc5,
+  dwarf_fpr_fcc6,
+  dwarf_fpr_fcc7,
+  dwarf_fpr_fcsr,
+
+  // register name alias
+  dwarf_gpr_zero = dwarf_gpr_r0,
+  dwarf_gpr_ra = dwarf_gpr_r1,
+  dwarf_gpr_tp = dwarf_gpr_r2,
+  dwarf_gpr_sp = dwarf_gpr_r3,
+  dwarf_gpr_a0 = dwarf_gpr_r4,
+  dwarf_gpr_a1 = dwarf_gpr_r5,
+  dwarf_gpr_a2 = dwarf_gpr_r6,
+  dwarf_gpr_a3 = dwarf_gpr_r7,
+  dwarf_gpr_a4 = dwarf_gpr_r8,
+  dwarf_gpr_a5 = dwarf_gpr_r9,
+  dwarf_gpr_a6 = dwarf_gpr_r10,
+  dwarf_gpr_a7 = dwarf_gpr_r11,
+  dwarf_gpr_t0 = dwarf_gpr_r12,
+  dwarf_gpr_t1 = dwarf_gpr_r13,
+  dwarf_gpr_t2 = dwarf_gpr_r14,
+  dwarf_gpr_t3 = dwarf_gpr_r15,
+  dwarf_gpr_t4 = dwarf_gpr_r16,
+  dwarf_gpr_t5 = dwarf_gpr_r17,
+  dwarf_gpr_t6 = dwarf_gpr_r18,
+  dwarf_gpr_t7 = dwarf_gpr_r19,
+  dwarf_gpr_t8 = dwarf_gpr_r20,
+  dwarf_gpr_fp = dwarf_gpr_r22,
+  dwarf_gpr_s9 = dwarf_gpr_r22,
+  dwarf_gpr_s0 = dwarf_gpr_r23,
+  dwarf_gpr_s1 = dwarf_gpr_r24,
+  dwarf_gpr_s2 = dwarf_gpr_r25,
+  dwarf_gpr_s3 = dwarf_gpr_r26,
+  dwarf_gpr_s4 = dwarf_gpr_r27,
+  dwarf_gpr_s5 = dwarf_gpr_r28,
+  dwarf_gpr_s6 = dwarf_gpr_r29,
+  dwarf_gpr_s7 = dwarf_gpr_r30,
+  dwarf_gpr_s8 = dwarf_gpr_r31,
+
+  dwarf_fpr_fa0 = dwarf_fpr_f0,
+  dwarf_fpr_fa1 = dwarf_fpr_f1,
+  dwarf_fpr_fa2 = dwarf_fpr_f2,
+  dwarf_fpr_fa3 = dwarf_fpr_f3,
+  dwarf_fpr_fa4 = dwarf_fpr_f4,
+  dwarf_fpr_fa5 = dwarf_fpr_f5,
+  dwarf_fpr_fa6 = dwarf_fpr_f6,
+  dwarf_fpr_fa7 = dwarf_fpr_f7,
+  dwarf_fpr_ft0 = dwarf_fpr_f8,
+  dwarf_fpr_ft1 = dwarf_fpr_f9,
+  dwarf_fpr_ft2 = dwarf_fpr_f10,
+  dwarf_fpr_ft3 = dwarf_fpr_f11,
+  dwarf_fpr_ft4 = dwarf_fpr_f12,
+  dwarf_fpr_ft5 = dwarf_fpr_f13,
+  dwarf_fpr_ft6 = dwarf_fpr_f14,
+  dwarf_fpr_ft7 = 

[Lldb-commits] [PATCH] D138407: [LLDB] Add LoongArch register definitions and operations

2022-11-23 Thread Tiezhu Yang via Phabricator via lldb-commits
seehearfeel added inline comments.



Comment at: lldb/source/Plugins/Process/Utility/RegisterInfos_loongarch64.h:21
+#define GPR_OFFSET(idx) ((idx)*8 + 0)
+#define FPR_OFFSET(idx) ((idx)*8 + sizeof(RegisterInfoPOSIX_loongarch64::GPR))
+#define FCC_OFFSET(idx) ((idx)*1 + 32 * 8 + 
sizeof(RegisterInfoPOSIX_loongarch64::GPR))

SixWeining wrote:
> I'm not sure whether you could use `RegisterInfoPOSIX_loongarch64` in this 
> file directly because I think this file is a `common` file. What do you 
> think? @DavidSpickett
Maybe it is better to define them in RegisterInfoPOSIX_loongarch64.cpp, let me 
modify it, thank you.



Comment at: lldb/source/Plugins/Process/Utility/RegisterInfos_loongarch64.h:98
+DEFINE_GPR64_ALT(r20, t8, LLDB_INVALID_REGNUM),
+DEFINE_GPR64_ALT(r21, u0, LLDB_INVALID_REGNUM),
+DEFINE_GPR64_ALT(r22, fp, LLDB_REGNUM_GENERIC_FP),

xen0n wrote:
> SixWeining wrote:
> > `u0` is a unknown alias. Could we just use `DEFINE_GPR64`?
> FYI the `u0` name is [[ 
> https://www.kernel.org/doc/html/latest/loongarch/introduction.html | a 
> non-standard alias only seen in the Linux kernel ]]. It should be harmless to 
> just support `r21` but not `u0`, much like how we don't support `v0/v1` any 
> more.
> 
> While at it, `s9` in addition to `fp` may be supported too. (Arguably `s9` is 
> a better description of `r22` than `fp`, because FP usage can be disabled 
> while generating code, in which case it's just another ordinary callee-saved 
> register. But it seems some people believe so deeply that this usage is 
> acceptable that the name persisted into the final ABI document...)
OK,  according to Register Convention in LoongArch ELF ABI specification
https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html#_register_convention

let me remove the alias u0 for r21, use fp and s9 for r22, thank you.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138407/new/

https://reviews.llvm.org/D138407

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D138407: [LLDB] Add LoongArch register definitions and operations

2022-11-23 Thread WÁNG Xuěruì via Phabricator via lldb-commits
xen0n added inline comments.



Comment at: lldb/source/Plugins/Process/Utility/RegisterInfos_loongarch64.h:98
+DEFINE_GPR64_ALT(r20, t8, LLDB_INVALID_REGNUM),
+DEFINE_GPR64_ALT(r21, u0, LLDB_INVALID_REGNUM),
+DEFINE_GPR64_ALT(r22, fp, LLDB_REGNUM_GENERIC_FP),

SixWeining wrote:
> `u0` is a unknown alias. Could we just use `DEFINE_GPR64`?
FYI the `u0` name is [[ 
https://www.kernel.org/doc/html/latest/loongarch/introduction.html | a 
non-standard alias only seen in the Linux kernel ]]. It should be harmless to 
just support `r21` but not `u0`, much like how we don't support `v0/v1` any 
more.

While at it, `s9` in addition to `fp` may be supported too. (Arguably `s9` is a 
better description of `r22` than `fp`, because FP usage can be disabled while 
generating code, in which case it's just another ordinary callee-saved 
register. But it seems some people believe so deeply that this usage is 
acceptable that the name persisted into the final ABI document...)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138407/new/

https://reviews.llvm.org/D138407

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D138638: Report which modules have forcefully completed types in statistics.

2022-11-23 Thread Greg Clayton via Phabricator via lldb-commits
clayborg created this revision.
clayborg added a reviewer: yinghuitan.
Herald added a reviewer: shafik.
Herald added a project: All.
clayborg requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

A previous patch added the ability for us to tell if types were forcefully 
completed. This patch adds the ability to see which modules have forcefully 
completed types and aggregates the number of modules with forcefully completed 
types at the root level.

We add a module specific setting named "debugInfoHadIncompleteTypes" that is a 
boolean value. We also aggregate the number of modules at the root level that 
had incomplete debug info with a key named 
"totalModuleCountWithIncompleteTypes" that is a count of number of modules that 
had incomplete types.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138638

Files:
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/include/lldb/Target/Statistics.h
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Target/Statistics.cpp
  lldb/test/API/commands/statistics/basic/TestStats.py
  lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py

Index: lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
===
--- lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
+++ lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
@@ -30,6 +30,23 @@
 self._check_type(target, "InheritsFromOne")
 self._check_type(target, "InheritsFromTwo")
 
+# Check that the statistics show that we had incomplete debug info.
+stats = self.get_stats()
+# Find the a.out module info in the stats and verify it has the
+# "debugInfoHadIncompleteTypes" key value pair set to True
+exe_module_found = False
+for module in stats['modules']:
+if module['path'].endswith('a.out'):
+self.assertTrue(module['debugInfoHadIncompleteTypes'])
+exe_module_found = True
+break
+self.assertTrue(exe_module_found)
+# Verify that "totalModuleCountWithIncompleteTypes" at the top level
+# is greater than zero which shows we had incomplete debug info in a
+# module
+self.assertGreater(stats['totalModuleCountWithIncompleteTypes'], 0)
+
+
 def _check_incomplete_frame_variable_output(self):
 # Check that the display of the "frame variable" output identifies the
 # incomplete types. Currently the expression parser will find the real
Index: lldb/test/API/commands/statistics/basic/TestStats.py
===
--- lldb/test/API/commands/statistics/basic/TestStats.py
+++ lldb/test/API/commands/statistics/basic/TestStats.py
@@ -55,30 +55,6 @@
 self.assertEqual(success_fail_dict['failures'], num_fails,
  'make sure success count')
 
-def get_stats(self, options=None, log_path=None):
-"""
-Get the output of the "statistics dump" with optional extra options
-and return the JSON as a python dictionary.
-"""
-# If log_path is set, open the path and emit the output of the command
-# for debugging purposes.
-if log_path is not None:
-f = open(log_path, 'w')
-else:
-f = None
-return_obj = lldb.SBCommandReturnObject()
-command = "statistics dump "
-if options is not None:
-command += options
-if f:
-f.write('(lldb) %s\n' % (command))
-self.ci.HandleCommand(command, return_obj, False)
-metrics_json = return_obj.GetOutput()
-if f:
-f.write(metrics_json)
-return json.loads(metrics_json)
-
-
 def get_target_stats(self, debug_stats):
 if "targets" in debug_stats:
 return debug_stats["targets"][0]
@@ -509,7 +485,6 @@
 exe_name = 'a.out'
 exe = self.getBuildArtifact(exe_name)
 dsym = self.getBuildArtifact(exe_name + ".dSYM")
-print("carp: dsym = '%s'" % (dsym))
 # Make sure the executable file exists after building.
 self.assertEqual(os.path.exists(exe), True)
 # Make sure the dSYM file doesn't exist after building.
@@ -563,7 +538,6 @@
 exe = self.getBuildArtifact(exe_name)
 dsym = self.getBuildArtifact(exe_name + ".dSYM")
 main_obj = self.getBuildArtifact('main.o')
-print("carp: dsym = '%s'" % (dsym))
 # Make sure the executable file exists after building.
 self.assertEqual(os.path.exists(exe), True)
 # Make sure the dSYM file doesn't exist after building.
Index: 

[Lldb-commits] [PATCH] D138407: [LLDB] Add LoongArch register definitions and operations

2022-11-23 Thread Lu Weining via Phabricator via lldb-commits
SixWeining added inline comments.



Comment at: lldb/source/Plugins/Process/Utility/RegisterInfos_loongarch64.h:21
+#define GPR_OFFSET(idx) ((idx)*8 + 0)
+#define FPR_OFFSET(idx) ((idx)*8 + sizeof(RegisterInfoPOSIX_loongarch64::GPR))
+#define FCC_OFFSET(idx) ((idx)*1 + 32 * 8 + 
sizeof(RegisterInfoPOSIX_loongarch64::GPR))

I'm not sure whether you could use `RegisterInfoPOSIX_loongarch64` in this file 
directly because I think this file is a `common` file. What do you think? 
@DavidSpickett



Comment at: lldb/source/Plugins/Process/Utility/RegisterInfos_loongarch64.h:98
+DEFINE_GPR64_ALT(r20, t8, LLDB_INVALID_REGNUM),
+DEFINE_GPR64_ALT(r21, u0, LLDB_INVALID_REGNUM),
+DEFINE_GPR64_ALT(r22, fp, LLDB_REGNUM_GENERIC_FP),

`u0` is a unknown alias. Could we just use `DEFINE_GPR64`?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138407/new/

https://reviews.llvm.org/D138407

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D138407: [LLDB] Add LoongArch register definitions and operations

2022-11-23 Thread Tiezhu Yang via Phabricator via lldb-commits
seehearfeel updated this revision to Diff 477650.
seehearfeel added a comment.

(1) Put elf.h before sys/uio.h
(2) Remove unnecessary indent
(3) Remove const cast of data_sp->GetBytes()
(4) Return k_num_register_sets in GetRegisterSetCount()
(5) Add register name alias


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138407/new/

https://reviews.llvm.org/D138407

Files:
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp
  lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.h
  lldb/source/Plugins/Process/Utility/CMakeLists.txt
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_loongarch64.cpp
  lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_loongarch64.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_loongarch64.cpp
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_loongarch64.h
  lldb/source/Plugins/Process/Utility/RegisterInfos_loongarch64.h
  lldb/source/Plugins/Process/Utility/lldb-loongarch-register-enums.h
  lldb/source/Utility/LoongArch_DWARF_Registers.h

Index: lldb/source/Utility/LoongArch_DWARF_Registers.h
===
--- /dev/null
+++ lldb/source/Utility/LoongArch_DWARF_Registers.h
@@ -0,0 +1,178 @@
+//===-- LoongArch_DWARF_Registers.h -*- 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
+//
+//===--===//
+
+#ifndef LLDB_SOURCE_UTILITY_LOONGARCH_DWARF_REGISTERS_H
+#define LLDB_SOURCE_UTILITY_LOONGARCH_DWARF_REGISTERS_H
+
+#include "lldb/lldb-private.h"
+
+namespace loongarch_dwarf {
+
+enum {
+  dwarf_gpr_r0 = 0,
+  dwarf_gpr_r1,
+  dwarf_gpr_r2,
+  dwarf_gpr_r3,
+  dwarf_gpr_r4,
+  dwarf_gpr_r5,
+  dwarf_gpr_r6,
+  dwarf_gpr_r7,
+  dwarf_gpr_r8,
+  dwarf_gpr_r9,
+  dwarf_gpr_r10,
+  dwarf_gpr_r11,
+  dwarf_gpr_r12,
+  dwarf_gpr_r13,
+  dwarf_gpr_r14,
+  dwarf_gpr_r15,
+  dwarf_gpr_r16,
+  dwarf_gpr_r17,
+  dwarf_gpr_r18,
+  dwarf_gpr_r19,
+  dwarf_gpr_r20,
+  dwarf_gpr_r21,
+  dwarf_gpr_r22,
+  dwarf_gpr_r23,
+  dwarf_gpr_r24,
+  dwarf_gpr_r25,
+  dwarf_gpr_r26,
+  dwarf_gpr_r27,
+  dwarf_gpr_r28,
+  dwarf_gpr_r29,
+  dwarf_gpr_r30,
+  dwarf_gpr_r31 = 31,
+
+  dwarf_gpr_orig_a0,
+  dwarf_gpr_pc,
+  dwarf_gpr_badv,
+
+  dwarf_gpr_reserved0 = 35,
+  dwarf_gpr_reserved1,
+  dwarf_gpr_reserved2,
+  dwarf_gpr_reserved3,
+  dwarf_gpr_reserved4,
+  dwarf_gpr_reserved5,
+  dwarf_gpr_reserved6,
+  dwarf_gpr_reserved7,
+  dwarf_gpr_reserved8,
+  dwarf_gpr_reserved9,
+
+  dwarf_fpr_f0 = 45,
+  dwarf_fpr_f1,
+  dwarf_fpr_f2,
+  dwarf_fpr_f3,
+  dwarf_fpr_f4,
+  dwarf_fpr_f5,
+  dwarf_fpr_f6,
+  dwarf_fpr_f7,
+  dwarf_fpr_f8,
+  dwarf_fpr_f9,
+  dwarf_fpr_f10,
+  dwarf_fpr_f11,
+  dwarf_fpr_f12,
+  dwarf_fpr_f13,
+  dwarf_fpr_f14,
+  dwarf_fpr_f15,
+  dwarf_fpr_f16,
+  dwarf_fpr_f17,
+  dwarf_fpr_f18,
+  dwarf_fpr_f19,
+  dwarf_fpr_f20,
+  dwarf_fpr_f21,
+  dwarf_fpr_f22,
+  dwarf_fpr_f23,
+  dwarf_fpr_f24,
+  dwarf_fpr_f25,
+  dwarf_fpr_f26,
+  dwarf_fpr_f27,
+  dwarf_fpr_f28,
+  dwarf_fpr_f29,
+  dwarf_fpr_f30,
+  dwarf_fpr_f31 = 76,
+
+  dwarf_fpr_fcc0,
+  dwarf_fpr_fcc1,
+  dwarf_fpr_fcc2,
+  dwarf_fpr_fcc3,
+  dwarf_fpr_fcc4,
+  dwarf_fpr_fcc5,
+  dwarf_fpr_fcc6,
+  dwarf_fpr_fcc7,
+  dwarf_fpr_fcsr,
+
+  // register name alias
+  dwarf_gpr_zero = dwarf_gpr_r0,
+  dwarf_gpr_ra = dwarf_gpr_r1,
+  dwarf_gpr_tp = dwarf_gpr_r2,
+  dwarf_gpr_sp = dwarf_gpr_r3,
+  dwarf_gpr_a0 = dwarf_gpr_r4,
+  dwarf_gpr_a1 = dwarf_gpr_r5,
+  dwarf_gpr_a2 = dwarf_gpr_r6,
+  dwarf_gpr_a3 = dwarf_gpr_r7,
+  dwarf_gpr_a4 = dwarf_gpr_r8,
+  dwarf_gpr_a5 = dwarf_gpr_r9,
+  dwarf_gpr_a6 = dwarf_gpr_r10,
+  dwarf_gpr_a7 = dwarf_gpr_r11,
+  dwarf_gpr_t0 = dwarf_gpr_r12,
+  dwarf_gpr_t1 = dwarf_gpr_r13,
+  dwarf_gpr_t2 = dwarf_gpr_r14,
+  dwarf_gpr_t3 = dwarf_gpr_r15,
+  dwarf_gpr_t4 = dwarf_gpr_r16,
+  dwarf_gpr_t5 = dwarf_gpr_r17,
+  dwarf_gpr_t6 = dwarf_gpr_r18,
+  dwarf_gpr_t7 = dwarf_gpr_r19,
+  dwarf_gpr_t8 = dwarf_gpr_r20,
+  dwarf_gpr_u0 = dwarf_gpr_r21,
+  dwarf_gpr_fp = dwarf_gpr_r22,
+  dwarf_gpr_s0 = dwarf_gpr_r23,
+  dwarf_gpr_s1 = dwarf_gpr_r24,
+  dwarf_gpr_s2 = dwarf_gpr_r25,
+  dwarf_gpr_s3 = dwarf_gpr_r26,
+  dwarf_gpr_s4 = dwarf_gpr_r27,
+  dwarf_gpr_s5 = dwarf_gpr_r28,
+  dwarf_gpr_s6 = dwarf_gpr_r29,
+  dwarf_gpr_s7 = dwarf_gpr_r30,
+  dwarf_gpr_s8 = dwarf_gpr_r31,
+
+  dwarf_fpr_fa0 = dwarf_fpr_f0,
+  dwarf_fpr_fa1 = dwarf_fpr_f1,
+  dwarf_fpr_fa2 = dwarf_fpr_f2,
+  dwarf_fpr_fa3 = dwarf_fpr_f3,
+  dwarf_fpr_fa4 = dwarf_fpr_f4,
+  dwarf_fpr_fa5 = dwarf_fpr_f5,
+  dwarf_fpr_fa6 = dwarf_fpr_f6,
+  dwarf_fpr_fa7 = dwarf_fpr_f7,
+  dwarf_fpr_ft0 = dwarf_fpr_f8,
+  dwarf_fpr_ft1 = dwarf_fpr_f9,
+  dwarf_fpr_ft2 = dwarf_fpr_f10,
+  dwarf_fpr_ft3 = dwarf_fpr_f11,
+  dwarf_fpr_ft4 = dwarf_fpr_f12,
+  

[Lldb-commits] [lldb] a2f1879 - [lldb] Fix a warning

2022-11-23 Thread Kazu Hirata via lldb-commits

Author: Kazu Hirata
Date: 2022-11-23T15:55:05-08:00
New Revision: a2f1879c2d8ad5e6c2773d77d9f6d3fdaffbe3ea

URL: 
https://github.com/llvm/llvm-project/commit/a2f1879c2d8ad5e6c2773d77d9f6d3fdaffbe3ea
DIFF: 
https://github.com/llvm/llvm-project/commit/a2f1879c2d8ad5e6c2773d77d9f6d3fdaffbe3ea.diff

LOG: [lldb] Fix a warning

This patch fixes:

  lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp:105:18:
  warning: comparison of unsigned expression in ‘>= 0’ is always true
  [-Wtype-limits]

Added: 


Modified: 
lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp 
b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
index ca7adff785d99..7c29bce147715 100644
--- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
+++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
@@ -102,7 +102,7 @@ static uint32_t GPREncodingToLLDB(uint32_t reg_encode) {
 }
 
 static uint32_t FPREncodingToLLDB(uint32_t reg_encode) {
-  if (reg_encode >= 0 && reg_encode <= 31)
+  if (reg_encode <= 31)
 return fpr_f0_riscv + reg_encode;
   return LLDB_INVALID_REGNUM;
 }



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D138618: [LLDB] Enable 64 bit debug/type offset

2022-11-23 Thread Alexander Yermolovich via Phabricator via lldb-commits
ayermolo created this revision.
Herald added subscribers: hoy, modimo, wenlei, arphaman.
Herald added a reviewer: shafik.
Herald added a project: All.
ayermolo published this revision for review.
Herald added a reviewer: jdoerfert.
Herald added subscribers: lldb-commits, sstefan1.
Herald added a project: LLDB.

This came out of from https://discourse.llvm.org/t/dwarf-dwp-4gb-limit/63902
With big binaries we can have .dwp files where .debug_info.dwo section can grow
beyond 4GB. We would like to support this in LLVM and in LLDB.

The plan is to enable manual parsing of cu/tu index in DWARF library
(https://reviews.llvm.org/D137882), and then
switch internal index data structure to 64 bit.
For the second part pre-requisite is to enable 64bit offset support in LLDB with
this patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138618

Files:
  lldb/include/lldb/Core/dwarf.h
  lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
  lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DIERef.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
  lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
  lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
  lldb/source/Symbol/DWARFCallFrameInfo.cpp
  lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
  lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwo.s
  lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp

Index: lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp
===
--- lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp
+++ lldb/unittests/SymbolFile/DWARF/DWARFIndexCachingTest.cpp
@@ -45,6 +45,26 @@
   EncodeDecode(DIERef(200, DIERef::Section::DebugTypes, 0x11223344));
 }
 
+TEST(DWARFIndexCachingTest, DIERefEncodeDecodeMax) {
+  // Tests DIERef::Encode(...) and DIERef::Decode(...)
+  EncodeDecode(DIERef(llvm::None, DIERef::Section::DebugInfo,
+  DIERef::k_die_offset_mask));
+  EncodeDecode(DIERef(llvm::None, DIERef::Section::DebugTypes,
+  DIERef::k_die_offset_mask));
+  EncodeDecode(
+  DIERef(100, DIERef::Section::DebugInfo, DIERef::k_die_offset_mask));
+  EncodeDecode(
+  DIERef(200, DIERef::Section::DebugTypes, DIERef::k_die_offset_mask));
+  EncodeDecode(DIERef(DIERef::k_dwo_num_mask, DIERef::Section::DebugInfo,
+  DIERef::k_dwo_num_mask));
+  EncodeDecode(DIERef(DIERef::k_dwo_num_mask, DIERef::Section::DebugTypes,
+  DIERef::k_dwo_num_mask));
+  EncodeDecode(
+  DIERef(DIERef::k_dwo_num_mask, DIERef::Section::DebugInfo, 0x11223344));
+  EncodeDecode(
+  DIERef(DIERef::k_dwo_num_mask, DIERef::Section::DebugTypes, 0x11223344));
+}
+
 static void EncodeDecode(const NameToDIE , ByteOrder byte_order) {
   const uint8_t addr_size = 8;
   DataEncoder encoder(byte_order, addr_size);
Index: lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwo.s
===
--- lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwo.s
+++ lldb/test/Shell/SymbolFile/DWARF/x86/debug_rnglists-dwo.s
@@ -4,9 +4,9 @@
 # RUN:   -o exit | FileCheck %s
 
 # CHECK-LABEL: image lookup -v -s lookup_rnglists
-# CHECK:  Function: id = {0x4028}, name = "rnglists", range = [0x-0x0003)
-# CHECK:Blocks: id = {0x4028}, range = [0x-0x0003)
-# CHECK-NEXT:   id = {0x4037}, range = [0x0001-0x0002)
+# CHECK:  Function: id = {0x2028}, name = "rnglists", range = [0x-0x0003)
+# CHECK:Blocks: id = {0x2028}, range = [0x-0x0003)
+# CHECK-NEXT:   id = {0x2037}, range = [0x0001-0x0002)
 
 .text
 rnglists:
Index: lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
===
--- lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
+++ lldb/test/Shell/SymbolFile/DWARF/DW_AT_range-DW_FORM_sec_offset.s
@@ -8,7 +8,7 @@
 # RUN:   -o exit | FileCheck %s
 
 # Failure was the block range 1..2 was not printed plus:
-# error: DW_AT_range-DW_FORM_sec_offset.s.tmp {0x003f}: DIE has 

[Lldb-commits] [PATCH] D138612: [lldb][NFC] Change FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE

2022-11-23 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 477611.
aeubanks added a comment.

update


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138612/new/

https://reviews.llvm.org/D138612

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -63,8 +63,8 @@
 
   UniqueDWARFASTTypeMap () override;
 
-  lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(
-  const DWARFDeclContext _decl_ctx) override;
+  lldb::TypeSP
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) override;
 
   lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
   const DWARFDIE , lldb_private::ConstString type_name,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -117,10 +117,9 @@
   return GetBaseSymbolFile().GetUniqueDWARFASTTypeMap();
 }
 
-lldb::TypeSP SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
-  return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(
-  die_decl_ctx);
+lldb::TypeSP
+SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) {
+  return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(die);
 }
 
 lldb::TypeSP SymbolFileDWARFDwo::FindCompleteObjCDefinitionTypeForDIE(
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -282,8 +282,7 @@
 
   CompileUnitInfo *GetCompileUnitInfo(SymbolFileDWARF *oso_dwarf);
 
-  lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext _decl_ctx);
+  lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(const DWARFDIE );
 
   bool Supports_DW_AT_APPLE_objc_complete_type(SymbolFileDWARF *skip_dwarf_oso);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -1125,10 +1125,10 @@
 }
 
 TypeSP SymbolFileDWARFDebugMap::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
+const DWARFDIE ) {
   TypeSP type_sp;
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
-type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
+type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die);
 return ((bool)type_sp);
   });
   return type_sp;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -443,7 +443,7 @@
lldb_private::SymbolContext );
 
   virtual lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext _decl_ctx);
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE );
 
   virtual lldb::TypeSP
   FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE ,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2946,119 +2946,113 @@
   return true;
 }
 
-TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
+TypeSP
+SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) {
   TypeSP type_sp;
 
-  const uint32_t dwarf_decl_ctx_count = dwarf_decl_ctx.GetSize();
-  if (dwarf_decl_ctx_count > 0) {
-const ConstString type_name(dwarf_decl_ctx[0].name);
-const dw_tag_t tag = dwarf_decl_ctx[0].tag;
+  const ConstString type_name(die.GetName());
+  if (type_name) {
+const dw_tag_t tag = die.Tag();
 
-if (type_name) {
-  Log *log = GetLog(DWARFLog::TypeCompletion | DWARFLog::Lookups);
-  if (log) {
- 

[Lldb-commits] [PATCH] D138612: [lldb][NFC] Change FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE

2022-11-23 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks updated this revision to Diff 477608.
aeubanks added a comment.
Herald added a subscriber: JDevlieghere.

update


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138612/new/

https://reviews.llvm.org/D138612

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -63,8 +63,8 @@
 
   UniqueDWARFASTTypeMap () override;
 
-  lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(
-  const DWARFDeclContext _decl_ctx) override;
+  lldb::TypeSP
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) override;
 
   lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
   const DWARFDIE , lldb_private::ConstString type_name,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -117,10 +117,9 @@
   return GetBaseSymbolFile().GetUniqueDWARFASTTypeMap();
 }
 
-lldb::TypeSP SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
-  return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(
-  die_decl_ctx);
+lldb::TypeSP
+SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) {
+  return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(die);
 }
 
 lldb::TypeSP SymbolFileDWARFDwo::FindCompleteObjCDefinitionTypeForDIE(
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -282,8 +282,7 @@
 
   CompileUnitInfo *GetCompileUnitInfo(SymbolFileDWARF *oso_dwarf);
 
-  lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext _decl_ctx);
+  lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(const DWARFDIE );
 
   bool Supports_DW_AT_APPLE_objc_complete_type(SymbolFileDWARF *skip_dwarf_oso);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -1125,10 +1125,10 @@
 }
 
 TypeSP SymbolFileDWARFDebugMap::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
+const DWARFDIE ) {
   TypeSP type_sp;
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
-type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
+type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die);
 return ((bool)type_sp);
   });
   return type_sp;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -443,7 +443,7 @@
lldb_private::SymbolContext );
 
   virtual lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext _decl_ctx);
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE );
 
   virtual lldb::TypeSP
   FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE ,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2946,119 +2946,113 @@
   return true;
 }
 
-TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
+TypeSP
+SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) {
   TypeSP type_sp;
 
-  const uint32_t dwarf_decl_ctx_count = dwarf_decl_ctx.GetSize();
-  if (dwarf_decl_ctx_count > 0) {
-const ConstString type_name(dwarf_decl_ctx[0].name);
-const dw_tag_t tag = dwarf_decl_ctx[0].tag;
+  const ConstString type_name(die.GetName());
+  if (type_name) {
+const dw_tag_t tag = die.Tag();
 
-if (type_name) {
-  Log *log = GetLog(DWARFLog::TypeCompletion 

[Lldb-commits] [PATCH] D138612: [lldb][NFC] Change FindDefinitionTypeForDWARFDeclContext() to take DWARFDIE

2022-11-23 Thread Arthur Eubanks via Phabricator via lldb-commits
aeubanks created this revision.
Herald added a reviewer: shafik.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This simplifies an upcoming patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138612

Files:
  lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h

Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h
@@ -63,8 +63,8 @@
 
   UniqueDWARFASTTypeMap () override;
 
-  lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(
-  const DWARFDeclContext _decl_ctx) override;
+  lldb::TypeSP
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) override;
 
   lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE(
   const DWARFDIE , lldb_private::ConstString type_name,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp
@@ -117,10 +117,9 @@
   return GetBaseSymbolFile().GetUniqueDWARFASTTypeMap();
 }
 
-lldb::TypeSP SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
-  return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(
-  die_decl_ctx);
+lldb::TypeSP
+SymbolFileDWARFDwo::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) {
+  return GetBaseSymbolFile().FindDefinitionTypeForDWARFDeclContext(die);
 }
 
 lldb::TypeSP SymbolFileDWARFDwo::FindCompleteObjCDefinitionTypeForDIE(
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -282,8 +282,7 @@
 
   CompileUnitInfo *GetCompileUnitInfo(SymbolFileDWARF *oso_dwarf);
 
-  lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext _decl_ctx);
+  lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(const DWARFDIE );
 
   bool Supports_DW_AT_APPLE_objc_complete_type(SymbolFileDWARF *skip_dwarf_oso);
 
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -1125,10 +1125,10 @@
 }
 
 TypeSP SymbolFileDWARFDebugMap::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
+const DWARFDIE ) {
   TypeSP type_sp;
   ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool {
-type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die_decl_ctx);
+type_sp = oso_dwarf->FindDefinitionTypeForDWARFDeclContext(die);
 return ((bool)type_sp);
   });
   return type_sp;
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -443,7 +443,7 @@
lldb_private::SymbolContext );
 
   virtual lldb::TypeSP
-  FindDefinitionTypeForDWARFDeclContext(const DWARFDeclContext _decl_ctx);
+  FindDefinitionTypeForDWARFDeclContext(const DWARFDIE );
 
   virtual lldb::TypeSP
   FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE ,
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2946,119 +2946,113 @@
   return true;
 }
 
-TypeSP SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(
-const DWARFDeclContext _decl_ctx) {
+TypeSP
+SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE ) {
   TypeSP type_sp;
 
-  const uint32_t dwarf_decl_ctx_count = dwarf_decl_ctx.GetSize();
-  if (dwarf_decl_ctx_count > 0) {
-const ConstString type_name(dwarf_decl_ctx[0].name);
-const dw_tag_t tag = dwarf_decl_ctx[0].tag;
+  const ConstString type_name(die.GetName());
+  if (type_name) {
+const dw_tag_t tag = die.Tag();
 
-if (type_name) {
-  Log *log = GetLog(DWARFLog::TypeCompletion | 

[Lldb-commits] [PATCH] D138539: Use std::nullopt_t instead of NoneType (NFC)

2022-11-23 Thread Kazu Hirata via Phabricator via lldb-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG34bcadc38c22: Use std::nullopt_t instead of NoneType (NFC) 
(authored by kazu).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138539/new/

https://reviews.llvm.org/D138539

Files:
  bolt/lib/Profile/DataAggregator.cpp
  bolt/lib/Profile/YAMLProfileWriter.cpp
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/clangd/support/ThreadsafeFS.h
  clang/include/clang/Analysis/Analyses/PostOrderCFGView.h
  clang/include/clang/Basic/DirectoryEntry.h
  clang/include/clang/Basic/FileEntry.h
  clang/include/clang/Sema/Template.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Tooling/Transformer/Parsing.cpp
  lldb/include/lldb/Utility/Timeout.h
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  llvm/include/llvm/ADT/ArrayRef.h
  llvm/include/llvm/ADT/Optional.h
  llvm/include/llvm/ADT/StringMapEntry.h
  llvm/include/llvm/ADT/StringSet.h
  llvm/include/llvm/FuzzMutate/OpDescriptor.h
  llvm/include/llvm/Support/SMLoc.h
  llvm/lib/CodeGen/MIRParser/MILexer.cpp
  llvm/lib/Support/Optional.cpp
  mlir/include/mlir/IR/OpDefinition.h
  mlir/include/mlir/IR/OperationSupport.h
  mlir/include/mlir/Support/Timing.h
  mlir/lib/Support/Timing.cpp

Index: mlir/lib/Support/Timing.cpp
===
--- mlir/lib/Support/Timing.cpp
+++ mlir/lib/Support/Timing.cpp
@@ -50,7 +50,7 @@
   llvm::sys::SmartRWMutex identifierMutex;
 
   /// A thread local cache of identifiers to reduce lock contention.
-  ThreadLocalCache *>>
+  ThreadLocalCache *>>
   localIdentifierCache;
 
   TimingManagerImpl() : identifiers(identifierAllocator) {}
Index: mlir/include/mlir/Support/Timing.h
===
--- mlir/include/mlir/Support/Timing.h
+++ mlir/include/mlir/Support/Timing.h
@@ -43,7 +43,7 @@
 /// This is a POD type with pointer size, so it should be passed around by
 /// value. The underlying data is owned by the `TimingManager`.
 class TimingIdentifier {
-  using EntryType = llvm::StringMapEntry;
+  using EntryType = llvm::StringMapEntry;
 
 public:
   TimingIdentifier(const TimingIdentifier &) = default;
Index: mlir/include/mlir/IR/OperationSupport.h
===
--- mlir/include/mlir/IR/OperationSupport.h
+++ mlir/include/mlir/IR/OperationSupport.h
@@ -490,7 +490,7 @@
   using size_type = size_t;
 
   NamedAttrList() : dictionarySorted({}, true) {}
-  NamedAttrList(llvm::NoneType none) : NamedAttrList() {}
+  NamedAttrList(std::nullopt_t none) : NamedAttrList() {}
   NamedAttrList(ArrayRef attributes);
   NamedAttrList(DictionaryAttr attributes);
   NamedAttrList(const_iterator inStart, const_iterator inEnd);
@@ -759,7 +759,7 @@
 class OpPrintingFlags {
 public:
   OpPrintingFlags();
-  OpPrintingFlags(llvm::NoneType) : OpPrintingFlags() {}
+  OpPrintingFlags(std::nullopt_t) : OpPrintingFlags() {}
 
   /// Enables the elision of large elements attributes by printing a lexically
   /// valid but otherwise meaningless form instead of the element data. The
Index: mlir/include/mlir/IR/OpDefinition.h
===
--- mlir/include/mlir/IR/OpDefinition.h
+++ mlir/include/mlir/IR/OpDefinition.h
@@ -41,7 +41,7 @@
   OptionalParseResult(ParseResult result) : impl(result) {}
   OptionalParseResult(const InFlightDiagnostic &)
   : OptionalParseResult(failure()) {}
-  OptionalParseResult(llvm::NoneType) : impl(llvm::None) {}
+  OptionalParseResult(std::nullopt_t) : impl(llvm::None) {}
 
   /// Returns true if we contain a valid ParseResult value.
   bool has_value() const { return impl.has_value(); }
Index: llvm/lib/Support/Optional.cpp
===
--- llvm/lib/Support/Optional.cpp
+++ llvm/lib/Support/Optional.cpp
@@ -9,6 +9,6 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/raw_ostream.h"
 
-llvm::raw_ostream ::operator<<(raw_ostream , NoneType) {
+llvm::raw_ostream ::operator<<(raw_ostream , std::nullopt_t) {
   return OS << "None";
 }
Index: llvm/lib/CodeGen/MIRParser/MILexer.cpp
===
--- llvm/lib/CodeGen/MIRParser/MILexer.cpp
+++ llvm/lib/CodeGen/MIRParser/MILexer.cpp
@@ -33,7 +33,7 @@
   const char *End = nullptr;
 
 public:
-  Cursor(NoneType) {}
+  Cursor(std::nullopt_t) {}
 
   explicit Cursor(StringRef Str) {
 Ptr = Str.data();
Index: llvm/include/llvm/Support/SMLoc.h
===
--- llvm/include/llvm/Support/SMLoc.h
+++ llvm/include/llvm/Support/SMLoc.h
@@ -50,7 +50,7 @@
   SMLoc Start, End;
 
   SMRange() = default;
-  SMRange(NoneType) {}
+  

[Lldb-commits] [lldb] 34bcadc - Use std::nullopt_t instead of NoneType (NFC)

2022-11-23 Thread Kazu Hirata via lldb-commits

Author: Kazu Hirata
Date: 2022-11-23T14:16:04-08:00
New Revision: 34bcadc38c2240807cd079fd03b93fc96cf64c84

URL: 
https://github.com/llvm/llvm-project/commit/34bcadc38c2240807cd079fd03b93fc96cf64c84
DIFF: 
https://github.com/llvm/llvm-project/commit/34bcadc38c2240807cd079fd03b93fc96cf64c84.diff

LOG: Use std::nullopt_t instead of NoneType (NFC)

This patch replaces those occurrences of NoneType that would trigger
an error if the definition of NoneType were missing in None.h.

To keep this patch focused, I am deliberately not replacing None with
std::nullopt in this patch or updating comments.  They will be
addressed in subsequent patches.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Differential Revision: https://reviews.llvm.org/D138539

Added: 


Modified: 
bolt/lib/Profile/DataAggregator.cpp
bolt/lib/Profile/YAMLProfileWriter.cpp
clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
clang-tools-extra/clangd/support/ThreadsafeFS.h
clang/include/clang/Analysis/Analyses/PostOrderCFGView.h
clang/include/clang/Basic/DirectoryEntry.h
clang/include/clang/Basic/FileEntry.h
clang/include/clang/Sema/Template.h
clang/lib/AST/ExprConstant.cpp
clang/lib/Tooling/Transformer/Parsing.cpp
lldb/include/lldb/Utility/Timeout.h
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
llvm/include/llvm/ADT/ArrayRef.h
llvm/include/llvm/ADT/Optional.h
llvm/include/llvm/ADT/StringMapEntry.h
llvm/include/llvm/ADT/StringSet.h
llvm/include/llvm/FuzzMutate/OpDescriptor.h
llvm/include/llvm/Support/SMLoc.h
llvm/lib/CodeGen/MIRParser/MILexer.cpp
llvm/lib/Support/Optional.cpp
mlir/include/mlir/IR/OpDefinition.h
mlir/include/mlir/IR/OperationSupport.h
mlir/include/mlir/Support/Timing.h
mlir/lib/Support/Timing.cpp

Removed: 




diff  --git a/bolt/lib/Profile/DataAggregator.cpp 
b/bolt/lib/Profile/DataAggregator.cpp
index 1cf2e72fba8d2..3befa8bac2d98 100644
--- a/bolt/lib/Profile/DataAggregator.cpp
+++ b/bolt/lib/Profile/DataAggregator.cpp
@@ -2233,7 +2233,7 @@ DataAggregator::writeAggregatedFile(StringRef 
OutputFilename) const {
 OutFile << "boltedcollection\n";
   if (opts::BasicAggregation) {
 OutFile << "no_lbr";
-for (const StringMapEntry  : EventNames)
+for (const StringMapEntry  : EventNames)
   OutFile << " " << Entry.getKey();
 OutFile << "\n";
 

diff  --git a/bolt/lib/Profile/YAMLProfileWriter.cpp 
b/bolt/lib/Profile/YAMLProfileWriter.cpp
index 03f3ac36f373f..84c060fef136a 100644
--- a/bolt/lib/Profile/YAMLProfileWriter.cpp
+++ b/bolt/lib/Profile/YAMLProfileWriter.cpp
@@ -161,7 +161,7 @@ std::error_code YAMLProfileWriter::writeProfile(const 
RewriteInstance ) {
   StringSet<> EventNames = RI.getProfileReader()->getEventNames();
   if (!EventNames.empty()) {
 std::string Sep;
-for (const StringMapEntry  : EventNames) {
+for (const StringMapEntry  : EventNames) {
   BP.Header.EventNames += Sep + EventEntry.first().str();
   Sep = ",";
 }

diff  --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
index 73b47dca20930..ba1f4d4ebe2ef 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -214,7 +214,7 @@ class NameLookup {
 
 public:
   explicit NameLookup(const NamedDecl *ND) : Data(ND, false) {}
-  explicit NameLookup(llvm::NoneType) : Data(nullptr, true) {}
+  explicit NameLookup(std::nullopt_t) : Data(nullptr, true) {}
   explicit NameLookup(std::nullptr_t) : Data(nullptr, false) {}
   NameLookup() : NameLookup(nullptr) {}
 

diff  --git a/clang-tools-extra/clangd/support/ThreadsafeFS.h 
b/clang-tools-extra/clangd/support/ThreadsafeFS.h
index b518c03e36969..7268ac742ce36 100644
--- a/clang-tools-extra/clangd/support/ThreadsafeFS.h
+++ b/clang-tools-extra/clangd/support/ThreadsafeFS.h
@@ -30,7 +30,7 @@ class ThreadsafeFS {
 
   /// Obtain a vfs::FileSystem with an arbitrary initial working directory.
   llvm::IntrusiveRefCntPtr
-  view(llvm::NoneType CWD) const {
+  view(std::nullopt_t CWD) const {
 return viewImpl();
   }
 

diff  --git a/clang/include/clang/Analysis/Analyses/PostOrderCFGView.h 
b/clang/include/clang/Analysis/Analyses/PostOrderCFGView.h
index 1000298945602..0b306d14be4d8 100644
--- a/clang/include/clang/Analysis/Analyses/PostOrderCFGView.h
+++ b/clang/include/clang/Analysis/Analyses/PostOrderCFGView.h
@@ -48,7 +48,7 @@ class PostOrderCFGView : public ManagedAnalysis {
 
 /// Set the bit associated with a particular CFGBlock.
 /// This is the important method for the SetType template parameter.
-std::pair 

[Lldb-commits] [lldb] 8b95d08 - Unbreak lldb build broken by d941fceca8e9

2022-11-23 Thread Benjamin Kramer via lldb-commits

Author: Benjamin Kramer
Date: 2022-11-23T21:01:47+01:00
New Revision: 8b95d08799cabaebf9b7549356e0552a17791dc6

URL: 
https://github.com/llvm/llvm-project/commit/8b95d08799cabaebf9b7549356e0552a17791dc6
DIFF: 
https://github.com/llvm/llvm-project/commit/8b95d08799cabaebf9b7549356e0552a17791dc6.diff

LOG: Unbreak lldb build broken by d941fceca8e9

Added: 


Modified: 
lldb/source/Symbol/CompilerType.cpp

Removed: 




diff  --git a/lldb/source/Symbol/CompilerType.cpp 
b/lldb/source/Symbol/CompilerType.cpp
index d30c9d87fa48..34dc7140c1fd 100644
--- a/lldb/source/Symbol/CompilerType.cpp
+++ b/lldb/source/Symbol/CompilerType.cpp
@@ -96,7 +96,8 @@ bool CompilerType::IsCompleteType() const {
 
 bool CompilerType::IsForcefullyCompleted() const {
   if (IsValid())
-return m_type_system->IsForcefullyCompleted(m_type);
+if (auto type_system_sp = GetTypeSystem())
+  return type_system_sp->IsForcefullyCompleted(m_type);
   return false;
 }
 



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D138539: Use std::nullopt_t instead of NoneType (NFC)

2022-11-23 Thread Fangrui Song via Phabricator via lldb-commits
MaskRay added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp:218
+  explicit NameLookup(std::nullopt_t) : Data(nullptr, true) {}
   explicit NameLookup(std::nullptr_t) : Data(nullptr, false) {}
   NameLookup() : NameLookup(nullptr) {}

A maintainer might want to check the uses. Having 3 constructors looks 
confusing to readers.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138539/new/

https://reviews.llvm.org/D138539

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D138589: Add runToBinaryEntry option for lldb-vscode

2022-11-23 Thread jeffrey tan via Phabricator via lldb-commits
yinghuitan abandoned this revision.
yinghuitan added a comment.

Discussed offline. We can't rely on initialized event because it has to happen 
before all breakpoints are set. Will create a new design for htis.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138589/new/

https://reviews.llvm.org/D138589

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D138259: Add the ability to see when a type in incomplete.

2022-11-23 Thread Martin Storsjö via Phabricator via lldb-commits
mstorsjo added a comment.

This seems to have caused build errors with GCC:

  ../tools/lldb/source/Symbol/CompilerType.cpp: In member function ‘bool 
lldb_private::CompilerType::IsForcefullyCompleted() const’:
  ../tools/lldb/source/Symbol/CompilerType.cpp:99:25: error: base operand of 
‘->’ has non-pointer type ‘const TypeSystemWP’ {aka ‘const 
std::weak_ptr’}
 99 | return m_type_system->IsForcefullyCompleted(m_type);
| ^~

Any clues about what’s missing?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138259/new/

https://reviews.llvm.org/D138259

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D138589: Add runToBinaryEntry option for lldb-vscode

2022-11-23 Thread Greg Clayton via Phabricator via lldb-commits
clayborg added a comment.

Ideally this feature would enable a one shot breakpoint and let the startup 
happen just like it was before this patch.

We don't want the user to see this stop right? It seems like we should allow 
some commands to be run with this one shot breakpoint and have it auto 
continue? What is supposed to happen now? the IDE knows that it set this 
startup option and then does something on the first stop?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138589/new/

https://reviews.llvm.org/D138589

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D138539: Use std::nullopt_t instead of NoneType (NFC)

2022-11-23 Thread David Blaikie via Phabricator via lldb-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Sounds good to me, thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138539/new/

https://reviews.llvm.org/D138539

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D138589: Add runToBinaryEntry option for lldb-vscode

2022-11-23 Thread Greg Clayton via Phabricator via lldb-commits
clayborg requested changes to this revision.
clayborg added a comment.
This revision now requires changes to proceed.

We have to let the IDE set breakpoints after the "initialized" packet is sent 
and _then_ do this functionality. So this patch needs to be modified to make 
that happen.




Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:1807-1809
+  if (error.Success())
+error = RunToBinaryEntry();
+

If this synchronously runs to the entry point of the program prior to letting 
the IDE set breakpoints (which happens when the "initialized" packet is sent), 
then we can't do this. We can miss breakpoints if they are set in the C++ 
global initializer lists. The flow with this in here will not stop at the entry 
point and allow the IDE to set breakpoints first and this must happen. 



Comment at: lldb/tools/lldb-vscode/package.json:162
+   "type": 
"boolean",
+   "description": 
"run to program entry one-shot breakpoint during launch to ensure dependency 
modules are loaded.",
+   "default": false

Description should be capitalized correct and the language is a bit off "run to 
program entry one-shot breakpoint"? Did you mean "run to program entry using a 
one-shot breakpoint"?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138589/new/

https://reviews.llvm.org/D138589

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D138259: Add the ability to see when a type in incomplete.

2022-11-23 Thread Greg Clayton via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd941fceca8e9: Add the ability to see when a type in 
incomplete. (authored by clayborg).

Changed prior to commit:
  https://reviews.llvm.org/D138259?vs=477314=477548#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138259/new/

https://reviews.llvm.org/D138259

Files:
  lldb/include/lldb/Symbol/CompilerType.h
  lldb/include/lldb/Symbol/TypeSystem.h
  lldb/source/API/SBType.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
  lldb/source/Symbol/CompilerType.cpp
  lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
  lldb/unittests/Symbol/TestTypeSystemClang.cpp

Index: lldb/unittests/Symbol/TestTypeSystemClang.cpp
===
--- lldb/unittests/Symbol/TestTypeSystemClang.cpp
+++ lldb/unittests/Symbol/TestTypeSystemClang.cpp
@@ -405,7 +405,7 @@
 
   RecordDecl *empty_base_decl = TypeSystemClang::GetAsRecordDecl(empty_base);
   EXPECT_NE(nullptr, empty_base_decl);
-  EXPECT_FALSE(TypeSystemClang::RecordHasFields(empty_base_decl));
+  EXPECT_FALSE(m_ast->RecordHasFields(empty_base_decl));
 
   // Test that a record with direct fields returns true
   CompilerType non_empty_base = m_ast->CreateRecordType(
@@ -419,7 +419,7 @@
   TypeSystemClang::GetAsRecordDecl(non_empty_base);
   EXPECT_NE(nullptr, non_empty_base_decl);
   EXPECT_NE(nullptr, non_empty_base_field_decl);
-  EXPECT_TRUE(TypeSystemClang::RecordHasFields(non_empty_base_decl));
+  EXPECT_TRUE(m_ast->RecordHasFields(non_empty_base_decl));
 
   std::vector> bases;
 
@@ -440,10 +440,9 @@
   m_ast->GetAsCXXRecordDecl(empty_derived.GetOpaqueQualType());
   RecordDecl *empty_derived_non_empty_base_decl =
   TypeSystemClang::GetAsRecordDecl(empty_derived);
-  EXPECT_EQ(1u, TypeSystemClang::GetNumBaseClasses(
+  EXPECT_EQ(1u, m_ast->GetNumBaseClasses(
 empty_derived_non_empty_base_cxx_decl, false));
-  EXPECT_TRUE(
-  TypeSystemClang::RecordHasFields(empty_derived_non_empty_base_decl));
+  EXPECT_TRUE(m_ast->RecordHasFields(empty_derived_non_empty_base_decl));
 
   // Test that a record with no direct fields, but fields in a virtual base
   // returns true
@@ -463,10 +462,10 @@
   m_ast->GetAsCXXRecordDecl(empty_derived2.GetOpaqueQualType());
   RecordDecl *empty_derived_non_empty_vbase_decl =
   TypeSystemClang::GetAsRecordDecl(empty_derived2);
-  EXPECT_EQ(1u, TypeSystemClang::GetNumBaseClasses(
+  EXPECT_EQ(1u, m_ast->GetNumBaseClasses(
 empty_derived_non_empty_vbase_cxx_decl, false));
   EXPECT_TRUE(
-  TypeSystemClang::RecordHasFields(empty_derived_non_empty_vbase_decl));
+  m_ast->RecordHasFields(empty_derived_non_empty_vbase_decl));
 }
 
 TEST_F(TestTypeSystemClang, TemplateArguments) {
@@ -980,4 +979,3 @@
   ModuleSP module = t.GetExeModule();
   EXPECT_EQ(module.get(), nullptr);
 }
-
Index: lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
===
--- lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
+++ lldb/test/API/functionalities/limit-debug-info/TestLimitDebugInfo.py
@@ -16,10 +16,12 @@
 type_ = exe.FindFirstType(name)
 self.trace("type_: %s"%type_)
 self.assertTrue(type_)
+self.assertTrue(type_.IsTypeComplete())
 base = type_.GetDirectBaseClassAtIndex(0).GetType()
 self.trace("base:%s"%base)
 self.assertTrue(base)
 self.assertEquals(base.GetNumberOfFields(), 0)
+self.assertFalse(base.IsTypeComplete())
 
 def _check_debug_info_is_limited(self, target):
 # Without other shared libraries we should only see the member declared
@@ -28,6 +30,100 @@
 self._check_type(target, "InheritsFromOne")
 self._check_type(target, "InheritsFromTwo")
 
+def _check_incomplete_frame_variable_output(self):
+# Check that the display of the "frame variable" output identifies the
+# incomplete types. Currently the expression parser will find the real
+# definition for a type when running an expression for any forcefully
+# completed types, but "frame variable" won't. I hope to fix this with
+# a follow up patch, but if we don't find the actual definition we
+# should clearly show this to the user by showing which types were
+# incomplete. So this will test verifies the expected output for such
+# types. We also need to verify the standard "frame variable" output
+# which will inline all of the members on one line, versus the full
+# output from "frame variable --raw" and a few other options.
+# self.expect("frame variable two_as_member", error=True,
+# substrs=["no member named 'one' in 

[Lldb-commits] [lldb] d941fce - Add the ability to see when a type in incomplete.

2022-11-23 Thread Greg Clayton via lldb-commits

Author: Greg Clayton
Date: 2022-11-23T10:07:12-08:00
New Revision: d941fceca8e9bc9b5a00c9865ee022ba5507df32

URL: 
https://github.com/llvm/llvm-project/commit/d941fceca8e9bc9b5a00c9865ee022ba5507df32
DIFF: 
https://github.com/llvm/llvm-project/commit/d941fceca8e9bc9b5a00c9865ee022ba5507df32.diff

LOG: Add the ability to see when a type in incomplete.

-flimit-debug-info and other compiler options might end up removing debug info 
that is needed for debugging. LLDB marks these types as being forcefully 
completed in the metadata in the TypeSystem. These types should have been 
complete in the debug info but were not because the compiler omitted them to 
save space. When we can't find a suitable replacement for the type, we should 
let the user know that these types are incomplete to indicate there was an 
issue instead of just showing nothing for a type.

The solution is to display presented in this patch is to display "" as the summary for any incomplete types. If there is a summary string or 
function that is provided for a type, but the type is currently forcefully 
completed, the installed summary will be ignored and we will display 
"". This patch also exposes the ability to ask a SBType if it 
was forcefully completed with:

  bool SBType::IsTypeForcefullyCompleted();

This will allow the user interface for a debugger to also detect this issue and 
possibly mark the variable display up on some way to indicate to the user the 
type is incomplete.

To show how this is diplayed, we can look at the existing output first for the 
example source file from the file: 
lldb/test/API/functionalities/limit-debug-info/main.cpp

(lldb) frame variable inherits_from_one inherits_from_two one_as_member 
two_as_member array_of_one array_of_two shadowed_one
(InheritsFromOne) ::inherits_from_one = (member = 47)
(InheritsFromTwo) ::inherits_from_two = (member = 47)
(OneAsMember) ::one_as_member = (one = member::One @ 0x00018028, member 
= 47)
(TwoAsMember) ::two_as_member = (two = member::Two @ 0x00018040, member 
= 47)
(array::One [3]) ::array_of_one = ([0] = array::One @ 0x00018068, [1] = 
array::One @ 0x00018069, [2] = array::One @ 0x0001806a)
(array::Two [3]) ::array_of_two = ([0] = array::Two @ 0x00018098, [1] = 
array::Two @ 0x00018099, [2] = array::Two @ 0x0001809a)
(ShadowedOne) ::shadowed_one = (member = 47)
(lldb) frame variable --show-types inherits_from_one inherits_from_two 
one_as_member two_as_member array_of_one array_of_two shadowed_one
(InheritsFromOne) ::inherits_from_one = {
  (int) member = 47
}
(InheritsFromTwo) ::inherits_from_two = {
  (int) member = 47
}
(OneAsMember) ::one_as_member = {
  (member::One) one = {}
  (int) member = 47
}
(TwoAsMember) ::two_as_member = {
  (member::Two) two = {}
  (int) member = 47
}
(array::One [3]) ::array_of_one = {
  (array::One) [0] = {}
  (array::One) [1] = {}
  (array::One) [2] = {}
}
(array::Two [3]) ::array_of_two = {
  (array::Two) [0] = {}
  (array::Two) [1] = {}
  (array::Two) [2] = {}
}
(ShadowedOne) ::shadowed_one = {
  (int) member = 47
}

With this patch in place we can now see any classes that were forcefully 
completed to let us know that we are missing information:

(lldb) frame variable inherits_from_one inherits_from_two one_as_member 
two_as_member array_of_one array_of_two shadowed_one
(InheritsFromOne) ::inherits_from_one = (One = , member = 47)
(InheritsFromTwo) ::inherits_from_two = (Two = , member = 47)
(OneAsMember) ::one_as_member = (one = , member = 47)
(TwoAsMember) ::two_as_member = (two = , member = 47)
(array::One[3]) ::array_of_one = ([0] = , [1] = , [2] = )
(array::Two[3]) ::array_of_two = ([0] = , [1] = , [2] = )
(ShadowedOne) ::shadowed_one = (func_shadow::One = , member = 
47)
(lldb) frame variable --show-types inherits_from_one inherits_from_two 
one_as_member two_as_member array_of_one array_of_two shadowed_one
(InheritsFromOne) ::inherits_from_one = {
  (One) One =  {}
  (int) member = 47
}
(InheritsFromTwo) ::inherits_from_two = {
  (Two) Two =  {}
  (int) member = 47
}
(OneAsMember) ::one_as_member = {
  (member::One) one =  {}
  (int) member = 47
}
(TwoAsMember) ::two_as_member = {
  (member::Two) two =  {}
  (int) member = 47
}
(array::One[3]) ::array_of_one = {
  (array::One) [0] =  {}
  (array::One) [1] =  {}
  (array::One) [2] =  {}
}
(array::Two[3]) ::array_of_two = {
  (array::Two) [0] =  {}
  (array::Two) [1] =  {}
  (array::Two) [2] =  {}
}
(ShadowedOne) ::shadowed_one = {
  (func_shadow::One) func_shadow::One =  {}
  (int) member = 47
}

Differential Revision: https://reviews.llvm.org/D138259

Added: 


Modified: 
lldb/include/lldb/Symbol/CompilerType.h
lldb/include/lldb/Symbol/TypeSystem.h
lldb/source/API/SBType.cpp
lldb/source/Core/ValueObject.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/source/Symbol/CompilerType.cpp

[Lldb-commits] [PATCH] D138589: Add runToBinaryEntry option for lldb-vscode

2022-11-23 Thread jeffrey tan via Phabricator via lldb-commits
yinghuitan created this revision.
yinghuitan added reviewers: clayborg, labath, jingham, jdoerfert, JDevlieghere, 
kusmour, GeorgeHuyubo.
Herald added a project: All.
yinghuitan requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This patch adds a new runToBinaryEntry option which sets a one-shot breakpoint
at program entry. This option is useful for synchronizing module loading with
dynamic loader to measure debugger startup performance: when program entry
one-short breakpoint hits most of the dependency modules should have been
loaded so this provides a good sample point for debugger startup time.

More explicitly for lldb-vscode, when this option is enabled, "Initialized" DAP
event is synchronously sent after most dependency modules are loaded.

Note: this is re-submission of https://reviews.llvm.org/D135798


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138589

Files:
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
  lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
  lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/VSCode.h
  lldb/tools/lldb-vscode/lldb-vscode.cpp
  lldb/tools/lldb-vscode/package.json

Index: lldb/tools/lldb-vscode/package.json
===
--- lldb/tools/lldb-vscode/package.json
+++ lldb/tools/lldb-vscode/package.json
@@ -157,6 +157,11 @@
 "description": "Automatically stop after launch.",
 "default": false
 			},
+			"runToBinaryEntry": {
+"type": "boolean",
+"description": "run to program entry one-shot breakpoint during launch to ensure dependency modules are loaded.",
+"default": false
+			},
 			"disableASLR": {
 "type": "boolean",
 "description": "Enable or disable Address space layout randomization if the debugger supports it.",
Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -1610,6 +1610,68 @@
  error.GetCString());
 }
 
+lldb::SBError RunToBinaryEntry() {
+  lldb::SBError error;
+  if (!g_vsc.run_to_binary_entry)
+return error;
+
+  if (g_vsc.stop_at_entry) {
+g_vsc.SendOutput(OutputType::Console,
+ "RunToBinaryEntry is ignored due to StopOnEntry\n");
+return error;
+  }
+
+  lldb::SBTarget target = g_vsc.debugger.GetSelectedTarget();
+  if (!target.IsValid())
+return error;
+  lldb::SBFileSpec exe_file = target.GetExecutable();
+  if (!exe_file.IsValid())
+return error;
+  lldb::SBModule exe_module = target.FindModule(exe_file);
+  if (!exe_module.IsValid()) {
+g_vsc.SendOutput(OutputType::Console,
+ "RunToBinaryEntry failed: invalid executable module\n");
+return error;
+  }
+
+  lldb::SBAddress entry_point = exe_module.GetObjectFileEntryPointAddress();
+  if (!entry_point.IsValid()) {
+g_vsc.SendOutput(OutputType::Console,
+ "RunToBinaryEntry failed: can't find entry point\n");
+return error;
+  }
+  lldb::SBBreakpoint entry_breakpoint =
+  target.BreakpointCreateBySBAddress(entry_point);
+  if (!entry_breakpoint.IsValid() || entry_breakpoint.GetNumLocations() == 0) {
+g_vsc.SendOutput(OutputType::Console,
+ "RunToBinaryEntry failed: can't resolve the entry point breakpoint\n");
+return error;
+  }
+
+  uint32_t old_stop_id = target.GetProcess().GetStopID();
+  entry_breakpoint.SetOneShot(true);
+  error = target.GetProcess().Continue();
+  if (error.Fail())
+return error;
+
+  const uint64_t timeout_seconds = 600;
+  error = g_vsc.WaitForProcessToStop(timeout_seconds, old_stop_id);
+  if (error.Fail())
+return error;
+
+  // Successfully got a process stop; we still need to check if the stop is what
+  // we expected.
+  if (entry_breakpoint.GetHitCount() == 0)
+g_vsc.SendOutput(OutputType::Telemetry,
+ "RunToBinaryEntry failed: process stopped not at the "
+ "binary's entry point\n");
+  else
+g_vsc.SendOutput(OutputType::Telemetry,
+ "RunToBinaryEntry success: Process stopped successfully "
+ "at the binary's entry point\n");
+  return error;
+}
+
 // "LaunchRequest": {
 //   "allOf": [ { "$ref": "#/definitions/Request" }, {
 // "type": "object",
@@ -1659,6 +1721,7 @@
   std::vector postRunCommands =
   GetStrings(arguments, "postRunCommands");
   g_vsc.stop_at_entry = GetBoolean(arguments, "stopOnEntry", false);
+  g_vsc.run_to_binary_entry = GetBoolean(arguments, "runToBinaryEntry", false);
   const llvm::StringRef debuggerRoot = GetString(arguments, "debuggerRoot");
   const uint64_t timeout_seconds = GetUnsigned(arguments, "timeout", 30);
 

[Lldb-commits] [PATCH] D138447: [LLDB][RISCV] Add RV32F instruction support for EmulateInstructionRISCV

2022-11-23 Thread Emmmer S via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6d4ab6d92179: [LLDB][RISCV] Add RV32F instruction support 
for EmulateInstructionRISCV (authored by Emmmer).
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138447/new/

https://reviews.llvm.org/D138447

Files:
  lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
  lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h
  lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h
  lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.h
  lldb/unittests/Instruction/RISCV/TestRISCVEmulator.cpp

Index: lldb/unittests/Instruction/RISCV/TestRISCVEmulator.cpp
===
--- lldb/unittests/Instruction/RISCV/TestRISCVEmulator.cpp
+++ lldb/unittests/Instruction/RISCV/TestRISCVEmulator.cpp
@@ -24,6 +24,7 @@
 
 struct RISCVEmulatorTester : public EmulateInstructionRISCV, testing::Test {
   RegisterInfoPOSIX_riscv64::GPR gpr;
+  RegisterInfoPOSIX_riscv64::FPR fpr;
   uint8_t memory[1024] = {0};
 
   RISCVEmulatorTester()
@@ -32,6 +33,7 @@
 EmulateInstruction::SetWriteRegCallback(WriteRegisterCallback);
 EmulateInstruction::SetReadMemCallback(ReadMemoryCallback);
 EmulateInstruction::SetWriteMemCallback(WriteMemoryCallback);
+ClearAll();
   }
 
   static bool ReadRegisterCallback(EmulateInstruction *instruction, void *baton,
@@ -41,8 +43,13 @@
 uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
 if (reg == gpr_x0_riscv)
   reg_value.SetUInt(0, reg_info->byte_size);
-else
+if (reg >= gpr_pc_riscv && reg <= gpr_x31_riscv)
   reg_value.SetUInt(tester->gpr.gpr[reg], reg_info->byte_size);
+if (reg >= fpr_f0_riscv && reg <= fpr_f31_riscv)
+  reg_value.SetUInt(tester->fpr.fpr[reg - fpr_f0_riscv],
+reg_info->byte_size);
+if (reg == fpr_fcsr_riscv)
+  reg_value.SetUInt(tester->fpr.fcsr, reg_info->byte_size);
 return true;
   }
 
@@ -52,8 +59,12 @@
 const RegisterValue _value) {
 RISCVEmulatorTester *tester = (RISCVEmulatorTester *)instruction;
 uint32_t reg = reg_info->kinds[eRegisterKindLLDB];
-if (reg != gpr_x0_riscv)
+if (reg >= gpr_pc_riscv && reg <= gpr_x31_riscv)
   tester->gpr.gpr[reg] = reg_value.GetAsUInt64();
+if (reg >= fpr_f0_riscv && reg <= fpr_f31_riscv)
+  tester->fpr.fpr[reg - fpr_f0_riscv] = reg_value.GetAsUInt64();
+if (reg == fpr_fcsr_riscv)
+  tester->fpr.fcsr = reg_value.GetAsUInt32();
 return true;
   }
 
@@ -81,6 +92,12 @@
 .transform([&](DecodeResult res) { return Execute(res, ignore_cond); })
 .value_or(false);
   }
+
+  void ClearAll() {
+memset(, 0, sizeof(gpr));
+memset(, 0, sizeof(fpr));
+memset(memory, 0, sizeof(memory));
+  }
 };
 
 TEST_F(RISCVEmulatorTester, testJAL) {
@@ -155,8 +172,8 @@
 
 using EncoderB = uint32_t (*)(uint32_t rs1, uint32_t rs2, int32_t offset);
 
-void testBranch(RISCVEmulatorTester *tester, EncoderB encoder, bool branched,
-uint64_t rs1, uint64_t rs2) {
+static void testBranch(RISCVEmulatorTester *tester, EncoderB encoder,
+   bool branched, uint64_t rs1, uint64_t rs2) {
   // prepare test registers
   lldb::addr_t old_pc = 0x114514;
   tester->WritePC(old_pc);
@@ -178,12 +195,13 @@
 testBranch(this, name, false, rs1, rs2_continued); \
   }
 
-void CheckRD(RISCVEmulatorTester *tester, uint64_t rd, uint64_t value) {
+static void CheckRD(RISCVEmulatorTester *tester, uint64_t rd, uint64_t value) {
   ASSERT_EQ(tester->gpr.gpr[rd], value);
 }
 
 template 
-void CheckMem(RISCVEmulatorTester *tester, uint64_t addr, uint64_t value) {
+static void CheckMem(RISCVEmulatorTester *tester, uint64_t addr,
+ uint64_t value) {
   auto mem = tester->ReadMem(addr);
   ASSERT_TRUE(mem.has_value());
   ASSERT_EQ(*mem, value);
@@ -194,8 +212,8 @@
 using PC = uint64_t;
 using RDComputer = std::function;
 
-void TestInst(RISCVEmulatorTester *tester, DecodeResult inst, bool has_rs2,
-  RDComputer rd_val) {
+static void TestInst(RISCVEmulatorTester *tester, DecodeResult inst,
+ bool has_rs2, RDComputer rd_val) {
 
   lldb::addr_t old_pc = 0x114514;
   tester->WritePC(old_pc);
@@ -223,8 +241,8 @@
 }
 
 template 
-void TestAtomic(RISCVEmulatorTester *tester, uint64_t inst, T rs1_val,
-T rs2_val, T rd_expected, T mem_expected) {
+static void TestAtomic(RISCVEmulatorTester *tester, uint64_t inst, T rs1_val,
+   T rs2_val, T rd_expected, T mem_expected) {
   // Atomic inst must have rs1 and rs2
 
   uint32_t rd = DecodeRD(inst);
@@ -261,7 +279,7 @@
   RISCVInst inst_type;
 };
 
-bool compareInst(const RISCVInst , const RISCVInst ) {
+static bool compareInst(const RISCVInst , const RISCVInst ) {
   if 

[Lldb-commits] [lldb] 6d4ab6d - [LLDB][RISCV] Add RV32F instruction support for EmulateInstructionRISCV

2022-11-23 Thread via lldb-commits

Author: Emmmer
Date: 2022-11-23T22:09:14+08:00
New Revision: 6d4ab6d921792125969e5f917b84cc810a1ba95c

URL: 
https://github.com/llvm/llvm-project/commit/6d4ab6d921792125969e5f917b84cc810a1ba95c
DIFF: 
https://github.com/llvm/llvm-project/commit/6d4ab6d921792125969e5f917b84cc810a1ba95c.diff

LOG: [LLDB][RISCV] Add RV32F instruction support for EmulateInstructionRISCV

Add:

- RV32F instruction set.
- corresponding unittests.

Further work:

- RV32FC, RV64F and RV64FC instructions support.
- update execution exceptions to fcsr register in RVM instructions.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D138447

Added: 


Modified: 
lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h
lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h
lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_riscv64.h
lldb/unittests/Instruction/RISCV/TestRISCVEmulator.cpp

Removed: 




diff  --git a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp 
b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
index c05b43f300fda..ca7adff785d99 100644
--- a/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
+++ b/lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
@@ -101,6 +101,12 @@ static uint32_t GPREncodingToLLDB(uint32_t reg_encode) {
   return LLDB_INVALID_REGNUM;
 }
 
+static uint32_t FPREncodingToLLDB(uint32_t reg_encode) {
+  if (reg_encode >= 0 && reg_encode <= 31)
+return fpr_f0_riscv + reg_encode;
+  return LLDB_INVALID_REGNUM;
+}
+
 bool Rd::Write(EmulateInstructionRISCV , uint64_t value) {
   uint32_t lldb_reg = GPREncodingToLLDB(rd);
   EmulateInstruction::Context ctx;
@@ -112,6 +118,17 @@ bool Rd::Write(EmulateInstructionRISCV , uint64_t 
value) {
 registerValue);
 }
 
+bool Rd::WriteAPFloat(EmulateInstructionRISCV , llvm::APFloat value) {
+  uint32_t lldb_reg = FPREncodingToLLDB(rd);
+  EmulateInstruction::Context ctx;
+  ctx.type = EmulateInstruction::eContextRegisterStore;
+  ctx.SetNoArgs();
+  RegisterValue registerValue;
+  registerValue.SetUInt64(value.bitcastToAPInt().getZExtValue());
+  return emulator.WriteRegister(ctx, eRegisterKindLLDB, lldb_reg,
+registerValue);
+}
+
 llvm::Optional Rs::Read(EmulateInstructionRISCV ) {
   uint32_t lldbReg = GPREncodingToLLDB(rs);
   RegisterValue value;
@@ -135,6 +152,18 @@ llvm::Optional 
Rs::ReadU32(EmulateInstructionRISCV ) {
   [](uint64_t value) { return uint32_t(value); });
 }
 
+llvm::Optional Rs::ReadAPFloat(EmulateInstructionRISCV 
,
+  bool isDouble) {
+  uint32_t lldbReg = FPREncodingToLLDB(rs);
+  RegisterValue value;
+  if (!emulator.ReadRegister(eRegisterKindLLDB, lldbReg, value))
+return llvm::None;
+  uint64_t bits = value.GetAsUInt64();
+  llvm::APInt api(64, bits, false);
+  return llvm::APFloat(isDouble ? llvm::APFloat(api.bitsToDouble())
+: llvm::APFloat(api.bitsToFloat()));
+}
+
 static bool CompareB(uint64_t rs1, uint64_t rs2, uint32_t funct3) {
   switch (funct3) {
   case BEQ:
@@ -356,7 +385,7 @@ template  static RISCVInst DecodeIType(uint32_t 
inst) {
 
 template  static RISCVInst DecodeBType(uint32_t inst) {
   return T{Rs{DecodeRS1(inst)}, Rs{DecodeRS2(inst)}, DecodeBImm(inst),
-   (inst & 0x7000) >> 12};
+   DecodeFunct3(inst)};
 }
 
 template  static RISCVInst DecodeSType(uint32_t inst) {
@@ -375,6 +404,11 @@ template  static RISCVInst 
DecodeRRS1Type(uint32_t inst) {
   return T{Rd{DecodeRD(inst)}, Rs{DecodeRS1(inst)}};
 }
 
+template  static RISCVInst DecodeR4Type(uint32_t inst) {
+  return T{Rd{DecodeRD(inst)}, Rs{DecodeRS1(inst)}, Rs{DecodeRS2(inst)},
+   Rs{DecodeRS3(inst)}, DecodeRM(inst)};
+}
+
 static const InstrPattern PATTERNS[] = {
 // RV32I & RV64I (The base integer ISA) //
 {"LUI", 0x7F, 0x37, DecodeUType},
@@ -492,6 +526,34 @@ static const InstrPattern PATTERNS[] = {
 {"C_SUB", 0xFC63, 0x8C01, DecodeC_SUB},
 {"C_SUBW", 0xFC63, 0x9C01, DecodeC_SUBW},
 {"C_ADDW", 0xFC63, 0x9C21, DecodeC_ADDW},
+
+// RV32F (Extension for Single-Precision Floating-Point) //
+{"FLW", 0x707F, 0x2007, DecodeIType},
+{"FSW", 0x707F, 0x2027, DecodeSType},
+{"FMADD_S", 0x67F, 0x43, DecodeR4Type},
+{"FMSUB_S", 0x67F, 0x47, DecodeR4Type},
+{"FNMSUB_S", 0x67F, 0x4B, DecodeR4Type},
+{"FNMADD_S", 0x67F, 0x4F, DecodeR4Type},
+{"FADD_S", 0xFE7F, 0x53, DecodeRType},
+{"FSUB_S", 0xFE7F, 0x853, DecodeRType},
+{"FMUL_S", 0xFE7F, 0x1053, DecodeRType},
+{"FDIV_S", 0xFE7F, 0x1853, DecodeRType},
+{"FSQRT_S", 0xFFF0007F, 0x5853, DecodeRType},
+{"FSGNJ_S", 0xFE00707F, 0x2053, DecodeRType},
+

[Lldb-commits] [PATCH] D138259: Add the ability to see when a type in incomplete.

2022-11-23 Thread Pavel Labath via Phabricator via lldb-commits
labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

Okay, looks good to me.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138259/new/

https://reviews.llvm.org/D138259

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D135798: Add runToBinaryEntry option for lldb-vscode

2022-11-23 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Ah, now I see that patch didn't land yet.

In the future, I think you can land simple changes like that without waiting 
for a (pre-commit) review, but if you don't feel comfortable doing that, then 
please revert the original patch so as to not leave the build in a broken state 
for a long period of time.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135798/new/

https://reviews.llvm.org/D135798

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D135798: Add runToBinaryEntry option for lldb-vscode

2022-11-23 Thread Pavel Labath via Phabricator via lldb-commits
labath added a comment.

Unfortunately, it looks like that patch broke things too. I haven't looked at 
the cause too closely, as the error was the same on linux and macos, but if you 
have problems reproducing it, let me know.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135798/new/

https://reviews.llvm.org/D135798

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 14aace3 - Revert "Add runToBinaryEntry option for lldb-vscode"

2022-11-23 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2022-11-23T13:26:11+01:00
New Revision: 14aace34c35da1ae5ffc4abc599cbdb36bf33a01

URL: 
https://github.com/llvm/llvm-project/commit/14aace34c35da1ae5ffc4abc599cbdb36bf33a01
DIFF: 
https://github.com/llvm/llvm-project/commit/14aace34c35da1ae5ffc4abc599cbdb36bf33a01.diff

LOG: Revert "Add runToBinaryEntry option for lldb-vscode"

This reverts commit f0c16f89124f2dc0630162ff9ea23934f5b2b75b because it
breaks linux and mac bots.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
lldb/tools/lldb-vscode/VSCode.cpp
lldb/tools/lldb-vscode/VSCode.h
lldb/tools/lldb-vscode/lldb-vscode.cpp
lldb/tools/lldb-vscode/package.json

Removed: 




diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
index 99baad59dc12d..a91f3b2b8feff 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/lldbvscode_testcase.py
@@ -286,7 +286,7 @@ def launch(self, program=None, args=None, cwd=None, 
env=None,
stopCommands=None, exitCommands=None, terminateCommands=None,
sourcePath=None, debuggerRoot=None, sourceInitFile=False, 
launchCommands=None,
sourceMap=None, disconnectAutomatically=True, 
runInTerminal=False,
-   expectFailure=False, postRunCommands=None, 
runToBinaryEntry=False):
+   expectFailure=False, postRunCommands=None):
 '''Sending launch request to vscode
 '''
 
@@ -323,8 +323,7 @@ def cleanup():
 sourceMap=sourceMap,
 runInTerminal=runInTerminal,
 expectFailure=expectFailure,
-postRunCommands=postRunCommands,
-runToBinaryEntry=runToBinaryEntry)
+postRunCommands=postRunCommands)
 
 if expectFailure:
 return response
@@ -347,7 +346,7 @@ def build_and_launch(self, program, args=None, cwd=None, 
env=None,
  terminateCommands=None, sourcePath=None,
  debuggerRoot=None, sourceInitFile=False, 
runInTerminal=False,
  disconnectAutomatically=True, postRunCommands=None,
- lldbVSCodeEnv=None, runToBinaryEntry=False):
+ lldbVSCodeEnv=None):
 '''Build the default Makefile target, create the VSCode debug adaptor,
and launch the process.
 '''
@@ -360,5 +359,4 @@ def build_and_launch(self, program, args=None, cwd=None, 
env=None,
 terminateCommands, sourcePath, debuggerRoot, 
sourceInitFile,
 runInTerminal=runInTerminal,
 disconnectAutomatically=disconnectAutomatically,
-postRunCommands=postRunCommands,
-runToBinaryEntry=runToBinaryEntry)
+postRunCommands=postRunCommands)

diff  --git a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
index f5f9ae30bbd46..c2de4ad5c7d9a 100644
--- a/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
+++ b/lldb/packages/Python/lldbsuite/test/tools/lldb-vscode/vscode.py
@@ -650,7 +650,7 @@ def request_launch(self, program, args=None, cwd=None, 
env=None,
terminateCommands=None ,sourcePath=None,
debuggerRoot=None, launchCommands=None, sourceMap=None,
runInTerminal=False, expectFailure=False,
-   postRunCommands=None, runToBinaryEntry=False):
+   postRunCommands=None):
 args_dict = {
 'program': program
 }
@@ -662,8 +662,6 @@ def request_launch(self, program, args=None, cwd=None, 
env=None,
 args_dict['env'] = env
 if stopOnEntry:
 args_dict['stopOnEntry'] = stopOnEntry
-if runToBinaryEntry:
-args_dict['runToBinaryEntry'] = runToBinaryEntry
 if disableASLR:
 args_dict['disableASLR'] = disableASLR
 if disableSTDIO:

diff  --git a/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py 
b/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
index 8bb89085bb156..6e916d72dda7d 100644
--- a/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
+++ b/lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py
@@ -78,29 +78,6 @@ def test_stopOnEntry(self):
 reason, 'breakpoint',
 'verify stop isn\'t "main" breakpoint')
 
-@skipIfWindows
-@skipIfRemote
-def 

[Lldb-commits] [PATCH] D138407: [LLDB] Add LoongArch register definitions and operations

2022-11-23 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp:221
+
+  uint8_t *src = const_cast(data_sp->GetBytes());
+  if (src == nullptr) {

seehearfeel wrote:
> DavidSpickett wrote:
> > seehearfeel wrote:
> > > DavidSpickett wrote:
> > > > Possibly not needed const cast.
> > > If no const cast, build failed:
> > > 
> > > ```
> > > /home/loongson/llvm.git/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp:221:12:
> > >  error: cannot initialize a variable of type 'uint8_t *' (aka 'unsigned 
> > > char *') with an rvalue of type 'const uint8_t *' (aka 'const unsigned 
> > > char *')
> > >   uint8_t *src = data_sp->GetBytes();
> > >^ ~~~
> > > 1 error generated.
> > > ```
> > Yes, for the way you've written it that makes sense. But I realise I was 
> > looking at the wrong thing here. It's fine that the GetBytes() is const 
> > because this is a WriteRegister call, that's expected.
> > 
> > You should be fine using `const uint8_t*` here, because you can still 
> > increment that pointer and memcpy from it. Since the pointer itself can 
> > change but the data it points to is const.
> > 
> > https://godbolt.org/z/9M9oqr575 might explain it better.
> The correct  code are:
> 
> In ReadAllRegisterValues()
> 
> ```
> uint8_t *dst = data_sp->GetBytes();
> ```
> 
> In WriteAllRegisterValues()
> 
> ```
> const uint8_t *src = data_sp->GetBytes();
> ```
> 
> Thank you.
Yes, exactly!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138407/new/

https://reviews.llvm.org/D138407

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D138407: [LLDB] Add LoongArch register definitions and operations

2022-11-23 Thread Tiezhu Yang via Phabricator via lldb-commits
seehearfeel added inline comments.



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp:221
+
+  uint8_t *src = const_cast(data_sp->GetBytes());
+  if (src == nullptr) {

DavidSpickett wrote:
> seehearfeel wrote:
> > DavidSpickett wrote:
> > > Possibly not needed const cast.
> > If no const cast, build failed:
> > 
> > ```
> > /home/loongson/llvm.git/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp:221:12:
> >  error: cannot initialize a variable of type 'uint8_t *' (aka 'unsigned 
> > char *') with an rvalue of type 'const uint8_t *' (aka 'const unsigned char 
> > *')
> >   uint8_t *src = data_sp->GetBytes();
> >^ ~~~
> > 1 error generated.
> > ```
> Yes, for the way you've written it that makes sense. But I realise I was 
> looking at the wrong thing here. It's fine that the GetBytes() is const 
> because this is a WriteRegister call, that's expected.
> 
> You should be fine using `const uint8_t*` here, because you can still 
> increment that pointer and memcpy from it. Since the pointer itself can 
> change but the data it points to is const.
> 
> https://godbolt.org/z/9M9oqr575 might explain it better.
The correct  code are:

In ReadAllRegisterValues()

```
uint8_t *dst = data_sp->GetBytes();
```

In WriteAllRegisterValues()

```
const uint8_t *src = data_sp->GetBytes();
```

Thank you.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138407/new/

https://reviews.llvm.org/D138407

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D138558: [lldb][DataFormatter] Add std::ranges::ref_view formatter

2022-11-23 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 477440.
Michael137 added a comment.

- Clean up test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138558/new/

https://reviews.llvm.org/D138558

Files:
  lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
  lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/main.cpp
@@ -0,0 +1,27 @@
+#include 
+#include 
+#include 
+#include 
+
+using string_vec = std::vector;
+
+string_vec svec{"First", "Second", "Third", "Fourth"};
+
+struct Foo {
+  string_vec vec = svec;
+};
+
+int main() {
+  {
+auto single = std::ranges::ref_view(svec[0]);
+auto all = std::views::all(svec);
+auto subset = all | std::views::take(2);
+std::puts("Break here");
+  }
+
+  {
+Foo f[2];
+auto view = std::ranges::ref_view(f);
+std::puts("Break here");
+  }
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py
@@ -0,0 +1,65 @@
+"""
+Test LLDB's std::ranges::ref_view formatter
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class LibcxxRangesRefViewDataFormatterTestCase(TestBase):
+
+def check_string_vec_children(self):
+return [ValueCheck(name='[0]', summary='"First"'),
+ValueCheck(name='[1]', summary='"Second"'),
+ValueCheck(name='[2]', summary='"Third"'),
+ValueCheck(name='[3]', summary='"Fourth"')]
+
+def check_string_vec_ref_view(self):
+return ValueCheck(
+name='*__range_',
+summary='size=4',
+children=self.check_string_vec_children())
+
+def check_foo(self):
+return ValueCheck(
+name='vec',
+children=self.check_string_vec_children())
+
+@add_test_categories(["libc++"])
+def test_with_run_command(self):
+"""Test that std::ranges::ref_view is formatted correctly when printed.
+"""
+self.build()
+(self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+self, 'Break here', lldb.SBFileSpec('main.cpp', False))
+
+# Check ref_view over a std::string
+self.expect_var_path('single',
+ children=[ValueCheck(
+   name='*__range_',
+   summary='"First"')])
+
+# Check all_view, which is a ref_view in this case
+self.expect_var_path('all',
+ children=[self.check_string_vec_ref_view()])
+
+# Check take_view format. Embeds a ref_view
+self.expect_var_path('subset',
+ children=[
+ ValueCheck(children=[self.check_string_vec_ref_view()]),
+ ValueCheck(name='__count_', value='2')
+ ])
+
+lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+# Check ref_view over custom type 'struct Foo'
+self.expect_var_path('view',
+ children=[ValueCheck(
+name='*__range_',
+children=[
+ValueCheck(name='[0]', type='Foo', children=[self.check_foo()]),
+ValueCheck(name='[1]', type='Foo', children=[self.check_foo()])
+])
+   ])
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/Makefile
@@ -0,0 +1,6 @@
+USE_LIBCPP := 1
+
+CXX_SOURCES := main.cpp
+CXXFLAGS_EXTRAS := -std=c++20
+
+include Makefile.rules
Index: 

[Lldb-commits] [PATCH] D138558: [lldb][DataFormatter] Add std::ranges::ref_view formatter

2022-11-23 Thread Michael Buch via Phabricator via lldb-commits
Michael137 updated this revision to Diff 477439.
Michael137 added a comment.

- Use typedef in test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138558/new/

https://reviews.llvm.org/D138558

Files:
  lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
  lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/main.cpp
@@ -0,0 +1,27 @@
+#include 
+#include 
+#include 
+#include 
+
+using string_vec = std::vector;
+
+string_vec svec{"First", "Second", "Third", "Fourth"};
+
+struct Foo {
+  string_vec vec = svec;
+};
+
+int main() {
+  {
+auto single = std::ranges::ref_view(svec[0]);
+auto all = std::views::all(svec);
+auto subset = all | std::views::take(2);
+std::puts("Break here");
+  }
+
+  {
+Foo f[2];
+auto view = std::ranges::ref_view(f);
+std::puts("Break here");
+  }
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py
@@ -0,0 +1,65 @@
+"""
+Test LLDB's std::ranges::ref_view formatter
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class LibcxxRangesRefViewDataFormatterTestCase(TestBase):
+
+def check_string_vec_children(self):
+return [ValueCheck(name='[0]', summary='"First"'),
+ValueCheck(name='[1]', summary='"Second"'),
+ValueCheck(name='[2]', summary='"Third"'),
+ValueCheck(name='[3]', summary='"Fourth"')]
+
+def check_string_vec_ref_view(self):
+return ValueCheck(
+name='*__range_',
+summary='size=4',
+children=self.check_string_vec_children())
+
+def check_foo(self):
+return ValueCheck(
+name="vec",
+children=self.check_string_vec_children())
+
+@add_test_categories(["libc++"])
+def test_with_run_command(self):
+"""Test that std::ranges::ref_view is formatted correctly when printed.
+"""
+self.build()
+(self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+self, 'Break here', lldb.SBFileSpec('main.cpp', False))
+
+# Check ref_view over a std::string
+self.expect_var_path('single',
+ children=[ValueCheck(
+   name='*__range_',
+   summary='"First"')])
+
+# Check all_view, which is a ref_view in this case
+self.expect_var_path('all',
+ children=[self.check_string_vec_ref_view()])
+
+# Check take_view format. Embeds a ref_view
+self.expect_var_path('subset',
+ children=[
+ ValueCheck(children=[self.check_string_vec_ref_view()]),
+ ValueCheck(name='__count_', value='2')
+ ])
+
+lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+# Check ref_view over custom type 'struct Foo'
+self.expect_var_path('view',
+ children=[ValueCheck(
+name='*__range_',
+children=[
+ValueCheck(name='[0]', type="Foo", children=[self.check_foo()]),
+ValueCheck(name='[1]', type="Foo", children=[self.check_foo()])
+])
+   ])
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/Makefile
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/Makefile
@@ -0,0 +1,6 @@
+USE_LIBCPP := 1
+
+CXX_SOURCES := main.cpp
+CXXFLAGS_EXTRAS := -std=c++20
+
+include Makefile.rules

[Lldb-commits] [PATCH] D138558: [lldb][DataFormatter] Add std::ranges::ref_view formatter

2022-11-23 Thread Michael Buch via Phabricator via lldb-commits
Michael137 created this revision.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

This patch adds a formatter for `std::ranges::ref_view`.
It simply holds a `T*`, so all this formatter does is dereference
this pointer and format it as `T` would be.

**Testing**

- Added API tests


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D138558

Files:
  lldb/source/Plugins/Language/CPlusPlus/CMakeLists.txt
  lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
  lldb/source/Plugins/Language/CPlusPlus/LibCxxRangesRefView.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/Makefile
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/main.cpp
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/main.cpp
@@ -0,0 +1,27 @@
+#include 
+#include 
+#include 
+#include 
+
+using string_vec = std::vector;
+
+string_vec svec{"First", "Second", "Third", "Fourth"};
+
+struct Foo {
+  std::vector vec = svec;
+};
+
+int main() {
+  {
+auto single = std::ranges::ref_view(svec[0]);
+auto all = std::views::all(svec);
+auto subset = all | std::views::take(2);
+std::puts("Break here");
+  }
+
+  {
+Foo f[2];
+auto view = std::ranges::ref_view(f);
+std::puts("Break here");
+  }
+}
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py
===
--- /dev/null
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/TestDataFormatterLibcxxRangesRefView.py
@@ -0,0 +1,65 @@
+"""
+Test LLDB's std::ranges::ref_view formatter
+"""
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class LibcxxRangesRefViewDataFormatterTestCase(TestBase):
+
+def check_string_vec_children(self):
+return [ValueCheck(name='[0]', summary='"First"'),
+ValueCheck(name='[1]', summary='"Second"'),
+ValueCheck(name='[2]', summary='"Third"'),
+ValueCheck(name='[3]', summary='"Fourth"')]
+
+def check_string_vec_ref_view(self):
+return ValueCheck(
+name='*__range_',
+summary='size=4',
+children=self.check_string_vec_children())
+
+def check_foo(self):
+return ValueCheck(
+name="vec",
+children=self.check_string_vec_children())
+
+@add_test_categories(["libc++"])
+def test_with_run_command(self):
+"""Test that std::ranges::ref_view is formatted correctly when printed.
+"""
+self.build()
+(self.target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(
+self, 'Break here', lldb.SBFileSpec('main.cpp', False))
+
+# Check ref_view over a std::string
+self.expect_var_path('single',
+ children=[ValueCheck(
+   name='*__range_',
+   summary='"First"')])
+
+# Check all_view, which is a ref_view in this case
+self.expect_var_path('all',
+ children=[self.check_string_vec_ref_view()])
+
+# Check take_view format. Embeds a ref_view
+self.expect_var_path('subset',
+ children=[
+ ValueCheck(children=[self.check_string_vec_ref_view()]),
+ ValueCheck(name='__count_', value='2')
+ ])
+
+lldbutil.continue_to_breakpoint(self.process(), bkpt)
+
+# Check ref_view over custom type 'struct Foo'
+self.expect_var_path('view',
+ children=[ValueCheck(
+name='*__range_',
+children=[
+ValueCheck(name='[0]', type="Foo", children=[self.check_foo()]),
+ValueCheck(name='[1]', type="Foo", children=[self.check_foo()])
+])
+   ])
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/ranges/ref_view/Makefile
===
--- /dev/null
+++ 

[Lldb-commits] [PATCH] D138407: [LLDB] Add LoongArch register definitions and operations

2022-11-23 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added inline comments.



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp:221
+
+  uint8_t *src = const_cast(data_sp->GetBytes());
+  if (src == nullptr) {

seehearfeel wrote:
> DavidSpickett wrote:
> > Possibly not needed const cast.
> If no const cast, build failed:
> 
> ```
> /home/loongson/llvm.git/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp:221:12:
>  error: cannot initialize a variable of type 'uint8_t *' (aka 'unsigned char 
> *') with an rvalue of type 'const uint8_t *' (aka 'const unsigned char *')
>   uint8_t *src = data_sp->GetBytes();
>^ ~~~
> 1 error generated.
> ```
Yes, for the way you've written it that makes sense. But I realise I was 
looking at the wrong thing here. It's fine that the GetBytes() is const because 
this is a WriteRegister call, that's expected.

You should be fine using `const uint8_t*` here, because you can still increment 
that pointer and memcpy from it. Since the pointer itself can change but the 
data it points to is const.

https://godbolt.org/z/9M9oqr575 might explain it better.



Comment at: 
lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_loongarch64.h:60
+  virtual bool WriteGPR() = 0;
+  virtual bool WriteFPR() = 0;
+};

seehearfeel wrote:
> DavidSpickett wrote:
> > This doesn't look right, I'd expect `bool ... () override;` here.
> Maybe we should leave it as is, the other archs do the same thing, 
> they will be override in the following file which is not implemented now:
> lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_loongarch64.h/cpp,
> otherwise build failed:
> 
> ```
> In file included from 
> /home/loongson/llvm.git/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_loongarch64.cpp:19:
> /home/loongson/llvm.git/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_loongarch64.h:57:18:
>  error: only virtual member functions can be marked 'override'
>   bool ReadGPR() override;
>  ^~~~
> /home/loongson/llvm.git/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_loongarch64.h:58:18:
>  error: only virtual member functions can be marked 'override'
>   bool ReadFPR() override;
>  ^~~~
> /home/loongson/llvm.git/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_loongarch64.h:59:19:
>  error: only virtual member functions can be marked 'override'
>   bool WriteGPR() override;
>   ^~~~
> /home/loongson/llvm.git/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_loongarch64.h:60:19:
>  error: only virtual member functions can be marked 'override'
>   bool WriteFPR() override;
>   ^~~~
> 4 errors generated.
> ```
Yes I think I was looking at one of the core file versions and didn't realise.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138407/new/

https://reviews.llvm.org/D138407

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D138539: Use std::nullopt_t instead of NoneType (NFC)

2022-11-23 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a reviewer: DavidSpickett.
DavidSpickett added a comment.

lldb parts LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138539/new/

https://reviews.llvm.org/D138539

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D138407: [LLDB] Add LoongArch register definitions and operations

2022-11-23 Thread Tiezhu Yang via Phabricator via lldb-commits
seehearfeel added inline comments.



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp:27
+// NT_PRSTATUS and NT_FPREGSET definition
+#include 
+

SixWeining wrote:
> [[ https://llvm.org/docs/CodingStandards.html#include-style | Should be 
> sorted lexicographically by the full path ]]. So put it before `sys/uio.h`. 
OK, will modify it, thank you.



Comment at: 
lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp:221
+
+  uint8_t *src = const_cast(data_sp->GetBytes());
+  if (src == nullptr) {

DavidSpickett wrote:
> Possibly not needed const cast.
If no const cast, build failed:

```
/home/loongson/llvm.git/lldb/source/Plugins/Process/Linux/NativeRegisterContextLinux_loongarch64.cpp:221:12:
 error: cannot initialize a variable of type 'uint8_t *' (aka 'unsigned char 
*') with an rvalue of type 'const uint8_t *' (aka 'const unsigned char *')
  uint8_t *src = data_sp->GetBytes();
   ^ ~~~
1 error generated.
```



Comment at: 
lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_loongarch64.h:60
+  virtual bool WriteGPR() = 0;
+  virtual bool WriteFPR() = 0;
+};

DavidSpickett wrote:
> This doesn't look right, I'd expect `bool ... () override;` here.
Maybe we should leave it as is, the other archs do the same thing, 
they will be override in the following file which is not implemented now:
lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_loongarch64.h/cpp,
otherwise build failed:

```
In file included from 
/home/loongson/llvm.git/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_loongarch64.cpp:19:
/home/loongson/llvm.git/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_loongarch64.h:57:18:
 error: only virtual member functions can be marked 'override'
  bool ReadGPR() override;
 ^~~~
/home/loongson/llvm.git/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_loongarch64.h:58:18:
 error: only virtual member functions can be marked 'override'
  bool ReadFPR() override;
 ^~~~
/home/loongson/llvm.git/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_loongarch64.h:59:19:
 error: only virtual member functions can be marked 'override'
  bool WriteGPR() override;
  ^~~~
/home/loongson/llvm.git/lldb/source/Plugins/Process/Utility/RegisterContextPOSIX_loongarch64.h:60:19:
 error: only virtual member functions can be marked 'override'
  bool WriteFPR() override;
  ^~~~
4 errors generated.
```



Comment at: 
lldb/source/Plugins/Process/Utility/RegisterInfoPOSIX_loongarch64.cpp:138
+size_t RegisterInfoPOSIX_loongarch64::GetRegisterSetCount() const {
+  return k_num_register_sets - 1;
+}

DavidSpickett wrote:
> SixWeining wrote:
> > Why `-  1`?
> I had the same thought. From the few others I looked at, it seems that it's 
> count not the last index. So if you've got N sets it should return N.
You are right, will modify it, thank you.



Comment at: lldb/source/Plugins/Process/Utility/RegisterInfos_loongarch64.h:35
+  {
\
+loongarch_dwarf::dwarf_##reg, loongarch_dwarf::dwarf_##reg, generic_kind,  
\
+LLDB_INVALID_REGNUM, reg##_loongarch   
\

SixWeining wrote:
> unnecessary indent?
Yes, will modify it, thank you.



Comment at: lldb/source/Plugins/Process/Utility/RegisterInfos_loongarch64.h:56
+
+#define DEFINE_FPR64(reg, generic_kind)
\
+  {
\

SixWeining wrote:
> Not allow accessing FPR registers through ABI names?
Will modify it, thank you.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138407/new/

https://reviews.llvm.org/D138407

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits