I tried to set `dap-lldb-debugged-program-function` the smart way instead of the default interactive way in minibuffer
so I got https://www.reddit.com/r/emacs/comments/ecgt48/comment/fbbf84m/?utm_source=share&utm_medium=web2x&context=3
```
(setq dap-lldb-debugged-program-function
(lambda ()
(completing-read "Select file to debug: "
(directory-files-recursively (lsp-workspace-root)
".*" nil #'f-executable?))))
```
It is OK but it lists basically all the files in the `lsp-workspace-root` which contains a lot of unneeded files such as files in directories of `.git/.cache/` or some files extensions such as `.cpp`(`'f-executable?` doesn't seem to work here) or `.o` I don't need since `dap-lldb-debugged-program-function` is the function I use to find the compiled binary.
But after I read the document of [`directory-files-recursively`](https://www.gnu.org/software/emacs/manual/html_node/elisp/Contents-of-Directories.html#index-directory_002dfiles_002drecursively)
```
Function: directory-files-recursively directory regexp &optional include-directories predicate follow-symlinks ¶
Return all files under directory whose names match regexp. This function searches the specified directory and its sub-directories, recursively, for files whose basenames (i.e., without the leading directories) match the specified regexp, and returns a list of the absolute file names of the matching files (see absolute file names). The file names are returned in depth-first order, meaning that files in some sub-directory are returned before the files in its parent directory. In addition, matching files found in each subdirectory are sorted alphabetically by their basenames. By default, directories whose names match regexp are omitted from the list, but if the optional argument include-directories is non-nil, they are included.
By default, all subdirectories are descended into. If predicate is t, errors when trying to descend into a subdirectory (for instance, if it’s not readable by this user) are ignored. If it’s neither nil nor t, it should be a function that takes one parameter (the subdirectory name) and should return non-nil if the directory is to be descended into.
Symbolic links to subdirectories are not followed by default, but if follow-symlinks is non-nil, they are followed.
```
I spent so much time on the `regexp` part, and I failed to exclude some directories and some extensions I don't need.
I got another simple function `counsel-fzf`
```
(setq dap-lldb-debugged-program-function
(lambda ()
(completing-read "Select file to debug: "
(counsel-fzf))))
```
but it directly opens the binary file in Emacs instead of starting dap-debug session
So friends here, how can I solve this problem? I mean one more easy way to use `dap-lldb-debugged-program-function` to choose the binary for C/C++/Rust project to start the dap-debug session? (I spent hours searching Google and Github for keywords `dap-lldb-debugged-program-function` and `directory-files-recursively` and couldn't find the solution.)