Skip to content

Filter for functions marked as unknown - Issue #5 #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions plugins/xrefer/core/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,18 @@ def _group_interesting_artifacts(self, interesting_indices: Set[int]) -> Tuple[D

return func_artifacts, orphan_func_artifacts, orphan_artifacts

def _is_function_excluded(self, func_name: str) -> bool:
"""
Check if a function name should be excluded from analysis.

Args:
func_name (str): Name of the function to check (e.g., "sub_401000", "unknown_lib").

Returns:
bool: True if the function should be excluded, False otherwise.
"""
return func_name.startswith('unknown_')

def populate_entity_xrefs(self, entity_idx: int) -> None:
"""Quickly populate xrefs for a specific entity."""
entity = self.entities[entity_idx]
Expand Down Expand Up @@ -2493,6 +2505,19 @@ def run_full_analysis(self) -> None:
for ref in self.mapped_refs:
orig_name = idc.get_func_name(ref[0])
func_ea = idc.get_name_ea(0, orig_name)

# If the user has requested to skip library functions
if self.settings["exclude_non_language_libs"]:
func_flags = idc.get_func_flags(func_ea)

# Check if the function is a library function, then skip it
if (func_flags & idc.FUNC_LIB) == 0:
continue

# Check if the function is excluded based on custom criteria
if self._is_function_excluded(orig_name):
continue

self.leaf_funcs.add(func_ea)

entity_index = ref[1]
Expand Down
10 changes: 9 additions & 1 deletion plugins/xrefer/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def get_default_settings(self) -> Dict[str, Any]:
"llm_model": "gemini-1.5-pro",
"api_key": "",
"enable_exclusions": True,
"exclude_non_language_libs": False,
"display_options": {
"auto_size_graphs": True,
"hide_llm_disclaimer": False,
Expand Down Expand Up @@ -896,6 +897,12 @@ def setup_exclusion_tab(self, tab) -> None:
path_layout.addWidget(self.exclusion_browse_btn, 0, 3)

layout.addLayout(path_layout)

self.exclude_non_language_libs_checkbox = QCheckBox("Exclude non-language specific library functions from analysis")
self.exclude_non_language_libs_checkbox.setChecked(self.settings["exclude_non_language_libs"])
self.exclude_non_language_libs_checkbox.setToolTip("Exclude non-language specific library functions from analysis")
layout.addWidget(self.exclude_non_language_libs_checkbox)

# Lists
lists_layout = QGridLayout()
self.exclusion_lists = {}
Expand Down Expand Up @@ -997,6 +1004,7 @@ def save_settings(self) -> None:
"llm_model": self.llm_model_combo.currentText(),
"api_key": self.api_key_edit.text(),
"enable_exclusions": self.enable_exclusion_checkbox.isChecked(),
"exclude_non_language_libs" : self.exclude_non_language_libs_checkbox.isChecked(),
# Add display options
"display_options": {
"auto_size_graphs": self.auto_size_graphs.isChecked(),
Expand Down Expand Up @@ -1272,4 +1280,4 @@ def __exit__(self, exc_type, exc_val, exc_tb):
os.unlink(self.lockfile)
except OSError:
pass