[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/beardbolt d604adae64 015/323: Add initial functions for
From: |
ELPA Syncer |
Subject: |
[elpa] externals/beardbolt d604adae64 015/323: Add initial functions for processing binary asm |
Date: |
Thu, 9 Mar 2023 10:57:51 -0500 (EST) |
branch: externals/beardbolt
commit d604adae646b89bdaa6db9b6ab937be356303153
Author: Jay Kamat <jaygkamat@gmail.com>
Commit: Jay Kamat <jaygkamat@gmail.com>
Add initial functions for processing binary asm
---
rmsbolt.el | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 66 insertions(+), 2 deletions(-)
diff --git a/rmsbolt.el b/rmsbolt.el
index 5247984008..ad795ec146 100644
--- a/rmsbolt.el
+++ b/rmsbolt.el
@@ -45,6 +45,7 @@
(defvar rmsbolt-filter-unused-labels t)
(defvar rmsbolt-filter-comment-only t)
(defvar rmsbolt-dissasemble nil)
+(defvar rmsbolt-binary-asm-limit 5000)
;;;; Regexes
@@ -78,6 +79,24 @@
(defvar rmsbolt-comment-only (rx bol (0+ space) (or (and (or (any "#@;") "//"))
(and "/*" (0+ any) "*/"))
(0+ any) eol))
+(defvar rmsbolt-dissas-line (rx bol
+ (group "/" (1+ (not (any ":")))) ":"
+ (group (1+ num))
+ (0+ any)))
+(defvar rmsbolt-dissas-label (rx bol (group (1+ (any digit "a-f")))
+ (1+ space) "<"
+ (group (1+ (not (any ">")))) ">:" eol))
+(defvar rmsbolt-dissas-dest (rx (0+ any) (group (1+ (any digit "a-f")))
+ (1+ space) "<" (group (1+ (not (any ">"))))
">" eol))
+
+(defvar rmsbolt-dissas-opcode (rx bol (0+ space) (group (1+ (any digit "a-f")))
+ ":" (0+ space)
+ (group (1+
+ (repeat 2
+ (any digit "a-f"))
+ (opt " ")))
+ (0+ space)
+ (group (0+ any))))
;;;; Classes
@@ -118,6 +137,10 @@
nil
:type 'string
:documentation "The starter filename to use")
+ (dissas-hidden-funcs
+ nil
+ :type 'string
+ :documentation "Functions that are hidden when dissasembling.")
(compile-cmd-function
nil
:type 'function
@@ -136,6 +159,13 @@
"-masm=intel"))
" ")))
cmd))
+(defvar rmsbolt--hidden-func-c (rx bol (or (and "__" (0+ any))
+ (and "_" (or "init" "start" "fini"))
+ (and (opt "de")
"register_tm_clones")
+ "call_gmon_start"
+ "frame_dummy"
+ (and ".plt" (0+ any)))
+ eol))
(defvar rmsbolt-languages)
(setq
rmsbolt-languages
@@ -146,6 +176,7 @@
:supports-binary t
:starter-file-name "rmsbolt.c"
:compile-cmd-function #'rmsbolt--c-compile-cmd
+ :dissas-hidden-funcs rmsbolt--hidden-func-c
:starter-file
"#include <stdio.h>
@@ -178,6 +209,7 @@ int main() {
:supports-binary t
:starter-file-name "rmsbolt.cpp"
:compile-cmd-function #'rmsbolt--c-compile-cmd
+ :dissas-hidden-funcs rmsbolt--hidden-func-c
:starter-file
"#include <iostream>
@@ -299,8 +331,39 @@ int main() {
(setq completed t))))
labels-used)))
-(defun rmsbolt--process-dissasembled-lines (asm-lines)
- )
+(defun rmsbolt--user-func-p (func)
+ "Return t if FUNC is a user function."
+ (let* ((lang (rmsbolt--get-lang))
+ (regexp (rmsbolt-l-dissas-hidden-funcs lang)))
+ (if regexp
+ (not (string-match-p regexp func))
+ t)))
+
+(cl-defun rmsbolt--process-dissasembled-lines (asm-lines)
+ "Process and filter dissasembled lines."
+ (let* ((result nil)
+ (func nil)
+ (match nil))
+ (dolist (line asm-lines)
+ (cl-tagbody
+ (when (> (length result) rmsbolt-binary-asm-limit)
+ (return-from rmsbolt--process-dissasembled-lines
+ '("Aborting processing due to exceeding the binary limit.")))
+ ;; TODO process line numbers
+ (when (string-match rmsbolt-dissas-label line)
+ (setq func (match-string 2 line)))
+ (unless (and func
+ (rmsbolt--user-func-p func))
+ (go continue))
+
+ (when (string-match rmsbolt-dissas-opcode line)
+ (push (match-string 3 line) result))
+
+
+ continue))
+ (mapconcat 'identity
+ (nreverse result)
+ "\n")))
(cl-defun rmsbolt--process-asm-lines (asm-lines)
"Process and filter a set of asm lines."
@@ -316,6 +379,7 @@ int main() {
(match-string 1 line)))
(used-label (cl-find match used-labels :test #'equal)))
(cl-tagbody
+ ;; TODO process line numbers
;; End block, reset prev-label and source
(when (string-match-p rmsbolt-endblock line)
(setq prev-label nil))
- [elpa] externals/beardbolt a9e5fbfd7a 028/323: Implement line number parsing for disassembled files, (continued)
- [elpa] externals/beardbolt a9e5fbfd7a 028/323: Implement line number parsing for disassembled files, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 3b6bb5bd75 030/323: Add basic overlays to view matched lines, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 5ab75b7f56 014/323: Add stubs for dissasembly, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 0a55783f33 029/323: Add skeleton for font-lock, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 8dcd74b511 031/323: Clean up rmsbolt.c by moving starters into helper files, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt aea0966e9d 035/323: Don't add binary asm line data when viewing different files, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt c066da01c4 052/323: Fix ocaml def, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 83e29706f5 005/323: Work on porting used label finder, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 58c77d90c3 008/323: Add outshine comments, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 1545531849 006/323: Add initial implementation of filter, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt d604adae64 015/323: Add initial functions for processing binary asm,
ELPA Syncer <=
- [elpa] externals/beardbolt e0bc9fc409 013/323: Fix starters, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 93f3cad769 017/323: Use local variables instead of custom parsing, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt ce6511f715 024/323: Fix compiler warnings, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 55c26882cd 025/323: Fix crash on quit, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 6239f41d9d 033/323: Add a goto-match feature for easily traversing matches, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt e6081fae6b 032/323: Add unrefined support for ocaml, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt a638324882 039/323: Add OCaml demo, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt e0d917206e 038/323: Improve quality of default matching faces, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt a950515dfc 043/323: Fix spelling mistake, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 4213316f23 037/323: Fix recentering when not needed, ELPA Syncer, 2023/03/09