From e69b7441ad09a359eddb5c5c4f967ed925f26e52 Mon Sep 17 00:00:00 2001 From: ganchuantao Date: Fri, 16 May 2025 02:20:04 +0000 Subject: [PATCH 1/5] =?UTF-8?q?=E9=80=82=E9=85=8D=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89dispatch=20table,=E5=A2=9E=E5=8A=A0ndk=20=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ganchuantao --- hiviewdfx/hidebug/include/hidebug/hidebug.h | 27 +++++++++++++++++++ .../hidebug/include/hidebug/hidebug_type.h | 18 ++++++++++++- hiviewdfx/hidebug/libhidebug.ndk.json | 13 +++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/hiviewdfx/hidebug/include/hidebug/hidebug.h b/hiviewdfx/hidebug/include/hidebug/hidebug.h index d7cc123d1..94698ea02 100644 --- a/hiviewdfx/hidebug/include/hidebug/hidebug.h +++ b/hiviewdfx/hidebug/include/hidebug/hidebug.h @@ -151,6 +151,33 @@ HiDebug_ErrorCode OH_HiDebug_StopAppTraceCapture(); */ HiDebug_ErrorCode OH_HiDebug_GetGraphicsMemory(uint32_t *value); +/** + * @brief Set custom dispatch table of malloc function. + * + * @param dispatchTable Indicates pointer of custom dispatch table. + * @return Result code + * {@link HIDEBUG_SUCCESS} Get graphics memory success. + * {@link HIDEBUG_INVALID_ARGUMENT} Invalid argument,value is null. + * @since 14 + */ +HiDebug_ErrorCode OH_HiDebug_SetMallocDispatchTable(struct HiDebug_MallocDispatch *dispatchTable); + +/** + * @brief Get default dispatch table of malloc function. + * + * @return The default dispatch table of malloc function. + + * @since 14 + */ +HiDebug_MallocDispatch* OH_HiDebug_GetDefaultMallocDispatchTable(void); + +/** + * @brief Restore malloc dispatch table. + * + * @since 14 + */ +void OH_HiDebug_RestoreMallocDispatchTable(void); + #ifdef __cplusplus } #endif // __cplusplus diff --git a/hiviewdfx/hidebug/include/hidebug/hidebug_type.h b/hiviewdfx/hidebug/include/hidebug/hidebug_type.h index 5d853666e..5d8e056ff 100644 --- a/hiviewdfx/hidebug/include/hidebug/hidebug_type.h +++ b/hiviewdfx/hidebug/include/hidebug/hidebug_type.h @@ -39,7 +39,8 @@ #define HIVIEWDFX_HIDEBUG_TYPE_H #include - +#include +#include #ifdef __cplusplus extern "C" { #endif // __cplusplus @@ -174,6 +175,21 @@ typedef enum HiDebug_TraceFlag { /** Capture all thread trace */ HIDEBUG_TRACE_FLAG_ALL_THREADS = 2 } HiDebug_TraceFlag; + +/** + * @brief Defines structure type of malloc dispatch table. + * + * @since 20 +*/ +typedef struct HiDebug_MallocDispatch { + void* (*malloc)(size_t); + void* (*calloc)(size_t, size_t); + void* (*realloc)(void*, size_t); + void (*free)(void*); + void* (*mmap) (void*, size_t, int, int, int, off_t); + int (*munmap) (void*, size_t); + void* (*aligned_alloc)(size_t, size_t); +} HiDebug_MallocDispatch; #ifdef __cplusplus } #endif // __cplusplus diff --git a/hiviewdfx/hidebug/libhidebug.ndk.json b/hiviewdfx/hidebug/libhidebug.ndk.json index 02d50bda9..1739f5d80 100644 --- a/hiviewdfx/hidebug/libhidebug.ndk.json +++ b/hiviewdfx/hidebug/libhidebug.ndk.json @@ -38,5 +38,18 @@ { "first_introduced": "14", "name": "OH_HiDebug_GetGraphicsMemory" + }, + { + "first_introduced": "14", + "name": "OH_HiDebug_SetMallocDispatchTable" + }, + { + "first_introduced": "14", + "name": "OH_HiDebug_GetDefaultMallocDispatchTable" + }, + { + "first_introduced": "14", + "name": "OH_HiDebug_RestoreMallocDispatchTable" } + ] \ No newline at end of file -- Gitee From da8b8f4e2aa0e3f756edaecc993bd47090e50a4a Mon Sep 17 00:00:00 2001 From: ganchuantao Date: Fri, 16 May 2025 07:20:20 +0000 Subject: [PATCH 2/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ganchuantao --- hiviewdfx/hidebug/include/hidebug/hidebug.h | 14 +++++++------- hiviewdfx/hidebug/libhidebug.ndk.json | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hiviewdfx/hidebug/include/hidebug/hidebug.h b/hiviewdfx/hidebug/include/hidebug/hidebug.h index 94698ea02..eb7847ab7 100644 --- a/hiviewdfx/hidebug/include/hidebug/hidebug.h +++ b/hiviewdfx/hidebug/include/hidebug/hidebug.h @@ -152,29 +152,29 @@ HiDebug_ErrorCode OH_HiDebug_StopAppTraceCapture(); HiDebug_ErrorCode OH_HiDebug_GetGraphicsMemory(uint32_t *value); /** - * @brief Set custom dispatch table of malloc function. + * @brief Replace MallocDispatch table with developer customized memory functions. * * @param dispatchTable Indicates pointer of custom dispatch table. * @return Result code - * {@link HIDEBUG_SUCCESS} Get graphics memory success. + * {@link HIDEBUG_SUCCESS} Set customized dispatch table success. * {@link HIDEBUG_INVALID_ARGUMENT} Invalid argument,value is null. - * @since 14 + * @since 20 */ HiDebug_ErrorCode OH_HiDebug_SetMallocDispatchTable(struct HiDebug_MallocDispatch *dispatchTable); /** - * @brief Get default dispatch table of malloc function. + * @brief Obtain current MallocDispatch table. * * @return The default dispatch table of malloc function. - * @since 14 + * @since 20 */ HiDebug_MallocDispatch* OH_HiDebug_GetDefaultMallocDispatchTable(void); /** - * @brief Restore malloc dispatch table. + * @brief Restore original MallocDispatch table. * - * @since 14 + * @since 20 */ void OH_HiDebug_RestoreMallocDispatchTable(void); diff --git a/hiviewdfx/hidebug/libhidebug.ndk.json b/hiviewdfx/hidebug/libhidebug.ndk.json index 1739f5d80..e69b20476 100644 --- a/hiviewdfx/hidebug/libhidebug.ndk.json +++ b/hiviewdfx/hidebug/libhidebug.ndk.json @@ -40,15 +40,15 @@ "name": "OH_HiDebug_GetGraphicsMemory" }, { - "first_introduced": "14", + "first_introduced": "20", "name": "OH_HiDebug_SetMallocDispatchTable" }, { - "first_introduced": "14", + "first_introduced": "20", "name": "OH_HiDebug_GetDefaultMallocDispatchTable" }, { - "first_introduced": "14", + "first_introduced": "20", "name": "OH_HiDebug_RestoreMallocDispatchTable" } -- Gitee From 8b743648286a20cf764c5c5eb761ea622e744998 Mon Sep 17 00:00:00 2001 From: ganchuantao Date: Fri, 16 May 2025 08:42:03 +0000 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ganchuantao --- hiviewdfx/hidebug/include/hidebug/hidebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hiviewdfx/hidebug/include/hidebug/hidebug.h b/hiviewdfx/hidebug/include/hidebug/hidebug.h index eb7847ab7..55ee8017b 100644 --- a/hiviewdfx/hidebug/include/hidebug/hidebug.h +++ b/hiviewdfx/hidebug/include/hidebug/hidebug.h @@ -157,7 +157,7 @@ HiDebug_ErrorCode OH_HiDebug_GetGraphicsMemory(uint32_t *value); * @param dispatchTable Indicates pointer of custom dispatch table. * @return Result code * {@link HIDEBUG_SUCCESS} Set customized dispatch table success. - * {@link HIDEBUG_INVALID_ARGUMENT} Invalid argument,value is null. + * {@link HIDEBUG_INVALID_ARGUMENT} Invalid argument, dispatchTable is null. * @since 20 */ HiDebug_ErrorCode OH_HiDebug_SetMallocDispatchTable(struct HiDebug_MallocDispatch *dispatchTable); -- Gitee From 7f457e4708ed2da94a6c5b5af91b58d61f149dd9 Mon Sep 17 00:00:00 2001 From: ganchuantao Date: Mon, 19 May 2025 08:01:25 +0000 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ganchuantao --- hiviewdfx/hidebug/include/hidebug/hidebug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hiviewdfx/hidebug/include/hidebug/hidebug.h b/hiviewdfx/hidebug/include/hidebug/hidebug.h index 55ee8017b..670930024 100644 --- a/hiviewdfx/hidebug/include/hidebug/hidebug.h +++ b/hiviewdfx/hidebug/include/hidebug/hidebug.h @@ -157,7 +157,7 @@ HiDebug_ErrorCode OH_HiDebug_GetGraphicsMemory(uint32_t *value); * @param dispatchTable Indicates pointer of custom dispatch table. * @return Result code * {@link HIDEBUG_SUCCESS} Set customized dispatch table success. - * {@link HIDEBUG_INVALID_ARGUMENT} Invalid argument, dispatchTable is null. + * {@link HIDEBUG_INVALID_ARGUMENT} Invalid argument, dispatchTable is null pointer * @since 20 */ HiDebug_ErrorCode OH_HiDebug_SetMallocDispatchTable(struct HiDebug_MallocDispatch *dispatchTable); -- Gitee From 1a90a7c162f0ced58de3b25db5c7786bd7dc4d4a Mon Sep 17 00:00:00 2001 From: ganchuantao Date: Mon, 19 May 2025 10:39:50 +0000 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ganchuantao --- hiviewdfx/hidebug/include/hidebug/hidebug_type.h | 1 - 1 file changed, 1 deletion(-) diff --git a/hiviewdfx/hidebug/include/hidebug/hidebug_type.h b/hiviewdfx/hidebug/include/hidebug/hidebug_type.h index 5d8e056ff..7fb52c46e 100644 --- a/hiviewdfx/hidebug/include/hidebug/hidebug_type.h +++ b/hiviewdfx/hidebug/include/hidebug/hidebug_type.h @@ -188,7 +188,6 @@ typedef struct HiDebug_MallocDispatch { void (*free)(void*); void* (*mmap) (void*, size_t, int, int, int, off_t); int (*munmap) (void*, size_t); - void* (*aligned_alloc)(size_t, size_t); } HiDebug_MallocDispatch; #ifdef __cplusplus } -- Gitee