[Feature][task-view-306]merge P56U08(patch6) version
Only Configure: No
Affected branch: master
Affected module: unknow
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No
Change-Id: I8e809511ac30c97228dd110c304b4a08f4af36d7
diff --git a/ap/lib/libdebug_info/debug_info.c b/ap/lib/libdebug_info/debug_info.c
index fbecc71..03fe2b8 100755
--- a/ap/lib/libdebug_info/debug_info.c
+++ b/ap/lib/libdebug_info/debug_info.c
@@ -8,37 +8,45 @@
#include "pub_debug_info.h"
-
#define DEBUG_INFO_MAX_TOTAL_LEN (140)
-#define DEBUG_INFO_MAX_DATA_LEN (128)
-#define DEBUG_INFO_MEM_HEAD_LEN (8)
+//#define DEBUG_INFO_MAX_DATA_LEN (128)
+//#define DEBUG_INFO_MEM_HEAD_LEN (8)
-typedef unsigned int UINT32;
-typedef unsigned short UINT16;
-typedef unsigned char UINT8;
-
-typedef struct
+ssize_t safe_write(int fd, const void *buf, size_t count)
{
- UINT16 module_id; // 模块id
- UINT16 sub_len; // 用户数据长度
- UINT32 time;
- char sub_data[]; // 用户数据
-} T_SHARED_MEM_DATA;
+ ssize_t n;
-int sc_debug_info_record(unsigned int id, const char *format, ...)
+ for (;;) {
+ n = write(fd, buf, count);
+ if (n >= 0 || errno != EINTR)
+ break;
+ /* Some callers set errno=0, are upset when they see EINTR.
+ * Returning EINTR is wrong since we retry write(),
+ * the "error" was transient.
+ */
+ errno = 0;
+ /* repeat the write() */
+ }
+
+ return n;
+}
+int sc_debug_info_record(char *id, const char *format, ...)
{
int fd = -1;
ssize_t writelen;
-
int len;
va_list args;
char str_buf[DEBUG_INFO_MAX_TOTAL_LEN] __attribute__((aligned(4)));
- T_SHARED_MEM_DATA *shareMemData;
- shareMemData = (T_SHARED_MEM_DATA *)str_buf;
+ char *ptmpstr = str_buf;
/* args是一个char*类型指针,指向format之后的第一个参数*/
+ if( id == NULL)
+ return -1;
+
+ len = snprintf((char *)ptmpstr, DEBUG_INFO_MAX_TOTAL_LEN, "[%s]",id);
+ ptmpstr += len;
va_start(args, format);
- len = vsnprintf(shareMemData->sub_data, DEBUG_INFO_MAX_DATA_LEN, format, args);
+ len += vsnprintf(ptmpstr, DEBUG_INFO_MAX_TOTAL_LEN - len, format, args);
va_end(args);
if (len < 0)
{
@@ -46,10 +54,6 @@
return -1;
}
- shareMemData->module_id = (UINT16)(id & 0xFFFF);
- shareMemData->sub_len = len;
- shareMemData->time = 0;
-
fd = open(DEBUG_INFO_DEV_PATH, O_WRONLY);
if (fd < 0)
{
@@ -57,7 +61,7 @@
return -1;
}
- writelen = write(fd, (char *)shareMemData, (len + DEBUG_INFO_MEM_HEAD_LEN));
+ writelen = safe_write(fd, (char *)str_buf, len);
if (writelen < 0)
{
printf("[libdebug_info]: sc_debug_info_record, write debug_info error, %s\n", strerror(errno));