How to search for a buffer for a numerical range that contains a given value

I have a buffer that contains some lldb output, which contains many address ranges, such as [0x00007fff60489000-0x00007fff604c0000).

Given an address (in hexadecimal), how do I look for a range that contains this address? I assume that this will require some kind of custom elisp code.

+4
source share
1 answer

You can use calcfor this. The syntax for hexadecimals is slightly different, and I will not show how to convert them, but the core of your functionality can be written as follows.

(require 'calc)

(defun is-between (n low high)
  (and (equal "1" (calc-eval (concat n " - " low " > 0")))
       (equal "1" (calc-eval (concat high " - " n " > 0")))))

(is-between "16#f0" "16#f" "16#ff")
0
source

Source: https://habr.com/ru/post/1625900/


All Articles