Skip to content

[lldb][rpc] Use Clang attributes to keep track of pointer plus len #148981

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 32 additions & 24 deletions lldb/include/lldb/API/SBData.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class LLDB_API SBData {

const char *GetString(lldb::SBError &error, lldb::offset_t offset);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
size_t ReadRawData(lldb::SBError &error, lldb::offset_t offset, void *buf,
size_t size);

Expand All @@ -80,9 +81,11 @@ class LLDB_API SBData {
// DataExtractor, but having two SetData() signatures triggers a SWIG bug
// where the typemap isn't applied before resolving the overload, and thus
// the right function never gets called
[[clang::annotate("lldb-rpc-gen pointer plus len")]]
void SetData(lldb::SBError &error, const void *buf, size_t size,
lldb::ByteOrder endian, uint8_t addr_size);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
void SetDataWithOwnership(lldb::SBError &error, const void *buf, size_t size,
lldb::ByteOrder endian, uint8_t addr_size);

Expand All @@ -96,41 +99,46 @@ class LLDB_API SBData {
// in the following CreateData*() and SetData*() prototypes, the two
// parameters array and array_len should not be renamed or rearranged,
// because doing so will break the SWIG typemap
static lldb::SBData CreateDataFromUInt64Array(lldb::ByteOrder endian,
uint32_t addr_byte_size,
uint64_t *array,
size_t array_len);

static lldb::SBData CreateDataFromUInt32Array(lldb::ByteOrder endian,
uint32_t addr_byte_size,
uint32_t *array,
size_t array_len);

static lldb::SBData CreateDataFromSInt64Array(lldb::ByteOrder endian,
uint32_t addr_byte_size,
int64_t *array,
size_t array_len);

static lldb::SBData CreateDataFromSInt32Array(lldb::ByteOrder endian,
uint32_t addr_byte_size,
int32_t *array,
size_t array_len);

static lldb::SBData CreateDataFromDoubleArray(lldb::ByteOrder endian,
uint32_t addr_byte_size,
double *array,
size_t array_len);
[[clang::annotate("lldb-rpc-gen pointer plus len")]]
static lldb::SBData
CreateDataFromUInt64Array(lldb::ByteOrder endian, uint32_t addr_byte_size,
uint64_t *array, size_t array_len);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
static lldb::SBData
CreateDataFromUInt32Array(lldb::ByteOrder endian, uint32_t addr_byte_size,
uint32_t *array, size_t array_len);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
static lldb::SBData
CreateDataFromSInt64Array(lldb::ByteOrder endian, uint32_t addr_byte_size,
int64_t *array, size_t array_len);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
static lldb::SBData
CreateDataFromSInt32Array(lldb::ByteOrder endian, uint32_t addr_byte_size,
int32_t *array, size_t array_len);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
static lldb::SBData
CreateDataFromDoubleArray(lldb::ByteOrder endian, uint32_t addr_byte_size,
double *array, size_t array_len);

bool SetDataFromCString(const char *data);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
bool SetDataFromUInt64Array(uint64_t *array, size_t array_len);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
bool SetDataFromUInt32Array(uint32_t *array, size_t array_len);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
bool SetDataFromSInt64Array(int64_t *array, size_t array_len);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
bool SetDataFromSInt32Array(int32_t *array, size_t array_len);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
bool SetDataFromDoubleArray(double *array, size_t array_len);

protected:
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBDebugger.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ class LLDB_API SBDebugger {

bool GetUseSourceCache() const;

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
static bool GetDefaultArchitecture(char *arch_name, size_t arch_name_len);

static bool SetDefaultArchitecture(const char *arch_name);
Expand Down Expand Up @@ -367,6 +368,7 @@ class LLDB_API SBDebugger {
void DispatchInput(void *baton, const void *data, size_t data_len);
#endif

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
void DispatchInput(const void *data, size_t data_len);

void DispatchInputInterrupt();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class LLDB_API SBFile {

SBFile &operator=(const SBFile &rhs);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
SBError Read(uint8_t *buf, size_t num_bytes, size_t *OUTPUT);
[[clang::annotate("lldb-rpc-gen pointer plus len")]]
SBError Write(const uint8_t *buf, size_t num_bytes, size_t *OUTPUT);
SBError Flush();
bool IsValid() const;
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBFileSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@ class LLDB_API SBFileSpec {

void SetDirectory(const char *directory);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
uint32_t GetPath(char *dst_path, size_t dst_len) const;

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
static int ResolvePath(const char *src_path, char *dst_path, size_t dst_len);

bool GetDescription(lldb::SBStream &description) const;
Expand Down
1 change: 1 addition & 0 deletions lldb/include/lldb/API/SBModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ class LLDB_API SBModule {
/// This function always returns the number of version numbers
/// that this object file has regardless of the number of
/// version numbers that were copied into \a versions.
[[clang::annotate("lldb-rpc-gen pointer plus len")]]
uint32_t GetVersion(uint32_t *versions, uint32_t num_versions);

/// Get accessor for the symbol file specification.
Expand Down
1 change: 1 addition & 0 deletions lldb/include/lldb/API/SBModuleSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class LLDB_API SBModuleSpec {

void SetTriple(const char *triple);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
const uint8_t *GetUUIDBytes();

size_t GetUUIDLength();
Expand Down
6 changes: 6 additions & 0 deletions lldb/include/lldb/API/SBProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@ class LLDB_API SBProcess {

size_t PutSTDIN(const char *src, size_t src_len);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
size_t GetSTDOUT(char *dst, size_t dst_len) const;

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
size_t GetSTDERR(char *dst, size_t dst_len) const;

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
size_t GetAsyncProfileData(char *dst, size_t dst_len) const;

#ifndef SWIG
Expand Down Expand Up @@ -197,11 +200,14 @@ class LLDB_API SBProcess {
///
void ForceScriptedState(StateType new_state);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
size_t ReadMemory(addr_t addr, void *buf, size_t size, lldb::SBError &error);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
size_t WriteMemory(addr_t addr, const void *buf, size_t size,
lldb::SBError &error);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
size_t ReadCStringFromMemory(addr_t addr, void *char_buf, size_t size,
lldb::SBError &error);

Expand Down
1 change: 1 addition & 0 deletions lldb/include/lldb/API/SBStructuredData.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class SBStructuredData {
/// \return
/// Returns the byte size needed to completely write the string value at
/// \a dst in all cases.
[[clang::annotate("lldb-rpc-gen pointer plus len")]]
size_t GetStringValue(char *dst, size_t dst_len) const;

/// Return the generic pointer if this data structure is a generic type.
Expand Down
17 changes: 11 additions & 6 deletions lldb/include/lldb/API/SBTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ class LLDB_API SBTarget {
///
/// \return
/// The amount of data read in host bytes.
[[clang::annotate("lldb-rpc-gen pointer plus len")]]
size_t ReadMemory(const SBAddress addr, void *buf, size_t size,
lldb::SBError &error);

Expand Down Expand Up @@ -688,12 +689,13 @@ class LLDB_API SBTarget {
const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
lldb::SBBreakpoint BreakpointCreateByNames(
const char *symbol_name[], uint32_t num_names,
uint32_t
name_type_mask, // Logical OR one or more FunctionNameType enum bits
lldb::LanguageType symbol_language,
const SBFileSpecList &module_list, const SBFileSpecList &comp_unit_list);
lldb::LanguageType symbol_language, const SBFileSpecList &module_list,
const SBFileSpecList &comp_unit_list);

lldb::SBBreakpoint BreakpointCreateByNames(
const char *symbol_name[], uint32_t num_names,
Expand Down Expand Up @@ -900,24 +902,27 @@ class LLDB_API SBTarget {
lldb::SBAddress end_addr,
const char *flavor_string);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
lldb::SBInstructionList GetInstructions(lldb::SBAddress base_addr,
const void *buf, size_t size);

// The "WithFlavor" is necessary to keep SWIG from getting confused about
// overloaded arguments when using the buf + size -> Python Object magic.

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
lldb::SBInstructionList GetInstructionsWithFlavor(lldb::SBAddress base_addr,
const char *flavor_string,
const void *buf,
size_t size);

#ifndef SWIG
[[clang::annotate("lldb-rpc-gen pointer plus len")]]
lldb::SBInstructionList GetInstructions(lldb::addr_t base_addr,
const void *buf, size_t size);
lldb::SBInstructionList GetInstructionsWithFlavor(lldb::addr_t base_addr,
const char *flavor_string,
const void *buf,
size_t size);
[[clang::annotate("lldb-rpc-gen pointer plus len")]]
lldb::SBInstructionList
GetInstructionsWithFlavor(lldb::addr_t base_addr, const char *flavor_string,
const void *buf, size_t size);
#endif

lldb::SBSymbolContextList FindSymbols(const char *name,
Expand Down
1 change: 1 addition & 0 deletions lldb/include/lldb/API/SBThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class LLDB_API SBThread {
SBThreadCollection
GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type);

[[clang::annotate("lldb-rpc-gen pointer plus len")]]
size_t GetStopDescription(char *dst_or_null, size_t dst_len);

SBValue GetStopReturnValue();
Expand Down
Loading