-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refs #1, change C++ STL map to C page table
- Loading branch information
1 parent
e55f8c8
commit ca83886
Showing
17 changed files
with
1,114 additions
and
63,875 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
### log version | ||
|
||
#### 001 -- 2018-01-15 -- first version | ||
#### 001 -- 2018-01-15 -- first version | ||
|
||
- X (70 - 80) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Source files to be used in the library | ||
set(LIB_SOURCES | ||
src/logger.c | ||
src/aproflib.c | ||
) | ||
|
||
set(LIB_INCLUDE | ||
${PROJECT_SOURCE_DIR}/runtime/AProfHooks/include | ||
) | ||
|
||
add_library(AProfHooks STATIC | ||
${LIB_SOURCES} | ||
) | ||
|
||
target_include_directories(AProfHooks | ||
PUBLIC ${LIB_INCLUDE} | ||
) | ||
|
||
|
||
## TODO: this is for building LogMem. | ||
############################################################ | ||
# Create an executable | ||
############################################################ | ||
|
||
# Source fles for the binary | ||
set(BINARY_SOURCES | ||
src/log_mem_to_file.c | ||
) | ||
|
||
# Add an executable with the above sources | ||
add_executable(AprofLogMem ${BINARY_SOURCES}) | ||
|
||
# link the new hello_library target with the hello_binary target | ||
target_link_libraries(AprofLogMem rt) | ||
|
||
|
||
## TODO: this is for testing runtime lib. | ||
############################################################ | ||
# Create an executable | ||
############################################################ | ||
|
||
# Source fles for the binary | ||
set(BINARY_SOURCES | ||
src/test_runtime.c | ||
) | ||
|
||
# Add an executable with the above sources | ||
add_executable(testHook ${BINARY_SOURCES}) | ||
|
||
# link the new hello_library target with the hello_binary target | ||
target_link_libraries(testHook | ||
PRIVATE AProfHooks | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
### log version | ||
|
||
#### 002 -- 2018-01-18 -- second version | ||
|
||
- change C++ STL stack and map to C page table and array. | ||
- X (10 - 20) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#ifndef APROFHOOKS_LIBRARY_H | ||
#define APROFHOOKS_LIBRARY_H | ||
|
||
#include <fcntl.h> | ||
#include <malloc.h> | ||
#include <stdlib.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <sys/mman.h> | ||
#include <unistd.h> | ||
|
||
|
||
// page table | ||
|
||
#define PAGE_SIZE 4096 | ||
#define L0_TABLE_SIZE 4 | ||
#define L1_TABLE_SIZE 512 | ||
#define L4_TABLE_SIZE 1024 | ||
|
||
#define L0_MASK 0xC00000000000 | ||
#define L1_MASK 0x3FE000000000 | ||
#define L2_MASK 0x1FF0000000 | ||
#define L3_MASK 0xFF80000 | ||
#define L4_MASK 0x7FC00 | ||
#define L5_MASK 0x3FF | ||
|
||
void init_page_table(); | ||
|
||
unsigned long query_page_table(unsigned long address); | ||
|
||
void insert_page_table(unsigned long address, unsigned long count); | ||
|
||
void destroy_page_table(); | ||
|
||
// page table | ||
|
||
|
||
#define BUFFERSIZE (unsigned long)1 << 24 | ||
#define APROF_MEM_LOG "/aprof_log.log" | ||
|
||
struct stack_elem { | ||
int funcId; // function id | ||
unsigned long ts; // time stamp | ||
unsigned long rms; | ||
unsigned long cost; | ||
}; | ||
|
||
void logger_init(); | ||
|
||
char * _init_share_mem(); | ||
|
||
int aprof_init(); | ||
|
||
void aprof_write(void *memory_addr, unsigned int length); | ||
|
||
void aprof_read(void *memory, unsigned int length); | ||
|
||
void aprof_increment_cost(); | ||
|
||
void aprof_increment_rms(); | ||
|
||
void aprof_call_before(int funcId, unsigned long numCost); | ||
|
||
void aprof_collect(); | ||
|
||
void aprof_call_after(); | ||
|
||
void aprof_return(unsigned long numCost); | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Copyright (c) 2017 rxi | ||
* | ||
* This library is free software; you can redistribute it and/or modify it | ||
* under the terms of the MIT license. See `log.c` for details. | ||
* source code: https://github.com/rxi/log.c/blob/master/src/log.h | ||
*/ | ||
|
||
#ifndef COMAIR_LOGGER_H | ||
#define COMAIR_LOGGER_H | ||
|
||
|
||
#include <stdio.h> | ||
#include <stdarg.h> | ||
|
||
#define LOG_VERSION "0.1.0" | ||
|
||
typedef void (*log_LockFn)(void *udata, int lock); | ||
|
||
enum { | ||
LOG_TRACE, LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR, LOG_FATAL | ||
}; | ||
|
||
|
||
#define log_trace(...) log_log(LOG_TRACE, __FILE__, __LINE__, __VA_ARGS__) | ||
#define log_debug(...) log_log(LOG_DEBUG, __FILE__, __LINE__, __VA_ARGS__) | ||
#define log_info(...) log_log(LOG_INFO, __FILE__, __LINE__, __VA_ARGS__) | ||
#define log_warn(...) log_log(LOG_WARN, __FILE__, __LINE__, __VA_ARGS__) | ||
#define log_error(...) log_log(LOG_ERROR, __FILE__, __LINE__, __VA_ARGS__) | ||
#define log_fatal(...) log_log(LOG_FATAL, __FILE__, __LINE__, __VA_ARGS__) | ||
|
||
|
||
void log_set_udata(void *udata); | ||
|
||
void log_set_lock(log_LockFn fn); | ||
|
||
void log_set_fp(FILE *fp); | ||
|
||
void log_set_level(int level); | ||
|
||
void log_set_quiet(int enable); | ||
|
||
void log_init(FILE *fp, int level, int enable); | ||
|
||
void log_log(int level, const char *file, int line, const char *fmt, ...); | ||
|
||
#endif //COMAIR_LOGGER_H |
Oops, something went wrong.