Update...
This commit is contained in:
parent
314a5d4c71
commit
746a1ad2ad
5 changed files with 42 additions and 34 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
|
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2024/04/28 17:28:30 by maiboyer #+# #+# #
|
# Created: 2024/04/28 17:28:30 by maiboyer #+# #+# #
|
||||||
# Updated: 2024/05/08 15:03:15 by maiboyer ### ########.fr #
|
# Updated: 2024/05/08 22:15:45 by maiboyer ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
OBJDIRNAME ?=
|
OBJDIRNAME ?=
|
||||||
|
|
||||||
# Flags
|
# Flags
|
||||||
CFLAGS = -Werror -Wextra -Wall -Wno-unused-command-line-argument -g3 -MMD -lreadline -I./includes -I./output/include -I./stdme/output/include -rdynamic
|
CFLAGS = -Werror -Wextra -Wall -Wno-unused-command-line-argument -g3 -MMD -lreadline -I./includes -I./output/include -I./stdme/output/include -rdynamic -Wl,-E
|
||||||
# Sources
|
# Sources
|
||||||
LIB = ./libft/ft_bzero.c \
|
LIB = ./libft/ft_bzero.c \
|
||||||
./libft/ft_calloc.c \
|
./libft/ft_calloc.c \
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,7 @@
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
in {
|
in {
|
||||||
devShell = pkgs.mkShell {
|
devShell = pkgs.mkShell {
|
||||||
packages = with pkgs; [clang valgrind gnumake readline.out readline.dev generic_c.packages.${system}.default];
|
packages = with pkgs; [clang valgrind gnumake readline.out readline.dev generic_c.packages.${system}.default llvmPackages.bintools];
|
||||||
shellHook = ''
|
|
||||||
alias 'valgrind'='valgrind --supressions=${./valgrind_readline_leaks_ignore.txt}';
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/02 13:20:25 by maiboyer #+# #+# */
|
/* Created: 2024/05/02 13:20:25 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/05/08 18:20:53 by maiboyer ### ########.fr */
|
/* Updated: 2024/05/08 21:52:34 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -14,10 +14,11 @@
|
||||||
#define SIGNAL_HANDLER_H
|
#define SIGNAL_HANDLER_H
|
||||||
|
|
||||||
#include "me/types.h"
|
#include "me/types.h"
|
||||||
#include <readline/readline.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <readline/readline.h>
|
||||||
|
|
||||||
typedef t_i32 t_signal;
|
typedef t_i32 t_signal;
|
||||||
|
|
||||||
t_error install_signal(void);
|
t_error install_signal(void);
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/07 09:47:50 by maiboyer #+# #+# */
|
/* Created: 2024/05/07 09:47:50 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/05/08 19:24:47 by maiboyer ### ########.fr */
|
/* Updated: 2024/05/08 22:05:36 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -41,7 +41,7 @@ t_error alloc_arena_page(t_usize min_size, t_arena_page **out)
|
||||||
{
|
{
|
||||||
t_arena_block *block;
|
t_arena_block *block;
|
||||||
|
|
||||||
printf("Allocating page with size %zu", min_size);
|
printf("Allocating page with size %zu\n", min_size);
|
||||||
min_size = usize_round_up_to(min_size, ARENA_SIZE_DEFAULT);
|
min_size = usize_round_up_to(min_size, ARENA_SIZE_DEFAULT);
|
||||||
if (out == NULL)
|
if (out == NULL)
|
||||||
return (ERROR);
|
return (ERROR);
|
||||||
|
|
|
||||||
|
|
@ -6,28 +6,41 @@
|
||||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2024/05/07 11:08:03 by maiboyer #+# #+# */
|
/* Created: 2024/05/07 11:08:03 by maiboyer #+# #+# */
|
||||||
/* Updated: 2024/05/08 19:39:37 by maiboyer ### ########.fr */
|
/* Updated: 2024/05/08 23:26:22 by maiboyer ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "me/fs/putstr_fd.h"
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
|
#include "me/alloc/alloc_internal.h"
|
||||||
#include "me/fs/putendl_fd.h"
|
#include "me/fs/putendl_fd.h"
|
||||||
|
#include "me/fs/putstr_fd.h"
|
||||||
#include "me/types.h"
|
#include "me/types.h"
|
||||||
|
#include <dlfcn.h>
|
||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
|
#include <link.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "me/alloc/alloc_internal.h"
|
|
||||||
|
|
||||||
#ifndef BASE_PATH
|
#ifndef BASE_PATH
|
||||||
# define BASE_PATH "/no_base_path_defined/"
|
# define BASE_PATH "/no_base_path_defined/"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PRINT_BACKTRACE) || defined(BACKTRACE_DEEP)
|
#if defined(PRINT_BACKTRACE) || defined(BACKTRACE_DEEP) || true
|
||||||
|
|
||||||
# ifndef BACKTRACE_DEEP
|
# ifndef BACKTRACE_DEEP
|
||||||
# define BACKTRACE_DEEP 256
|
# define BACKTRACE_DEEP 256
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
static size_t convert_to_vma(t_usize addr)
|
||||||
|
{
|
||||||
|
Dl_info info;
|
||||||
|
struct link_map *link_map;
|
||||||
|
|
||||||
|
dladdr1((void *)addr, &info, (void **)&link_map, RTLD_DL_LINKMAP);
|
||||||
|
return (addr - link_map->l_addr);
|
||||||
|
}
|
||||||
|
|
||||||
static void print_trace_inner(void **trace, t_str *messages, t_usize i)
|
static void print_trace_inner(void **trace, t_str *messages, t_usize i)
|
||||||
{
|
{
|
||||||
char syscom[1024];
|
char syscom[1024];
|
||||||
|
|
@ -35,18 +48,15 @@ static void print_trace_inner(void **trace, t_str *messages, t_usize i)
|
||||||
|
|
||||||
p = 0;
|
p = 0;
|
||||||
fprintf(stderr, "[bt] #%-4zu\t", i);
|
fprintf(stderr, "[bt] #%-4zu\t", i);
|
||||||
while (messages[i][p] != '(' && messages[i][p] != ' '
|
while (messages[i][p] != '(' && messages[i][p] != ' ' &&
|
||||||
&& messages[i][p] != 0)
|
messages[i][p] != 0)
|
||||||
++p;
|
++p;
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
snprintf(syscom, \
|
snprintf(
|
||||||
1024, \
|
syscom, sizeof(syscom) / sizeof(syscom[0]),
|
||||||
"addr2line %p -e %.*s -ipf | 1>&2 rg \"^(.*) at %s(.*)\"'$' " \
|
"addr2line %#x -e %.*s -ipfa"
|
||||||
"--replace '$1 at $2' --color never", \
|
"| 1>&2 rg \"^(.*) at %s(.*)\"'$' --replace '$1 at $2' --color never",
|
||||||
trace[i], \
|
(t_u32)(convert_to_vma((t_usize)trace[i])), p, messages[i], BASE_PATH);
|
||||||
p, \
|
|
||||||
messages[i], \
|
|
||||||
BASE_PATH);
|
|
||||||
if (system(syscom))
|
if (system(syscom))
|
||||||
fprintf(stderr, "%s\n", messages[i]);
|
fprintf(stderr, "%s\n", messages[i]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue