Skip to content
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

Implement a way to list and reconstruct symbols #65

Merged
merged 3 commits into from
Apr 14, 2024
Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## [Unreleased]

### Added

- Implement symbol reconstruction and diffing capabilities
- Add 4 new commands to `resymc`: `list-symbols`, `dump-symbol`, `dump-all-symbols` and `diff-symbol`

## [0.4.0] - 2024-03-24

### Added
Expand Down
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

192 changes: 165 additions & 27 deletions resym/src/resym_app.rs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,45 +1,40 @@
use eframe::egui::{self, ScrollArea, TextStyle};
use resym_core::frontend::{TypeIndex, TypeList};

pub struct TypeListComponent {
filtered_type_list: TypeList,
pub struct IndexListComponent<I: Copy> {
index_list: Vec<(String, I)>,
selected_row: usize,
list_ordering: TypeListOrdering,
list_ordering: IndexListOrdering,
}

pub enum TypeListOrdering {
pub enum IndexListOrdering {
/// Doesn't respect any particular order
None,
/// Orders types alphabetically
Alphabetical,
}

impl TypeListComponent {
pub fn new(ordering: TypeListOrdering) -> Self {
impl<I: Copy> IndexListComponent<I> {
pub fn new(ordering: IndexListOrdering) -> Self {
Self {
filtered_type_list: vec![],
index_list: vec![],
selected_row: usize::MAX,
list_ordering: ordering,
}
}

pub fn update_type_list(&mut self, type_list: TypeList) {
self.filtered_type_list = type_list;
pub fn update_index_list(&mut self, index_list: Vec<(String, I)>) {
self.index_list = index_list;
self.selected_row = usize::MAX;

// Reorder list if needed
if let TypeListOrdering::Alphabetical = self.list_ordering {
self.filtered_type_list
if let IndexListOrdering::Alphabetical = self.list_ordering {
self.index_list
.sort_unstable_by(|lhs, rhs| lhs.0.cmp(&rhs.0));
}
}

pub fn update<CB: FnMut(&str, TypeIndex)>(
&mut self,
ui: &mut egui::Ui,
on_type_selected: &mut CB,
) {
let num_rows = self.filtered_type_list.len();
pub fn update<CB: FnMut(&str, I)>(&mut self, ui: &mut egui::Ui, on_element_selected: &mut CB) {
let num_rows = self.index_list.len();
const TEXT_STYLE: TextStyle = TextStyle::Body;
let row_height = ui.text_style_height(&TEXT_STYLE);
ui.with_layout(
Expand All @@ -55,14 +50,14 @@ impl TypeListComponent {
.auto_shrink([false, false])
.show_rows(ui, row_height, num_rows, |ui, row_range| {
for row_index in row_range {
let (type_name, type_index) = &self.filtered_type_list[row_index];
let (type_name, type_index) = &self.index_list[row_index];

if ui
.selectable_label(self.selected_row == row_index, type_name)
.clicked()
{
self.selected_row = row_index;
on_type_selected(type_name, *type_index);
on_element_selected(type_name, *type_index);
}
}
});
Expand All @@ -71,8 +66,8 @@ impl TypeListComponent {
}
}

impl Default for TypeListComponent {
impl<I: Copy> Default for IndexListComponent<I> {
fn default() -> Self {
Self::new(TypeListOrdering::None)
Self::new(IndexListOrdering::None)
}
}
4 changes: 2 additions & 2 deletions resym/src/ui_components/mod.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
mod code_view;
mod console;
mod index_list;
mod module_tree;
#[cfg(feature = "http")]
mod open_url;
mod settings;
mod text_search;
mod type_list;

pub use code_view::*;
pub use console::*;
pub use index_list::*;
pub use module_tree::*;
#[cfg(feature = "http")]
pub use open_url::*;
pub use settings::*;
pub use text_search::*;
pub use type_list::*;
2 changes: 1 addition & 1 deletion resym/src/ui_components/module_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::cell::RefCell;

use eframe::egui::{self, ScrollArea};

use resym_core::frontend::ModuleList;
use resym_core::pdb_file::ModuleList;

use crate::{
module_tree::{ModuleInfo, ModulePath, ModuleTreeNode},
Expand Down
1 change: 1 addition & 0 deletions resym_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ regex = "1.10"
similar = "2.4"
ehttp = { version = "0.5", optional = true }
url = { version = "2.5", optional = true }
msvc-demangler = "0.10"

# Web:
[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand Down
Loading
Loading