📄 s390dbf.txt
字号:
S390 Debug Feature==================files: arch/s390/kernel/debug.c include/asm-s390/debug.hDescription:------------The goal of this feature is to provide a kernel debug logging API where log records can be stored efficiently in memory, where each component (e.g. device drivers) can have one seperate debug log.One purpose of this is to inspect the debug logs after a production system crashin order to analyze the reason for the crash.If the system still runs but only a subcomponent which uses dbf failes,it is possible to look at the debug logs on a live system via the Linux procfilesystem.The debug feature may also very usefull for kernel and driver development.Design:-------Kernel components (e.g. device drivers) can register themselves at the debug feature with the function call debug_register(). This function initializes a debug log for the caller. For each debug log exists a number of debug areas where exactly one is active at one time. Each debug area consists of contiguouspages in memory. In the debug areas there are stored debug entries (log records)which are written by event- and exception-calls. An event-call writes the specified debug entry to the active debugarea and updates the log pointer for the active area. If the end of the active debug area is reached, a wrap around is done (ring buffer) and the next debug entry will be written at the beginning of the active debug area.An exception-call writes the specified debug entry to the log andswitches to the next debug area. This is done in order to be surethat the records which describe the origin of the exception are notoverwritten when a wrap around for the current area occurs.The debug areas itselve are also ordered in form of a ring buffer. When an exception is thrown in the last debug area, the following debug entries are then written again in the very first area.There are three versions for the event- and exception-calls: One forlogging raw data, one for text and one for numbers.Each debug entry contains the following data:- Timestamp- Cpu-Number of calling task- Level of debug entry (0...6)- Return Address to caller- Flag, if entry is an exception or notThe debug logs can be inspected in a live system through entries inthe proc-filesystem. Under the path /proc/s390dbf there is a directory for each registered component, which is named like thecorresponding component.The content of the directories are files which represent different viewsto the debug log. Each component can decide which views should beused through registering them with the function debug_register_view().Predefined views for hex/ascii, sprintf and raw binary data are provided.It is also possible to define other views. The content ofa view can be inspected simply by reading the corresponding proc file.All debug logs have an an actual debug level (range from 0 to 6).The default level is 3. Event and Exception functions have a 'level'parameter. Only debug entries with a level that is lower or equalthan the actual level are written to the log. This means that high priority log entries should have a low level value whereas low priorityentries should have a high one. The actual debug level can be changed with the help of the proc-filesystem through writing a number string "x" to the 'level' proc file which isprovided for every debug log. Debugging can be switched off completelyby using "-" on the 'level' proc file.Example:> echo "-" > /proc/s390dbf/dasd/levelKernel Interfaces:----------------------------------------------------------------------------------------------debug_info_t *debug_register(char *name, int pages_index, int nr_areas, int buf_size);Parameter: name: Name of debug log (e.g. used for proc entry) pages_index: 2^pages_index pages will be allocated per area nr_areas: number of debug areas buf_size: size of data area in each debug entryReturn Value: Handle for generated debug area NULL if register failed Description: Allocates memory for a debug log Must not be called within an interrupt handler ---------------------------------------------------------------------------void debug_unregister (debug_info_t * id);Parameter: id: handle for debug log Return Value: none Description: frees memory for a debug log Must not be called within an interrupt handler ---------------------------------------------------------------------------void debug_set_level (debug_info_t * id, int new_level);Parameter: id: handle for debug log new_level: new debug level Return Value: none Description: Sets new actual debug level if new_level is valid. ---------------------------------------------------------------------------debug_entry_t* debug_event (debug_info_t* id, int level, void* data, int length);Parameter: id: handle for debug log level: debug level data: pointer to data for debug entry length: length of data in bytes Return Value: Address of written debug entry Description: writes debug entry to active debug area (if level <= actual debug level) ---------------------------------------------------------------------------debug_entry_t* debug_int_event (debug_info_t * id, int level, unsigned int data);debug_entry_t* debug_long_event(debug_info_t * id, int level, unsigned long data);Parameter: id: handle for debug log level: debug level data: integer value for debug entry Return Value: Address of written debug entry Description: writes debug entry to active debug area (if level <= actual debug level) ---------------------------------------------------------------------------debug_entry_t* debug_text_event (debug_info_t * id, int level, const char* data);Parameter: id: handle for debug log level: debug level data: string for debug entry Return Value: Address of written debug entry Description: writes debug entry in ascii format to active debug area (if level <= actual debug level) ---------------------------------------------------------------------------debug_entry_t* debug_sprintf_event (debug_info_t * id, int level, char* string,...);Parameter: id: handle for debug log level: debug level string: format string for debug entry ...: varargs used as in sprintf()Return Value: Address of written debug entryDescription: writes debug entry with format string and varargs (longs) to active debug area (if level $<=$ actual debug level). floats and long long datatypes cannot be used as varargs.---------------------------------------------------------------------------debug_entry_t* debug_exception (debug_info_t* id, int level, void* data, int length);Parameter: id: handle for debug log level: debug level data: pointer to data for debug entry length: length of data in bytes Return Value: Address of written debug entry Description: writes debug entry to active debug area (if level <= actual debug level) and switches to next debug area ---------------------------------------------------------------------------debug_entry_t* debug_int_exception (debug_info_t * id, int level, unsigned int data);debug_entry_t* debug_long_exception(debug_info_t * id, int level, unsigned long data);Parameter: id: handle for debug log level: debug level data: integer value for debug entry Return Value: Address of written debug entry Description: writes debug entry to active debug area (if level <= actual debug level) and switches to next debug area ---------------------------------------------------------------------------debug_entry_t* debug_text_exception (debug_info_t * id, int level, const char* data);Parameter: id: handle for debug log level: debug level data: string for debug entry Return Value: Address of written debug entry Description: writes debug entry in ascii format to active debug area (if level <= actual debug level) and switches to next debug area ---------------------------------------------------------------------------debug_entry_t* debug_sprintf_exception (debug_info_t * id, int level, char* string,...);Parameter: id: handle for debug log level: debug level string: format string for debug entry ...: varargs used as in sprintf()Return Value: Address of written debug entry Description: writes debug entry with format string and varargs (longs) to active debug area (if level $<=$ actual debug level) and switches to next debug area. floats and long long datatypes cannot be used as varargs.---------------------------------------------------------------------------int debug_register_view (debug_info_t * id, struct debug_view *view);Parameter: id: handle for debug log view: pointer to debug view struct Return Value: 0 : ok < 0: Error Description: registers new debug view and creates proc dir entry ---------------------------------------------------------------------------int debug_unregister_view (debug_info_t * id, struct debug_view *view); Parameter: id: handle for debug log view: pointer to debug view struct Return Value: 0 : ok < 0: Error Description: unregisters debug view and removes proc dir entry Predefined views:-----------------extern struct debug_view debug_hex_ascii_view;extern struct debug_view debug_raw_view;extern struct debug_view debug_sprintf_view;Examples--------/* * hex_ascii- + raw-view Example */#include <linux/module.h>#include <asm/debug.h>static debug_info_t* debug_info;int init_module(void){ /* register 4 debug areas with one page each and 4 byte data field */ debug_info = debug_register ("test", 0, 4, 4 ); debug_register_view(debug_info,&debug_hex_ascii_view); debug_register_view(debug_info,&debug_raw_view); debug_text_event(debug_info, 4 , "one ");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -