Added debug_strlcpy() for use in the kernel debugger.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33380 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -131,6 +131,7 @@ extern bool debug_is_kernel_memory_accessible(addr_t address, size_t size,
|
|||||||
extern int debug_call_with_fault_handler(jmp_buf jumpBuffer,
|
extern int debug_call_with_fault_handler(jmp_buf jumpBuffer,
|
||||||
void (*function)(void*), void* parameter);
|
void (*function)(void*), void* parameter);
|
||||||
extern status_t debug_memcpy(void* to, const void* from, size_t size);
|
extern status_t debug_memcpy(void* to, const void* from, size_t size);
|
||||||
|
extern ssize_t debug_strlcpy(char* to, const char* from, size_t size);
|
||||||
|
|
||||||
extern char kgetc(void);
|
extern char kgetc(void);
|
||||||
extern void kputs(const char *string);
|
extern void kputs(const char *string);
|
||||||
|
|||||||
@@ -55,6 +55,13 @@ struct debug_memcpy_parameters {
|
|||||||
size_t size;
|
size_t size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct debug_strlcpy_parameters {
|
||||||
|
char* to;
|
||||||
|
const char* from;
|
||||||
|
size_t size;
|
||||||
|
size_t result;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
static const char* const kKDLPrompt = "kdebug> ";
|
static const char* const kKDLPrompt = "kdebug> ";
|
||||||
|
|
||||||
@@ -1180,6 +1187,16 @@ debug_memcpy_trampoline(void* _parameters)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
debug_strlcpy_trampoline(void* _parameters)
|
||||||
|
{
|
||||||
|
debug_strlcpy_parameters* parameters
|
||||||
|
= (debug_strlcpy_parameters*)_parameters;
|
||||||
|
parameters->result = strlcpy(parameters->to, parameters->from,
|
||||||
|
parameters->size);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
call_modules_hook(bool enter)
|
call_modules_hook(bool enter)
|
||||||
{
|
{
|
||||||
@@ -1522,6 +1539,22 @@ debug_memcpy(void* to, const void* from, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*! Similar to user_strlcpy(), but can only be invoked from within the kernel
|
||||||
|
debugger (and must not be used outside).
|
||||||
|
*/
|
||||||
|
ssize_t
|
||||||
|
debug_strlcpy(char* to, const char* from, size_t size)
|
||||||
|
{
|
||||||
|
debug_strlcpy_parameters parameters = {to, from, size};
|
||||||
|
|
||||||
|
if (debug_call_with_fault_handler(gCPU[sDebuggerOnCPU].fault_jump_buffer,
|
||||||
|
&debug_strlcpy_trampoline, ¶meters) != 0) {
|
||||||
|
return B_BAD_ADDRESS;
|
||||||
|
}
|
||||||
|
return parameters.result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - public API
|
// #pragma mark - public API
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user