feat: reformatted code base to be more standard
This commit is contained in:
@@ -2,25 +2,27 @@
|
||||
// Created by rick on 08-03-21.
|
||||
//
|
||||
|
||||
#include <debug/debug.h>
|
||||
#include <elf.h>
|
||||
#include <libk/libk.h>
|
||||
#include <libc/libc.h>
|
||||
#include <libc/kprintf.h>
|
||||
#include <libc/string.h>
|
||||
#include <libk/kprint.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
static struct elf32_section_header* elf_headers = NULL;
|
||||
static struct elf32_section_header* elf_shstrtab = NULL;
|
||||
static struct elf32_section_header* elf_symtab = NULL;
|
||||
static struct elf32_section_header* elf_strtab = NULL;
|
||||
#define DEBUG_INIT
|
||||
|
||||
#include <myke/debug/debug.h>
|
||||
#include <myke/elf.h>
|
||||
#include <myke/libk/libk.h>
|
||||
#include <myke/libk/kprint.h>
|
||||
|
||||
static struct elf32_section_header *elf_headers = NULL;
|
||||
static struct elf32_section_header *elf_shstrtab = NULL;
|
||||
static struct elf32_section_header *elf_symtab = NULL;
|
||||
static struct elf32_section_header *elf_strtab = NULL;
|
||||
static uint32_t elf_header_cnt;
|
||||
|
||||
static const char* elf_name_symtab = ".symtab";
|
||||
static const char* elf_name_strtab = ".strtab";
|
||||
static const char *elf_name_symtab = ".symtab";
|
||||
static const char *elf_name_strtab = ".strtab";
|
||||
|
||||
struct stackframe {
|
||||
struct stackframe* ebp;
|
||||
struct stackframe *ebp;
|
||||
uint32_t eip;
|
||||
};
|
||||
|
||||
@@ -31,7 +33,7 @@ char *debug_get_shstrtab_entry(uint32_t ndx) {
|
||||
if (ndx > elf_shstrtab->sh_size) {
|
||||
return NULL;
|
||||
}
|
||||
return ((char*)elf_shstrtab->sh_addr + ndx);
|
||||
return ((char *) elf_shstrtab->sh_addr + ndx);
|
||||
}
|
||||
|
||||
char *debug_get_strtab_entry(uint32_t ndx) {
|
||||
@@ -41,7 +43,7 @@ char *debug_get_strtab_entry(uint32_t ndx) {
|
||||
if (ndx > elf_strtab->sh_size) {
|
||||
return NULL;
|
||||
}
|
||||
return ((char*)elf_strtab->sh_addr + ndx);
|
||||
return ((char *) elf_strtab->sh_addr + ndx);
|
||||
}
|
||||
|
||||
void debug_find_sections(uint32_t shndx) {
|
||||
@@ -76,11 +78,11 @@ void debug_store_info(struct multiboot_info *info) {
|
||||
debug_find_sections(info->u.elf_sec.shndx);
|
||||
}
|
||||
|
||||
struct elf32_symtab_entry* debug_get_entry_for_addr(uint32_t addr) {
|
||||
struct elf32_symtab_entry *debug_get_entry_for_addr(uint32_t addr) {
|
||||
if (elf_symtab == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
struct elf32_symtab_entry* first = (struct elf32_symtab_entry *) elf_symtab->sh_addr;
|
||||
struct elf32_symtab_entry *first = (struct elf32_symtab_entry *) elf_symtab->sh_addr;
|
||||
uint32_t num = elf_symtab->sh_size / sizeof(struct elf32_symtab_entry);
|
||||
for (uint32_t i = 0; i < num; ++i) {
|
||||
// only functions for now
|
||||
@@ -96,7 +98,7 @@ struct elf32_symtab_entry* debug_get_entry_for_addr(uint32_t addr) {
|
||||
|
||||
void debug_backtrace(bool do_sync) {
|
||||
struct stackframe *frame = __builtin_frame_address(0);
|
||||
void (*printer)(const char*) = do_sync ? kprint_sync : kprint;
|
||||
void (*printer)(const char *) = do_sync ? kprint_sync : kprint;
|
||||
printer("\n\n## Stack Trace ##\n");
|
||||
char msg[1024] = {0};
|
||||
while (frame->ebp != NULL) {
|
||||
|
||||
Reference in New Issue
Block a user