summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorOskar.Guan <oskarguan@163.com>2019-05-28 15:49:05 (GMT)
committer Hanhui <sylixos@gmail.com>2019-04-18 15:51:39 (GMT)
commit000d1d34254f2c4020edebd1d0d15b35d5972cf6 (patch)
treee16ce88bacb1870670d8a8dba54c16e30abb9831
parentc31e4a1d92f9c05298abdd14b2dac1ee4b4e9c1d (diff)
downloadAIC-OS-000d1d34254f2c4020edebd1d0d15b35d5972cf6.zip
Update debugger application abort restore abort instruction.
-rw-r--r--SylixOS/arch/arm/arm_support.h1
-rw-r--r--SylixOS/arch/arm/dbg/armDbg.c18
-rw-r--r--SylixOS/arch/arm64/arm64_support.h1
-rw-r--r--SylixOS/arch/arm64/dbg/arm64Dbg.c18
-rw-r--r--SylixOS/arch/c6x/c6x_support.h1
-rw-r--r--SylixOS/arch/c6x/dbg/c6xDbg.c18
-rw-r--r--SylixOS/arch/csky/csky_support.h1
-rw-r--r--SylixOS/arch/csky/dbg/cskyDbg.c34
-rw-r--r--SylixOS/arch/mips/dbg/mipsDbg.c18
-rw-r--r--SylixOS/arch/mips/mips_support.h1
-rw-r--r--SylixOS/arch/mips/mm/mmu/mipsMmuCommon.c2
-rw-r--r--SylixOS/arch/ppc/dbg/ppcDbg.c22
-rw-r--r--SylixOS/arch/ppc/ppc_support.h1
-rw-r--r--SylixOS/arch/riscv/dbg/riscvDbg.c40
-rw-r--r--SylixOS/arch/riscv/riscv_support.h1
-rw-r--r--SylixOS/arch/sparc/dbg/sparcDbg.c18
-rw-r--r--SylixOS/arch/sparc/sparc_support.h1
-rw-r--r--SylixOS/arch/x86/dbg/x86Dbg.c34
-rw-r--r--SylixOS/arch/x86/x86_support.h1
-rw-r--r--SylixOS/debug/dtrace/dtrace.c13
-rw-r--r--SylixOS/include/sys/semfd.h4
-rw-r--r--SylixOS/kernel/include/k_class.h2
-rw-r--r--SylixOS/kernel/show/ThreadShow.c14
-rw-r--r--SylixOS/system/device/semfd/semfdDev.c10
24 files changed, 230 insertions, 44 deletions
diff --git a/SylixOS/arch/arm/arm_support.h b/SylixOS/arch/arm/arm_support.h
index 5d39594..5ef5a35 100644
--- a/SylixOS/arch/arm/arm_support.h
+++ b/SylixOS/arch/arm/arm_support.h
@@ -110,6 +110,7 @@ PLW_STACK archCtxStackEnd(const ARCH_REG_CTX *pregctx);
VOID archDbgBpInsert(addr_t ulAddr, size_t stSize, ULONG *pulIns, BOOL bLocal);
VOID archDbgAbInsert(addr_t ulAddr, ULONG *pulIns);
VOID archDbgBpRemove(addr_t ulAddr, size_t stSize, ULONG ulIns, BOOL bLocal);
+VOID archDbgApRemove(addr_t ulAddr, ULONG ulIns);
VOID archDbgBpPrefetch(addr_t ulAddr);
UINT archDbgTrapType(addr_t ulAddr, PVOID pvArch);
VOID archDbgBpAdjust(PVOID pvDtrace, PVOID pvtm);
diff --git a/SylixOS/arch/arm/dbg/armDbg.c b/SylixOS/arch/arm/dbg/armDbg.c
index 9bf20f9..28a94e8 100644
--- a/SylixOS/arch/arm/dbg/armDbg.c
+++ b/SylixOS/arch/arm/dbg/armDbg.c
@@ -115,6 +115,24 @@ VOID archDbgBpRemove (addr_t ulAddr, size_t stSize, ULONG ulIns, BOOL bLocal
#endif /* LW_CFG_CACHE_EN > 0 */
}
/*********************************************************************************************************
+** 函数名称: archDbgApRemove
+** 功能描述: 删除一个终止点.
+** 输 入 : ulAddr 终止点地址
+** pulIns 返回的之前的指令
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+VOID archDbgApRemove (addr_t ulAddr, ULONG ulIns)
+{
+ lib_memcpy((PCHAR)ulAddr, (PCHAR)&ulIns, sizeof(ULONG));
+ KN_SMP_MB();
+
+#if LW_CFG_CACHE_EN > 0
+ API_CacheTextUpdate((PVOID)ulAddr, sizeof(ULONG));
+#endif /* LW_CFG_CACHE_EN > 0 */
+}
+/*********************************************************************************************************
** 函数名称: archDbgBpPrefetch
** 功能描述: 预取一个指令.
当指令处于 MMU 共享物理段时, 指令空间为物理只读, 这里需要产生一次缺页中断, 克隆一个物理页面.
diff --git a/SylixOS/arch/arm64/arm64_support.h b/SylixOS/arch/arm64/arm64_support.h
index 518cc66..f6f8b91 100644
--- a/SylixOS/arch/arm64/arm64_support.h
+++ b/SylixOS/arch/arm64/arm64_support.h
@@ -100,6 +100,7 @@ PLW_STACK archCtxStackEnd(const ARCH_REG_CTX *pregctx);
VOID archDbgBpInsert(addr_t ulAddr, size_t stSize, ULONG *pulIns, BOOL bLocal);
VOID archDbgAbInsert(addr_t ulAddr, ULONG *pulIns);
VOID archDbgBpRemove(addr_t ulAddr, size_t stSize, ULONG ulIns, BOOL bLocal);
+VOID archDbgApRemove(addr_t ulAddr, ULONG ulIns);
VOID archDbgBpPrefetch(addr_t ulAddr);
UINT archDbgTrapType(addr_t ulAddr, PVOID pvArch);
VOID archDbgBpAdjust(PVOID pvDtrace, PVOID pvtm);
diff --git a/SylixOS/arch/arm64/dbg/arm64Dbg.c b/SylixOS/arch/arm64/dbg/arm64Dbg.c
index 7b7a6c6..19df355 100644
--- a/SylixOS/arch/arm64/dbg/arm64Dbg.c
+++ b/SylixOS/arch/arm64/dbg/arm64Dbg.c
@@ -107,6 +107,24 @@ VOID archDbgBpRemove (addr_t ulAddr, size_t stSize, ULONG ulIns, BOOL bLocal
#endif /* LW_CFG_CACHE_EN > 0 */
}
/*********************************************************************************************************
+** 函数名称: archDbgApRemove
+** 功能描述: 删除一个终止点.
+** 输 入 : ulAddr 终止点地址
+** pulIns 返回的之前的指令
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+VOID archDbgApRemove (addr_t ulAddr, ULONG ulIns)
+{
+ lib_memcpy((PCHAR)ulAddr, (PCHAR)&ulIns, sizeof(ARM64_INSTRUCTION));
+ KN_SMP_MB();
+
+#if LW_CFG_CACHE_EN > 0
+ API_CacheTextUpdate((PVOID)ulAddr, sizeof(ARM64_INSTRUCTION));
+#endif /* LW_CFG_CACHE_EN > 0 */
+}
+/*********************************************************************************************************
** 函数名称: archDbgBpPrefetch
** 功能描述: 预取一个指令.
当指令处于 MMU 共享物理段时, 指令空间为物理只读, 这里需要产生一次缺页中断, 克隆一个物理页面.
diff --git a/SylixOS/arch/c6x/c6x_support.h b/SylixOS/arch/c6x/c6x_support.h
index 935bca3..5e2ade3 100644
--- a/SylixOS/arch/c6x/c6x_support.h
+++ b/SylixOS/arch/c6x/c6x_support.h
@@ -98,6 +98,7 @@ PLW_STACK archCtxStackEnd(const ARCH_REG_CTX *pregctx);
VOID archDbgBpInsert(addr_t ulAddr, size_t stSize, ULONG *pulIns, BOOL bLocal);
VOID archDbgAbInsert(addr_t ulAddr, ULONG *pulIns);
VOID archDbgBpRemove(addr_t ulAddr, size_t stSize, ULONG ulIns, BOOL bLocal);
+VOID archDbgApRemove(addr_t ulAddr, ULONG ulIns);
VOID archDbgBpPrefetch(addr_t ulAddr);
UINT archDbgTrapType(addr_t ulAddr, PVOID pvArch);
VOID archDbgBpAdjust(PVOID pvDtrace, PVOID pvtm);
diff --git a/SylixOS/arch/c6x/dbg/c6xDbg.c b/SylixOS/arch/c6x/dbg/c6xDbg.c
index 3e02e3c..9481c91 100644
--- a/SylixOS/arch/c6x/dbg/c6xDbg.c
+++ b/SylixOS/arch/c6x/dbg/c6xDbg.c
@@ -111,6 +111,24 @@ VOID archDbgBpRemove (addr_t ulAddr, size_t stSize, ULONG ulIns, BOOL bLoca
#endif /* LW_CFG_CACHE_EN > 0 */
}
/*********************************************************************************************************
+** 函数名称: archDbgApRemove
+** 功能描述: 删除一个终止点.
+** 输 入 : ulAddr 终止点地址
+** pulIns 返回的之前的指令
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+VOID archDbgApRemove (addr_t ulAddr, ULONG ulIns)
+{
+ lib_memcpy((PCHAR)ulAddr, (PCHAR)&ulIns, sizeof(ULONG));
+ KN_SMP_MB();
+
+#if LW_CFG_CACHE_EN > 0
+ API_CacheTextUpdate((PVOID)ulAddr, sizeof(ULONG));
+#endif /* LW_CFG_CACHE_EN > 0 */
+}
+/*********************************************************************************************************
** 函数名称: archDbgBpPrefetch
** 功能描述: 预取一个指令.
当指令处于 MMU 共享物理段时, 指令空间为物理只读, 这里需要产生一次缺页中断, 克隆一个物理页面.
diff --git a/SylixOS/arch/csky/csky_support.h b/SylixOS/arch/csky/csky_support.h
index 9d45c33..233bcca 100644
--- a/SylixOS/arch/csky/csky_support.h
+++ b/SylixOS/arch/csky/csky_support.h
@@ -100,6 +100,7 @@ PLW_STACK archCtxStackEnd(const ARCH_REG_CTX *pregctx);
VOID archDbgBpInsert(addr_t ulAddr, size_t stSize, ULONG *pulIns, BOOL bLocal);
VOID archDbgAbInsert(addr_t ulAddr, ULONG *pulIns);
VOID archDbgBpRemove(addr_t ulAddr, size_t stSize, ULONG ulIns, BOOL bLocal);
+VOID archDbgApRemove(addr_t ulAddr, ULONG ulIns);
VOID archDbgBpPrefetch(addr_t ulAddr);
UINT archDbgTrapType(addr_t ulAddr, PVOID pvArch);
VOID archDbgBpAdjust(PVOID pvDtrace, PVOID pvtm);
diff --git a/SylixOS/arch/csky/dbg/cskyDbg.c b/SylixOS/arch/csky/dbg/cskyDbg.c
index b9de814..13e3adf 100644
--- a/SylixOS/arch/csky/dbg/cskyDbg.c
+++ b/SylixOS/arch/csky/dbg/cskyDbg.c
@@ -107,6 +107,24 @@ VOID archDbgBpRemove (addr_t ulAddr, size_t stSize, ULONG ulIns, BOOL bLocal
#endif /* LW_CFG_CACHE_EN > 0 */
}
/*********************************************************************************************************
+** 函数名称: archDbgApRemove
+** 功能描述: 删除一个终止点.
+** 输 入 : ulAddr 终止点地址
+** pulIns 返回的之前的指令
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+VOID archDbgApRemove (addr_t ulAddr, ULONG ulIns)
+{
+ lib_memcpy((PCHAR)ulAddr, (PCHAR)&ulIns, sizeof(CSKY_INSTRUCTION));
+ KN_SMP_MB();
+
+#if LW_CFG_CACHE_EN > 0
+ API_CacheTextUpdate((PVOID)ulAddr, sizeof(CSKY_INSTRUCTION));
+#endif /* LW_CFG_CACHE_EN > 0 */
+}
+/*********************************************************************************************************
** 函数名称: archDbgBpPrefetch
** 功能描述: 预取一个指令.
当指令处于 MMU 共享物理段时, 指令空间为物理只读, 这里需要产生一次缺页中断, 克隆一个物理页面.
@@ -132,21 +150,23 @@ VOID archDbgBpPrefetch (addr_t ulAddr)
*********************************************************************************************************/
UINT archDbgTrapType (addr_t ulAddr, PVOID pvArch)
{
+ PLW_CLASS_TCB ptcbCur;
#if (LW_CFG_SMP_EN > 0) && (LW_CFG_CACHE_EN > 0) && (LW_CFG_GDB_SMP_TU_LAZY > 0)
- ULONG ulCPUId;
+ ULONG ulCPUId;
#endif /* LW_CFG_SMP_EN > 0 */
if (API_DtraceIsValid() == LW_FALSE) { /* 不存在调试节点 */
return (LW_TRAP_INVAL);
}
- switch (*(CSKY_INSTRUCTION *)ulAddr) {
-
- case CSKY_BREAKPOINT_INS:
- return (LW_TRAP_BRKPT);
+ if (*(CSKY_INSTRUCTION *)ulAddr == CSKY_BREAKPOINT_INS) {
+ LW_TCB_GET_CUR_SAFE(ptcbCur);
- default:
- break;
+ if (ptcbCur->TCB_ulAbortPointAddr == ulAddr) {
+ return (LW_TRAP_ABORT);
+ } else {
+ return (LW_TRAP_BRKPT);
+ }
}
#if (LW_CFG_SMP_EN > 0) && (LW_CFG_CACHE_EN > 0) && (LW_CFG_GDB_SMP_TU_LAZY > 0)
diff --git a/SylixOS/arch/mips/dbg/mipsDbg.c b/SylixOS/arch/mips/dbg/mipsDbg.c
index 2223979..9a88f55 100644
--- a/SylixOS/arch/mips/dbg/mipsDbg.c
+++ b/SylixOS/arch/mips/dbg/mipsDbg.c
@@ -108,6 +108,24 @@ VOID archDbgBpRemove (addr_t ulAddr, size_t stSize, ULONG ulIns, BOOL bLocal
#endif /* LW_CFG_CACHE_EN > 0 */
}
/*********************************************************************************************************
+** 函数名称: archDbgApRemove
+** 功能描述: 删除一个终止点.
+** 输 入 : ulAddr 终止点地址
+** pulIns 返回的之前的指令
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+VOID archDbgApRemove (addr_t ulAddr, ULONG ulIns)
+{
+ lib_memcpy((PCHAR)ulAddr, (PCHAR)&ulIns, sizeof(MIPS_INSTRUCTION));
+ KN_SMP_MB();
+
+#if LW_CFG_CACHE_EN > 0
+ API_CacheTextUpdate((PVOID)ulAddr, sizeof(MIPS_INSTRUCTION));
+#endif /* LW_CFG_CACHE_EN > 0 */
+}
+/*********************************************************************************************************
** 函数名称: archDbgBpPrefetch
** 功能描述: 预取一个指令.
当指令处于 MMU 共享物理段时, 指令空间为物理只读, 这里需要产生一次缺页中断, 克隆一个物理页面.
diff --git a/SylixOS/arch/mips/mips_support.h b/SylixOS/arch/mips/mips_support.h
index b79dc5a..1dabfbf 100644
--- a/SylixOS/arch/mips/mips_support.h
+++ b/SylixOS/arch/mips/mips_support.h
@@ -110,6 +110,7 @@ VOIDFUNCPTR mipsIdleHookGet(CPCHAR pcMachineName);
VOID archDbgBpInsert(addr_t ulAddr, size_t stSize, ULONG *pulIns, BOOL bLocal);
VOID archDbgAbInsert(addr_t ulAddr, ULONG *pulIns);
VOID archDbgBpRemove(addr_t ulAddr, size_t stSize, ULONG ulIns, BOOL bLocal);
+VOID archDbgApRemove(addr_t ulAddr, ULONG ulIns);
VOID archDbgBpPrefetch(addr_t ulAddr);
UINT archDbgTrapType(addr_t ulAddr, PVOID pvArch);
VOID archDbgBpAdjust(PVOID pvDtrace, PVOID pvtm);
diff --git a/SylixOS/arch/mips/mm/mmu/mipsMmuCommon.c b/SylixOS/arch/mips/mm/mmu/mipsMmuCommon.c
index 49a0e79..c78fa5f 100644
--- a/SylixOS/arch/mips/mm/mmu/mipsMmuCommon.c
+++ b/SylixOS/arch/mips/mm/mmu/mipsMmuCommon.c
@@ -183,7 +183,7 @@ VOID mipsMmuDumpTLB (VOID)
ulEntryHi = mipsCp0EntryHiRead();
ulPageMask = mipsCp0PageMaskRead();
- _PrintFormat("TLB[%02d]: EntryLo0="LX_FMT", EntryLo1=0x%"LX_FMT", "
+ _PrintFormat("TLB[%02d]: EntryLo0="LX_FMT", EntryLo1="LX_FMT", "
"EntryHi="LX_FMT", PageMask="LX_FMT"\r\n",
i, ulEntryLo0, ulEntryLo1, ulEntryHi, ulPageMask);
}
diff --git a/SylixOS/arch/ppc/dbg/ppcDbg.c b/SylixOS/arch/ppc/dbg/ppcDbg.c
index 3f6ce3b..47df447 100644
--- a/SylixOS/arch/ppc/dbg/ppcDbg.c
+++ b/SylixOS/arch/ppc/dbg/ppcDbg.c
@@ -122,6 +122,28 @@ VOID archDbgBpRemove (addr_t ulAddr, size_t stSize, ULONG ulIns, BOOL bLoca
#endif /* LW_CFG_CACHE_EN > 0 */
}
/*********************************************************************************************************
+** 函数名称: archDbgApRemove
+** 功能描述: 删除一个终止点.
+** 输 入 : ulAddr 终止点地址
+** pulIns 返回的之前的指令
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+VOID archDbgApRemove (addr_t ulAddr, ULONG ulIns)
+{
+#if LW_CFG_VMM_EN > 0
+ archMmuDataTlbPreLoad(ulAddr);
+#endif
+
+ lib_memcpy((PCHAR)ulAddr, (PCHAR)&ulIns, sizeof(ULONG));
+ KN_SMP_MB();
+
+#if LW_CFG_CACHE_EN > 0
+ API_CacheTextUpdate((PVOID)ulAddr, sizeof(ULONG));
+#endif /* LW_CFG_CACHE_EN > 0 */
+}
+/*********************************************************************************************************
** 函数名称: archDbgBpPrefetch
** 功能描述: 预取一个指令.
当指令处于 MMU 共享物理段时, 指令空间为物理只读, 这里需要产生一次缺页中断, 克隆一个物理页面.
diff --git a/SylixOS/arch/ppc/ppc_support.h b/SylixOS/arch/ppc/ppc_support.h
index 0c24b4d..eb4e459 100644
--- a/SylixOS/arch/ppc/ppc_support.h
+++ b/SylixOS/arch/ppc/ppc_support.h
@@ -102,6 +102,7 @@ PLW_STACK archCtxStackEnd(const ARCH_REG_CTX *pregctx);
VOID archDbgBpInsert(addr_t ulAddr, size_t stSize, ULONG *pulIns, BOOL bLocal);
VOID archDbgAbInsert(addr_t ulAddr, ULONG *pulIns);
VOID archDbgBpRemove(addr_t ulAddr, size_t stSize, ULONG ulIns, BOOL bLocal);
+VOID archDbgApRemove(addr_t ulAddr, ULONG ulIns);
VOID archDbgBpPrefetch(addr_t ulAddr);
UINT archDbgTrapType(addr_t ulAddr, PVOID pvArch);
VOID archDbgBpAdjust(PVOID pvDtrace, PVOID pvtm);
diff --git a/SylixOS/arch/riscv/dbg/riscvDbg.c b/SylixOS/arch/riscv/dbg/riscvDbg.c
index 8e7b394..01ab183 100644
--- a/SylixOS/arch/riscv/dbg/riscvDbg.c
+++ b/SylixOS/arch/riscv/dbg/riscvDbg.c
@@ -29,7 +29,6 @@
RISC-V 断点指令 (必须支持压缩指令)
*********************************************************************************************************/
#define RISCV_BREAKPOINT_INS 0x9002
-#define RISCV_ABORTPOINT_INS 0x9003 /* TODO */
/*********************************************************************************************************
SMP
*********************************************************************************************************/
@@ -76,7 +75,7 @@ VOID archDbgBpInsert (addr_t ulAddr, size_t stSize, ULONG *pulIns, BOOL bLoc
VOID archDbgAbInsert (addr_t ulAddr, ULONG *pulIns)
{
*pulIns = *(ULONG *)ulAddr;
- *(UINT16 *)ulAddr = RISCV_ABORTPOINT_INS;
+ *(UINT16 *)ulAddr = RISCV_BREAKPOINT_INS;
KN_SMP_MB();
#if LW_CFG_CACHE_EN > 0
@@ -108,6 +107,24 @@ VOID archDbgBpRemove (addr_t ulAddr, size_t stSize, ULONG ulIns, BOOL bLocal
#endif /* LW_CFG_CACHE_EN > 0 */
}
/*********************************************************************************************************
+** 函数名称: archDbgApRemove
+** 功能描述: 删除一个终止点.
+** 输 入 : ulAddr 终止点地址
+** pulIns 返回的之前的指令
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+VOID archDbgApRemove (addr_t ulAddr, ULONG ulIns)
+{
+ lib_memcpy((PCHAR)ulAddr, (PCHAR)&ulIns, sizeof(UINT16));
+ KN_SMP_MB();
+
+#if LW_CFG_CACHE_EN > 0
+ API_CacheTextUpdate((PVOID)ulAddr, sizeof(UINT16));
+#endif /* LW_CFG_CACHE_EN > 0 */
+}
+/*********************************************************************************************************
** 函数名称: archDbgBpPrefetch
** 功能描述: 预取一个指令.
当指令处于 MMU 共享物理段时, 指令空间为物理只读, 这里需要产生一次缺页中断, 克隆一个物理页面.
@@ -133,24 +150,23 @@ VOID archDbgBpPrefetch (addr_t ulAddr)
*********************************************************************************************************/
UINT archDbgTrapType (addr_t ulAddr, PVOID pvArch)
{
+ PLW_CLASS_TCB ptcbCur;
#if (LW_CFG_SMP_EN > 0) && (LW_CFG_CACHE_EN > 0) && (LW_CFG_GDB_SMP_TU_LAZY > 0)
- ULONG ulCPUId;
+ ULONG ulCPUId;
#endif /* LW_CFG_SMP_EN > 0 */
if (API_DtraceIsValid() == LW_FALSE) { /* 不存在调试节点 */
return (LW_TRAP_INVAL);
}
- switch (*(UINT16 *)ulAddr) {
-
- case RISCV_BREAKPOINT_INS:
- return (LW_TRAP_BRKPT);
+ if (*(UINT16 *)ulAddr == RISCV_BREAKPOINT_INS) {
+ LW_TCB_GET_CUR_SAFE(ptcbCur);
- case RISCV_ABORTPOINT_INS:
- return (LW_TRAP_ABORT);
-
- default:
- break;
+ if (ptcbCur->TCB_ulAbortPointAddr == ulAddr) {
+ return (LW_TRAP_ABORT);
+ } else {
+ return (LW_TRAP_BRKPT);
+ }
}
#if (LW_CFG_SMP_EN > 0) && (LW_CFG_CACHE_EN > 0) && (LW_CFG_GDB_SMP_TU_LAZY > 0)
diff --git a/SylixOS/arch/riscv/riscv_support.h b/SylixOS/arch/riscv/riscv_support.h
index 577a0c6..104d2bb 100644
--- a/SylixOS/arch/riscv/riscv_support.h
+++ b/SylixOS/arch/riscv/riscv_support.h
@@ -104,6 +104,7 @@ PLW_STACK archCtxStackEnd(const ARCH_REG_CTX *pregctx);
VOID archDbgBpInsert(addr_t ulAddr, size_t stSize, ULONG *pulIns, BOOL bLocal);
VOID archDbgAbInsert(addr_t ulAddr, ULONG *pulIns);
VOID archDbgBpRemove(addr_t ulAddr, size_t stSize, ULONG ulIns, BOOL bLocal);
+VOID archDbgApRemove(addr_t ulAddr, ULONG ulIns);
VOID archDbgBpPrefetch(addr_t ulAddr);
UINT archDbgTrapType(addr_t ulAddr, PVOID pvArch);
VOID archDbgBpAdjust(PVOID pvDtrace, PVOID pvtm);
diff --git a/SylixOS/arch/sparc/dbg/sparcDbg.c b/SylixOS/arch/sparc/dbg/sparcDbg.c
index 9308e4d..1eeeca3 100644
--- a/SylixOS/arch/sparc/dbg/sparcDbg.c
+++ b/SylixOS/arch/sparc/dbg/sparcDbg.c
@@ -108,6 +108,24 @@ VOID archDbgBpRemove (addr_t ulAddr, size_t stSize, ULONG ulIns, BOOL bLocal
#endif /* LW_CFG_CACHE_EN > 0 */
}
/*********************************************************************************************************
+** 函数名称: archDbgApRemove
+** 功能描述: 删除一个终止点.
+** 输 入 : ulAddr 终止点地址
+** pulIns 返回的之前的指令
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+VOID archDbgApRemove (addr_t ulAddr, ULONG ulIns)
+{
+ lib_memcpy((PCHAR)ulAddr, (PCHAR)&ulIns, sizeof(ULONG));
+ KN_SMP_MB();
+
+#if LW_CFG_CACHE_EN > 0
+ API_CacheTextUpdate((PVOID)ulAddr, sizeof(ULONG));
+#endif /* LW_CFG_CACHE_EN > 0 */
+}
+/*********************************************************************************************************
** 函数名称: archDbgBpPrefetch
** 功能描述: 预取一个指令.
当指令处于 MMU 共享物理段时, 指令空间为物理只读, 这里需要产生一次缺页中断, 克隆一个物理页面.
diff --git a/SylixOS/arch/sparc/sparc_support.h b/SylixOS/arch/sparc/sparc_support.h
index fab1b83..e29d11d 100644
--- a/SylixOS/arch/sparc/sparc_support.h
+++ b/SylixOS/arch/sparc/sparc_support.h
@@ -102,6 +102,7 @@ PLW_STACK archCtxStackEnd(const ARCH_REG_CTX *pregctx);
VOID archDbgBpInsert(addr_t ulAddr, size_t stSize, ULONG *pulIns, BOOL bLocal);
VOID archDbgAbInsert(addr_t ulAddr, ULONG *pulIns);
VOID archDbgBpRemove(addr_t ulAddr, size_t stSize, ULONG ulIns, BOOL bLocal);
+VOID archDbgApRemove(addr_t ulAddr, ULONG ulIns);
VOID archDbgBpPrefetch(addr_t ulAddr);
UINT archDbgTrapType(addr_t ulAddr, PVOID pvArch);
VOID archDbgBpAdjust(PVOID pvDtrace, PVOID pvtm);
diff --git a/SylixOS/arch/x86/dbg/x86Dbg.c b/SylixOS/arch/x86/dbg/x86Dbg.c
index b44187a..897505f 100644
--- a/SylixOS/arch/x86/dbg/x86Dbg.c
+++ b/SylixOS/arch/x86/dbg/x86Dbg.c
@@ -104,6 +104,24 @@ VOID archDbgBpRemove (addr_t ulAddr, size_t stSize, ULONG ulIns, BOOL bLoca
#endif /* LW_CFG_CACHE_EN > 0 */
}
/*********************************************************************************************************
+** 函数名称: archDbgApRemove
+** 功能描述: 删除一个终止点.
+** 输 入 : ulAddr 终止点地址
+** pulIns 返回的之前的指令
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+VOID archDbgApRemove (addr_t ulAddr, ULONG ulIns)
+{
+ *(UINT8 *)ulAddr = (UINT8)ulIns;
+ KN_SMP_MB();
+
+#if LW_CFG_CACHE_EN > 0
+ API_CacheTextUpdate((PVOID)ulAddr, sizeof(UINT8));
+#endif /* LW_CFG_CACHE_EN > 0 */
+}
+/*********************************************************************************************************
** 函数名称: archDbgBpPrefetch
** 功能描述: 预取一个指令.
当指令处于 MMU 共享物理段时, 指令空间为物理只读, 这里需要产生一次缺页中断, 克隆一个物理页面.
@@ -129,8 +147,9 @@ VOID archDbgBpPrefetch (addr_t ulAddr)
*********************************************************************************************************/
UINT archDbgTrapType (addr_t ulAddr, PVOID pvArch)
{
+ PLW_CLASS_TCB ptcbCur;
#if (LW_CFG_SMP_EN > 0) && (LW_CFG_CACHE_EN > 0) && (LW_CFG_GDB_SMP_TU_LAZY > 0)
- ULONG ulCPUId;
+ ULONG ulCPUId;
#endif /* LW_CFG_SMP_EN > 0 */
if (API_DtraceIsValid() == LW_FALSE) { /* 不存在调试节点 */
@@ -141,13 +160,14 @@ UINT archDbgTrapType (addr_t ulAddr, PVOID pvArch)
return (LW_TRAP_ISTEP);
}
- switch (*(UINT8 *)ulAddr) {
+ if (*(UINT8 *)ulAddr == X86_BREAKPOINT_INS) {
+ LW_TCB_GET_CUR_SAFE(ptcbCur);
- case X86_BREAKPOINT_INS:
- return (LW_TRAP_BRKPT);
-
- default:
- break;
+ if (ptcbCur->TCB_ulAbortPointAddr == ulAddr) {
+ return (LW_TRAP_ABORT);
+ } else {
+ return (LW_TRAP_BRKPT);
+ }
}
#if (LW_CFG_SMP_EN > 0) && (LW_CFG_CACHE_EN > 0) && (LW_CFG_GDB_SMP_TU_LAZY > 0)
diff --git a/SylixOS/arch/x86/x86_support.h b/SylixOS/arch/x86/x86_support.h
index cbd4df1..d3f5097 100644
--- a/SylixOS/arch/x86/x86_support.h
+++ b/SylixOS/arch/x86/x86_support.h
@@ -105,6 +105,7 @@ PLW_STACK archCtxStackEnd(const ARCH_REG_CTX *pregctx);
VOID archDbgBpInsert(addr_t ulAddr, size_t stSize, ULONG *pulIns, BOOL bLocal);
VOID archDbgAbInsert(addr_t ulAddr, ULONG *pulIns);
VOID archDbgBpRemove(addr_t ulAddr, size_t stSize, ULONG ulIns, BOOL bLocal);
+VOID archDbgApRemove(addr_t ulAddr, ULONG ulIns);
VOID archDbgBpPrefetch(addr_t ulAddr);
UINT archDbgTrapType(addr_t ulAddr, PVOID pvArch);
VOID archDbgBpAdjust(PVOID pvDtrace, PVOID pvtm);
diff --git a/SylixOS/debug/dtrace/dtrace.c b/SylixOS/debug/dtrace/dtrace.c
index a71655c..5cca0ec 100644
--- a/SylixOS/debug/dtrace/dtrace.c
+++ b/SylixOS/debug/dtrace/dtrace.c
@@ -266,6 +266,12 @@ INT API_DtraceBreakTrap (addr_t ulAddr, UINT uiBpType)
}
#endif /* LW_CFG_SMP_EN > 0 */
+ if (uiBpType == LW_TRAP_ABORT) { /* 恢复终止点指令 */
+ archDbgApRemove(ulAddr, ptcbCur->TCB_ulAbortPointInst);
+ ptcbCur->TCB_ulAbortPointInst = 0;
+ ptcbCur->TCB_ulAbortPointAddr = 0;
+ }
+
dtm.DTM_ulAddr = ulAddr;
dtm.DTM_uiType = uiBpType; /* 获得 trap 类型 */
dtm.DTM_ulThread = ptcbCur->TCB_ulId;
@@ -330,7 +336,6 @@ LW_API
INT API_DtraceAbortTrap (addr_t ulAddr)
{
#if LW_CFG_MODULELOADER_EN > 0
- ULONG ulIns;
PLW_LIST_LINE plineTemp;
LW_LD_VPROC *pvproc;
PLW_CLASS_TCB ptcbCur;
@@ -344,7 +349,8 @@ INT API_DtraceAbortTrap (addr_t ulAddr)
}
if (pvproc->VP_iDbgFlags & LW_VPROC_DEBUG_TRAP) { /* 需要停止下来 */
- archDbgAbInsert(ulAddr, &ulIns); /* 建立一个断点 */
+ ptcbCur->TCB_ulAbortPointAddr = ulAddr;
+ archDbgAbInsert(ulAddr, &ptcbCur->TCB_ulAbortPointInst); /* 建立一个终止点 */
vprocDebugStop(pvproc, ptcbCur); /* 需要停止进程内其他线程 */
return (ERROR_NONE);
}
@@ -364,7 +370,8 @@ INT API_DtraceAbortTrap (addr_t ulAddr)
return (PX_ERROR);
} else {
- archDbgAbInsert(ulAddr, &ulIns); /* 建立一个断点 */
+ ptcbCur->TCB_ulAbortPointAddr = ulAddr;
+ archDbgAbInsert(ulAddr, &ptcbCur->TCB_ulAbortPointInst); /* 建立一个终止点 */
return (ERROR_NONE);
}
#else
diff --git a/SylixOS/include/sys/semfd.h b/SylixOS/include/sys/semfd.h
index 70a94c3..f6ba6c6 100644
--- a/SylixOS/include/sys/semfd.h
+++ b/SylixOS/include/sys/semfd.h
@@ -43,13 +43,13 @@ typedef enum {
#define SEMFD_OPT_DELETE_SAFE LW_OPTION_DELETE_SAFE /* Only for mutex */
/*********************************************************************************************************
- set/get parameter
+ set/get parameter (Initial value and Max value <= INT32_MAX)
*********************************************************************************************************/
struct semfd_param {
semfd_type sem_type; /* Type */
UINT32 sem_opts; /* Options */
- UINT32 sem_value; /* Initialize value */
+ UINT32 sem_value; /* Initial value */
UINT32 sem_max; /* Max value */
UINT32 auto_unlink; /* unlink on last close */
UINT32 reserved[3];
diff --git a/SylixOS/kernel/include/k_class.h b/SylixOS/kernel/include/k_class.h
index e1aebac..517f019 100644
--- a/SylixOS/kernel/include/k_class.h
+++ b/SylixOS/kernel/include/k_class.h
@@ -697,6 +697,8 @@ typedef struct __lw_tcb {
addr_t TCB_ulStepAddr; /* 单步地址,-1 表示非单步模式 */
ULONG TCB_ulStepInst; /* 单步地址指令备份 */
BOOL TCB_bStepClear; /* 单步断点是否被清除 */
+ addr_t TCB_ulAbortPointAddr; /* 终止点地址 */
+ ULONG TCB_ulAbortPointInst; /* 终止点地址指令备份 */
#endif
/*********************************************************************************************************
diff --git a/SylixOS/kernel/show/ThreadShow.c b/SylixOS/kernel/show/ThreadShow.c
index 7c98f6d..31a3c4a 100644
--- a/SylixOS/kernel/show/ThreadShow.c
+++ b/SylixOS/kernel/show/ThreadShow.c
@@ -115,12 +115,9 @@ VOID API_ThreadShowEx (pid_t pid)
continue;
}
-#if LW_CFG_CPU_WORD_LENGHT == 64
- if (tcbdesc.TCBD_ulWakeupLeft > 999999999l) {
+ if (tcbdesc.TCBD_ulWakeupLeft > INT_MAX) {
lib_strcpy(cWakeupLeft, "--");
- } else
-#endif
- {
+ } else {
lib_itoa((int)tcbdesc.TCBD_ulWakeupLeft, cWakeupLeft, 10);
}
@@ -334,12 +331,9 @@ VOID API_ThreadPendShowEx (pid_t pid)
continue;
}
-#if LW_CFG_CPU_WORD_LENGHT == 64
- if (tcbdesc.TCBD_ulWakeupLeft > 9999999999l) {
+ if (tcbdesc.TCBD_ulWakeupLeft > INT_MAX) {
lib_strcpy(cWakeupLeft, "--");
- } else
-#endif
- {
+ } else {
lib_itoa((int)tcbdesc.TCBD_ulWakeupLeft, cWakeupLeft, 10);
}
diff --git a/SylixOS/system/device/semfd/semfdDev.c b/SylixOS/system/device/semfd/semfdDev.c
index e984c86..c8fcc5f 100644
--- a/SylixOS/system/device/semfd/semfdDev.c
+++ b/SylixOS/system/device/semfd/semfdDev.c
@@ -229,6 +229,12 @@ static INT _semfdSetInode (PLW_SEMFD_INODE psemfdinode, struct semfd_param *pa
return (PX_ERROR);
}
+ if ((param->sem_value > INT32_MAX) ||
+ (param->sem_max > INT32_MAX)) {
+ _ErrorHandle(EINVAL);
+ return (PX_ERROR);
+ }
+
ulOpt |= param->sem_opts;
switch (param->sem_type) {
@@ -697,7 +703,7 @@ static INT _semfdNFreeFnode (PLW_SEMFD_FILE psemfdfil, INT *piNFree)
case _OBJECT_SEM_C:
API_SemaphoreCStatusEx(psemfdfil->SEMFDF_pinode->SEMFDI_ulSem, &ulValue, LW_NULL, LW_NULL, &ulMaxValue);
if (ulValue < ulMaxValue) {
- *piNFree = 1;
+ *piNFree = (INT)(ulMaxValue - ulValue);
}
break;
@@ -758,7 +764,7 @@ static INT _semfdNReadFnode (PLW_SEMFD_FILE psemfdfil, INT *piNRead)
case _OBJECT_SEM_C:
API_SemaphoreCStatus(psemfdfil->SEMFDF_pinode->SEMFDI_ulSem, &ulValue, LW_NULL, LW_NULL);
if (ulValue) {
- *piNRead = 1;
+ *piNRead = (INT)ulValue;
}
break;