Skip to content

Commit 9dab558

Browse files
author
walter erquinigo
committed
[lldb-dap] Add an option to show function args in stack frames
When this option is enabled, display names of stack frames are generated using the `${function.name-with-args}` formatter instead of simply calling `SBFrame::GetDisplayFunctionName`. This makes lldb-dap show an output similar to the one in the CLI. This option is disabled by default because of its performance cost. It's a good option for non-gigantic programs.
1 parent 7360d5d commit 9dab558

File tree

24 files changed

+511
-235
lines changed

24 files changed

+511
-235
lines changed

lldb/bindings/headers.swig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "lldb/API/SBFile.h"
3131
#include "lldb/API/SBFileSpec.h"
3232
#include "lldb/API/SBFileSpecList.h"
33+
#include "lldb/API/SBFormat.h"
3334
#include "lldb/API/SBFrame.h"
3435
#include "lldb/API/SBFunction.h"
3536
#include "lldb/API/SBHostOS.h"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
%feature("docstring",
2+
"Class that represents a format string that can be used to generate "
3+
"descriptions of objects like frames and threads. See "
4+
"https://lldb.llvm.org/use/formatting.html for more information."
5+
) lldb::SBFormat;

lldb/bindings/interfaces.swig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
%include "./interface/SBFileDocstrings.i"
3535
%include "./interface/SBFileSpecDocstrings.i"
3636
%include "./interface/SBFileSpecListDocstrings.i"
37+
%include "./interface/SBFormatDocstrings.i"
3738
%include "./interface/SBFrameDocstrings.i"
3839
%include "./interface/SBFunctionDocstrings.i"
3940
%include "./interface/SBHostOSDocstrings.i"
@@ -106,6 +107,7 @@
106107
%include "lldb/API/SBFile.h"
107108
%include "lldb/API/SBFileSpec.h"
108109
%include "lldb/API/SBFileSpecList.h"
110+
%include "lldb/API/SBFormat.h"
109111
%include "lldb/API/SBFrame.h"
110112
%include "lldb/API/SBFunction.h"
111113
%include "lldb/API/SBHostOS.h"

lldb/include/lldb/API/SBDefines.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class LLDB_API SBExpressionOptions;
7171
class LLDB_API SBFile;
7272
class LLDB_API SBFileSpec;
7373
class LLDB_API SBFileSpecList;
74+
class LLDB_API SBFormat;
7475
class LLDB_API SBFrame;
7576
class LLDB_API SBFunction;
7677
class LLDB_API SBHostOS;

lldb/include/lldb/API/SBError.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class LLDB_API SBError {
8080
friend class SBData;
8181
friend class SBDebugger;
8282
friend class SBFile;
83+
friend class SBFormat;
8384
friend class SBHostOS;
8485
friend class SBPlatform;
8586
friend class SBProcess;

lldb/include/lldb/API/SBFormat.h

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
//===-- SBFormat.h ----------------------------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLDB_API_SBFORMAT_H
10+
#define LLDB_API_SBFORMAT_H
11+
12+
#include "lldb/API/SBDefines.h"
13+
14+
namespace lldb_private {
15+
namespace python {
16+
class SWIGBridge;
17+
} // namespace python
18+
namespace lua {
19+
class SWIGBridge;
20+
} // namespace lua
21+
} // namespace lldb_private
22+
23+
namespace lldb {
24+
25+
/// Class that represents a format string that can be used to generate
26+
/// descriptions of objects like frames and threads. See
27+
/// https://lldb.llvm.org/use/formatting.html for more information.
28+
class LLDB_API SBFormat {
29+
public:
30+
SBFormat();
31+
32+
/// Create an \a SBFormat by parsing the given format string. If parsing
33+
/// fails, this object is initialized as invalid.
34+
///
35+
/// \param[in] format
36+
/// The format string to parse.
37+
///
38+
/// \param[out] error
39+
/// An object where error messages will be written to if parsing fails.
40+
SBFormat(const char *format, lldb::SBError &error);
41+
42+
SBFormat(const lldb::SBFormat &rhs);
43+
44+
lldb::SBFormat &operator=(const lldb::SBFormat &rhs);
45+
46+
~SBFormat();
47+
48+
/// \return
49+
/// \b true if and only if this object is valid and can be used for
50+
/// formatting.
51+
explicit operator bool() const;
52+
53+
protected:
54+
friend class SBFrame;
55+
56+
/// \return
57+
/// The underlying shared pointer storage for this object.
58+
lldb::FormatEntrySP GetFormatEntrySP() const;
59+
60+
/// The storage for this object.
61+
lldb::FormatEntrySP m_opaque_sp;
62+
};
63+
64+
} // namespace lldb
65+
#endif // LLDB_API_SBFORMAT_H

lldb/include/lldb/API/SBFrame.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class LLDB_API SBFrame {
8888
const char *GetDisplayFunctionName();
8989

9090
const char *GetFunctionName() const;
91-
91+
9292
// Return the frame function's language. If there isn't a function, then
9393
// guess the language type from the mangled name.
9494
lldb::LanguageType GuessLanguage() const;
@@ -193,6 +193,21 @@ class LLDB_API SBFrame {
193193

194194
bool GetDescription(lldb::SBStream &description);
195195

196+
/// Similar to \a GetDescription() but the format of the description can be
197+
/// configured via the \p format parameter. See
198+
/// https://lldb.llvm.org/use/formatting.html for more information on format
199+
/// strings.
200+
///
201+
/// \param[in] format
202+
/// The format to use for generating the description.
203+
///
204+
/// \param[out] output
205+
/// The stream where the description will be written to.
206+
///
207+
/// \return
208+
/// An error object with an error message in case of failures.
209+
SBError GetDescriptionWithFormat(const SBFormat &format, SBStream &output);
210+
196211
protected:
197212
friend class SBBlock;
198213
friend class SBExecutionContext;

0 commit comments

Comments
 (0)