mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-05 22:38:44 +00:00
Better gdb support
This commit is contained in:
parent
e2e6d47996
commit
2dbd6808a5
4 changed files with 16 additions and 7 deletions
3
gdb/.gdbinit
Normal file
3
gdb/.gdbinit
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
define pp
|
||||
p (char*) Bstringval ((void*) $arg0)
|
||||
end
|
||||
|
|
@ -66,6 +66,7 @@ class options args =
|
|||
val paths = ref [X86.get_std_path ()]
|
||||
val mode = ref (`Default : [`Default | `Eval | `SM | `Compile ])
|
||||
val curdir = Unix.getcwd ()
|
||||
val debug = ref false
|
||||
(* Workaround until Ostap starts to memoize properly *)
|
||||
val const = ref false
|
||||
(* end of the workaround *)
|
||||
|
|
@ -87,6 +88,7 @@ class options args =
|
|||
| "-dp" -> self#set_dump dump_ast
|
||||
| "-h" -> self#set_help
|
||||
| "-v" -> self#set_version
|
||||
| "-g" -> self#set_debug
|
||||
| _ ->
|
||||
if opt.[0] = '-'
|
||||
then raise (Commandline_error (Printf.sprintf "Invalid command line specifier ('%s')" opt))
|
||||
|
|
@ -171,6 +173,10 @@ class options args =
|
|||
);
|
||||
if !version then Printf.printf "%s\n" Version.version;
|
||||
if !help then Printf.printf "%s" help_string
|
||||
method get_debug =
|
||||
if !debug then "" else "-g"
|
||||
method set_debug =
|
||||
debug := true
|
||||
end
|
||||
|
||||
let main =
|
||||
|
|
|
|||
12
src/X86.ml
12
src/X86.ml
|
|
@ -403,11 +403,11 @@ let compile cmd env imports code =
|
|||
then []
|
||||
else
|
||||
[Meta (Printf.sprintf "\t.stabs \"%s:F1\",36,0,0,%s" name f)] @
|
||||
(List.mapi (fun i a -> Meta (Printf.sprintf "\t.stabs \"%s:p1\",160,0,0,%d" a ((i*4) + match closure with [] -> 8 | _ -> 12))) args)
|
||||
(List.mapi (fun i a -> Meta (Printf.sprintf "\t.stabs \"%s:p1\",160,0,0,%d" a ((i*4) + 8))) args)
|
||||
)
|
||||
@
|
||||
[Meta "\t.cfi_startproc"] @
|
||||
(if has_closure then [Push edx; Meta "\t.cfi_adjust_cfa_offset\t8"] else []) @
|
||||
[Meta "\t.cfi_startproc"; Meta "\t.cfi_adjust_cfa_offset\t4"] @
|
||||
(if has_closure then [Push edx; Meta "\t.cfi_adjust_cfa_offset\t4"] else []) @
|
||||
(if f = cmd#topname
|
||||
then
|
||||
[Mov (M "_init", eax);
|
||||
|
|
@ -420,7 +420,7 @@ let compile cmd env imports code =
|
|||
else []
|
||||
) @
|
||||
[Push ebp;
|
||||
Meta "\t.cfi_adjust_cfa_offset\t8";
|
||||
Meta "\t.cfi_adjust_cfa_offset\t4";
|
||||
Mov (esp, ebp);
|
||||
Meta "\t.cfi_def_cfa_register\t5";
|
||||
Binop ("-", M ("$" ^ env#lsize), esp);
|
||||
|
|
@ -801,8 +801,8 @@ let build cmd prog =
|
|||
let objs = find_objects (fst @@ fst prog) cmd#get_include_paths in
|
||||
let buf = Buffer.create 255 in
|
||||
List.iter (fun o -> Buffer.add_string buf o; Buffer.add_string buf " ") objs;
|
||||
let gcc_cmdline = Printf.sprintf "gcc -m32 %s %s.s %s %s/runtime.a" cmd#get_output_option cmd#basename (Buffer.contents buf) inc in
|
||||
let gcc_cmdline = Printf.sprintf "gcc %s -m32 %s %s.s %s %s/runtime.a" cmd#get_debug cmd#get_output_option cmd#basename (Buffer.contents buf) inc in
|
||||
Sys.command gcc_cmdline
|
||||
| `Compile ->
|
||||
Sys.command (Printf.sprintf "gcc -m32 -c %s.s" cmd#basename)
|
||||
Sys.command (Printf.sprintf "gcc %s -m32 -c %s.s" cmd#get_debug cmd#basename)
|
||||
| _ -> invalid_arg "must not happen"
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
let version = "Version 1.00, 81c060d21, Fri Sep 4 23:45:57 2020 +0300"
|
||||
let version = "Version 1.00, e2e6d4799, Sun Sep 6 21:39:58 2020 +0300"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue