Skip to content

Commit 431333f

Browse files
committed
[lldb][rpc] Add RPC client library tests
Adds shell tests for the LLDB RPC client library.
1 parent c93d166 commit 431333f

File tree

10 files changed

+129
-0
lines changed

10 files changed

+129
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef LLDB_API_SBRPC_CHECKARRAYPTR_H
2+
#define LLDB_API_SBRPC_CHECKARRAYPTR_H
3+
4+
namespace lldb {
5+
class SBRPC_CheckArrayPtr {
6+
public:
7+
// Pointers to arrays followed by length must use a
8+
// Bytes object constructed using that pointer and the sizeof()
9+
// the array object.
10+
int CheckArrayPtr(int *array, int array_len);
11+
12+
}; // class SBRPC_CheckArrayPtr
13+
} // namespace lldb
14+
15+
#endif // LLDB_API_SBRPC_CHECKARRAYPTR_H
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef LLDB_API_SBRPC_CHECKCONSTCHARPTRPTRWITHLEN_H
2+
#define LLDB_API_SBRPC_CHECKCONSTCHARPTRPTRWITHLEN_H
3+
4+
namespace lldb {
5+
class SBRPC_CheckConstCharPtrPtrWithLen {
6+
public:
7+
// const char ** followed by len must use a StringList
8+
// when being encoded.
9+
int CheckConstCharPtrPtrWithLen(const char **arg1, int len);
10+
11+
}; // class SBRPC_CheckConstCharPtrPtrWithLen
12+
} // namespace lldb
13+
14+
#endif // LLDB_API_SBRPC_CHECKCONSTCHARPTRPTRWITHLEN_H
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#ifndef LLDB_API_SBRPC_CHECKNONCONSTSBREF_H
2+
#define LLDB_API_SBRPC_CHECKNONCONSTSBREF_H
3+
4+
#include "lldb/API/SBDefines.h"
5+
6+
namespace lldb {
7+
class LLDB_API SBRPC_CheckNonConstSBRef {
8+
public:
9+
// Non-const references to SB classes will have an assert
10+
// added that trips if it has an invalid ObjectRef.
11+
int CheckNonConstSBRef(SBDebugger &debugger_ref);
12+
13+
}; // class SBRPC_CheckNonConstSBRef
14+
} // namespace lldb
15+
16+
#endif // LLDB_API_SBRPC_CHECKNONCONSTSBREF_H
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifndef LLDB_API_SBRPC_CHECKSBPTR_H
2+
#define LLDB_API_SBRPC_CHECKSBPTR_H
3+
4+
#include "lldb/API/SBDefines.h"
5+
6+
namespace lldb {
7+
class LLDB_API SBRPC_CheckSBPtr {
8+
public:
9+
// Pointers to SB objects must be checked to
10+
// see if they're null. If so, then a new object of the given
11+
// class must be created and encoded. Otherwise, the original
12+
// parameter will be encoded.
13+
int CheckSBPtr(SBDebugger *debugger_ptr);
14+
15+
}; // class SBRPC_CheckSBPtr
16+
} // namespace lldb
17+
18+
#endif // LLDB_API_SBRPC_CHECKSBPTR_H
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef LLDB_API_SBRPC_CHECKVOIDPTR_H
2+
#define LLDB_API_SBRPC_CHECKVOIDPTR_H
3+
4+
namespace lldb {
5+
class SBRPC_CheckVoidPtr {
6+
public:
7+
// void * followed by length must use a Bytes object
8+
// when being encoded.
9+
int CheckVoidPtr(void *buf, int len);
10+
11+
}; // class SBRPC_CheckVoidPtr
12+
} // namespace lldb
13+
14+
#endif // LLDB_API_SBRPC_CHECKVOIDPTR_H
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
RUN: mkdir -p %t/server
2+
RUN: mkdir -p %t/lib
3+
RUN: %lldb-rpc-gen --output-dir=%t %S/../../Inputs/Client/CheckArrayPointer.h
4+
5+
RUN: cat %t/lib/CheckArrayPointer.cpp | FileCheck %s
6+
7+
# Pointers to arrays followed by length must use a
8+
# Bytes object constructed using that pointer and the sizeof()
9+
# the array object.
10+
CHECK: Bytes array_buffer(array, sizeof(int) * array_len);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
RUN: mkdir -p %t/server
2+
RUN: mkdir -p %t/lib
3+
RUN: %lldb-rpc-gen --output-dir=%t %S/../../Inputs/Client/CheckConstCharPtrPtrWithLen.h
4+
5+
RUN: cat %t/lib/CheckConstCharPtrPtrWithLen.cpp | FileCheck %s
6+
7+
# const char ** followed by len must use a StringList
8+
# when being encoded.
9+
CHECK: StringList arg1_list
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
RUN: mkdir -p %t/server
2+
RUN: mkdir -p %t/lib
3+
RUN: %lldb-rpc-gen --output-dir=%t %S/../../Inputs/Client/CheckNonConstSBRef.h
4+
5+
RUN: cat %t/lib/CheckNonConstSBRef.cpp | FileCheck %s
6+
7+
# Non-const references to SB classes will have an assert
8+
# added that trips if it has an invalid ObjectRef.
9+
CHECK: assert(debugger_ref.ObjectRefIsValid() && "SB object refs must be valid before encoding");
10+
CHECK-NEXT: RPCValueEncoder(send, rpc_common::RPCPacket::ValueType::Argument, debugger_ref);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
RUN: mkdir -p %t/server
2+
RUN: mkdir -p %t/lib
3+
RUN: %lldb-rpc-gen --output-dir=%t %S/../../Inputs/Client/CheckSBPointer.h
4+
5+
RUN: cat %t/lib/CheckSBPointer.cpp | FileCheck %s
6+
7+
# Pointers to SB objects must be checked to
8+
# see if they're null. If so, then a new object of the given
9+
# class must be created and encoded. Otherwise, the original
10+
# parameter will be encoded.
11+
CHECK: if (debugger_ptr)
12+
CHECK-NEXT: RPCValueEncoder(send, rpc_common::RPCPacket::ValueType::Argument, *debugger_ptr);
13+
CHECK-NEXT: else
14+
CHECK-NEXT: RPCValueEncoder(send, rpc_common::RPCPacket::ValueType::Argument, rpc::ObjectRef(ObjectRefGetConnectionID(), eClass_lldb_SBDebugger, LLDB_RPC_INVALID_OBJECT_ID));
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
RUN: mkdir -p %t/server
2+
RUN: mkdir -p %t/lib
3+
RUN: %lldb-rpc-gen --output-dir=%t %S/../../Inputs/Client/CheckVoidPtr.h
4+
5+
RUN: cat %t/lib/CheckVoidPtr.cpp | FileCheck %s
6+
7+
# void * followed by length must use a Bytes object
8+
# when being encoded.
9+
CHECK: Bytes buf_buffer(buf, len);

0 commit comments

Comments
 (0)