-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bootstrap: network_cmds depends on KeyronexKit
- Loading branch information
1 parent
4ed045e
commit a3af871
Showing
7 changed files
with
212 additions
and
0 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 |
---|---|---|
|
@@ -15,3 +15,4 @@ ports/ | |
bundled/ | ||
*.xbstrap | ||
build/ | ||
debug.log |
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 |
---|---|---|
|
@@ -459,6 +459,7 @@ packages: | |
- 'host-gcc' | ||
pkgs_required: | ||
- 'mlibc' | ||
- 'KeyronexKit' | ||
configure: | ||
- args: | ||
- 'meson' | ||
|
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,18 @@ | ||
%{ | ||
#include <stdlib.h> | ||
#include "parser.tab.h" | ||
|
||
extern int yylex(void); | ||
extern int yyerror(const char *); | ||
%} | ||
|
||
%option noyywrap nounput noinput | ||
|
||
%% | ||
"ALLOC" return ALLOC; | ||
"FREE" return FREE; | ||
[0-9]+ { yylval.i = atoi(yytext); return INT; } | ||
0[xX][0-9a-fA-F]+ { yylval.str = yytext; return HEX; } | ||
"str:"[^ \n\t]* { yylval.str = yytext + 4; return STR; } | ||
\n | ||
. |
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,57 @@ | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
|
||
#include <fcntl.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
|
||
#include "parser.tab.h" | ||
|
||
#include "result.hh" | ||
#include <iostream> | ||
|
||
std::map<std::string, Allocation> allocs; | ||
|
||
extern int yyparse(); | ||
|
||
int | ||
main(int argc, char **argv) | ||
{ | ||
int input; | ||
if (argc != 2) { | ||
printf("%s <input file>\n", argv[0]); | ||
return 1; | ||
} | ||
input = open(argv[1], O_RDONLY); | ||
dup2(input, STDIN_FILENO); | ||
close(input); | ||
// yydebug = true; | ||
yyparse(); | ||
|
||
for (auto &alloc : allocs) { | ||
std::cout << "By " << alloc.second.pid << " In " | ||
<< alloc.second.zone << ": " << alloc.first << "\n"; | ||
|
||
for (int i = 5; i < 7; i++) { | ||
std::string invocation = | ||
"addr2line -e ../../../build/system-root/boot/keyronex " + | ||
(*alloc.second.addresses)[i]; | ||
std::cout << " "; | ||
system(invocation.c_str()); | ||
} | ||
} | ||
} | ||
|
||
int | ||
yywrap(void) | ||
{ | ||
return 0; | ||
} | ||
|
||
int | ||
yyerror(const char *msg) | ||
{ | ||
printf("Parse error: %s\n", msg); | ||
exit(1); | ||
} |
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,29 @@ | ||
project('memdbg', 'c', 'cpp') | ||
|
||
flex = find_program('flex', required: false) | ||
bison = find_program('bison', required: false) | ||
|
||
if not flex.found() | ||
error('flex not found.') | ||
endif | ||
|
||
if not bison.found() | ||
error('bison not found.') | ||
endif | ||
|
||
lgen = generator(flex, | ||
output : '@PLAINNAME@.yy.cc', | ||
arguments : ['-o', '@OUTPUT@', '@INPUT@']) | ||
|
||
lfiles = lgen.process('lexer.l') | ||
|
||
pgen = generator(bison, | ||
output : ['@BASENAME@.tab.cc', '@BASENAME@.tab.h'], | ||
arguments : ['@INPUT@', '--defines=@OUTPUT1@', '--output=@OUTPUT0@']) | ||
|
||
pfiles = pgen.process('parser.y') | ||
|
||
e = executable('pgen', 'main.cc', | ||
lfiles, | ||
pfiles) | ||
|
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,90 @@ | ||
|
||
%code requires { | ||
#include <list> | ||
#include <string> | ||
#include <vector> | ||
} | ||
|
||
%{ | ||
#include <iostream> | ||
#include <cassert> | ||
#include <cstdlib> | ||
#include <cstring> | ||
#include <string> | ||
|
||
#include "result.hh" | ||
|
||
extern int yylex(void); | ||
extern int yyerror(const char*); | ||
%} | ||
|
||
|
||
%union { | ||
const char *str; | ||
std::vector<std::string> *strlist; | ||
int i; | ||
} | ||
|
||
%debug | ||
|
||
%token ALLOC FREE | ||
%token <str> HEX STR | ||
%token <i> INT | ||
|
||
%type <str> string hex | ||
|
||
%type <strlist> hex_list opt_hex_list | ||
|
||
%% | ||
input: | ||
note_list ; | ||
|
||
note_list: | ||
note | ||
| note_list note | ||
; | ||
|
||
string: STR | ||
{ | ||
$$ = strdup($1); | ||
} | ||
|
||
hex: HEX | ||
{ | ||
$$ = strdup($1); | ||
} | ||
|
||
|
||
hex_list: | ||
hex { | ||
auto list = new std::vector<std::string>; | ||
list->push_back($1); | ||
$$ = list; | ||
} | ||
| hex_list hex { | ||
$$ = $1; | ||
$$->push_back($2); | ||
} | ||
; | ||
|
||
opt_hex_list: | ||
hex_list { $$ = $1; } | ||
| %empty { $$ = NULL; } | ||
; | ||
|
||
note: | ||
ALLOC INT string hex opt_hex_list { | ||
if(allocs.find($4) != allocs.end()) { | ||
std::cout << "Allocation of an already-allocated address!\n"; | ||
abort(); | ||
} | ||
allocs[$4] = Allocation { $2, $3, $5 }; | ||
} | ||
| FREE string hex { | ||
auto it = allocs.find($3); | ||
if (it != allocs.end()) | ||
allocs.erase(it); | ||
else | ||
std::cout << "Didn't find " << $3 << "\n"; | ||
} | ||
; |
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,16 @@ | ||
#ifndef KRX_MEMDBG_RESULT_HH | ||
#define KRX_MEMDBG_RESULT_HH | ||
|
||
#include <string> | ||
#include <map> | ||
#include <vector> | ||
|
||
struct Allocation { | ||
int pid; | ||
std::string zone; | ||
std::vector<std::string> *addresses; | ||
}; | ||
|
||
extern std::map<std::string, Allocation> allocs; | ||
|
||
#endif /* KRX_MEMDBG_RESULT_HH */ |