Skip to content

Commit

Permalink
Replace tfg with flameshow
Browse files Browse the repository at this point in the history
Fixes: azat#5
  • Loading branch information
azat committed Nov 22, 2023
1 parent 0efdfa0 commit 6dc4d43
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# pyinstaller
/build
/dist
tfg.spec
*.spec
# packages
*.deb
*.tar.*
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "contrib/tfg"]
path = contrib/tfg
url = https://github.com/4rtzel/tfg
[submodule "contrib/flameshow"]
path = contrib/flameshow
url = https://github.com/laixintao/flameshow.git
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,26 @@ ifneq ($(target),)
cargo_build_opts += --target $(target)
endif

.PHONY: build tfg chdig install deb rpm archlinux packages
.PHONY: build flameshow chdig install deb rpm archlinux packages

chdig:
cargo build $(cargo_build_opts)

tfg:
pyinstaller contrib/tfg/tfg.py --onefile
ln -r -f -s dist/tfg dist/chdig-tfg
.ONESHELL:
flameshow:
poetry -C $(PWD)/contrib/flameshow install --no-root --all-extras
source $(shell poetry -C $(PWD)/contrib/flameshow env info --path)/bin/activate && pyinstaller --noconfirm --onefile contrib/flameshow/flameshow/main.py
# main is the flameshow
ln -r -f -s dist/main dist/chdig-flameshow

build: chdig tfg link
build: chdig flameshow link

build_completion:
cargo run -- --completion bash > dist/chdig.bash-completion

install:
install -m755 -D -t $(DESTDIR)/bin target/$(target)/$(target_type)/chdig
install -m755 -D -t $(DESTDIR)/bin dist/chdig-tfg
install -m755 -D -t $(DESTDIR)/bin dist/chdig-flameshow
install -m644 -D -t $(DESTDIR)/share/bash-completion/completions dist/chdig.bash-completion

link:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ make packages

### Third party libraries

- [tfg](https://github.com/4rtzel/tfg)
- [flameshow](https://github.com/laixintao/flameshow)

### Notes

Expand Down
4 changes: 2 additions & 2 deletions chdig-nfpm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ description: |
contents:
- src: target/chdig
dst: /usr/bin/chdig
- src: dist/tfg
dst: /usr/bin/chdig-tfg
- src: dist/flameshow
dst: /usr/bin/chdig-flameshow
- src: dist/chdig.bash-completion
dst: /usr/share/bash-completion/completions/chdig
- src: README.md
Expand Down
1 change: 1 addition & 0 deletions contrib/flameshow
Submodule flameshow added at ccffe0
1 change: 0 additions & 1 deletion contrib/tfg
Submodule tfg deleted from 88793e
10 changes: 5 additions & 5 deletions src/interpreter/flamegraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,30 @@ pub fn show(block: Columns) -> Result<()> {
tmp_file.write_all(data.as_bytes())?;

// TODO: replace with builtin implementation (flamegraphs rendering in Rust)
let mut child = Command::new("chdig-tfg")
let mut child = Command::new("chdig-flameshow")
.env("TERMINFO", "/lib/terminfo")
.arg("-t")
.arg("pyspy")
.arg(tmp_file.path().to_str().unwrap())
.spawn()
.or_else(|e| {
Err(Error::msg(format!(
"Cannot find/execute chdig-tfg. Check that chdig-tfg is in PATH ({})",
"Cannot find/execute chdig-flameshow. Check that chdig-flameshow is in PATH ({})",
e
)))
})?;

let result = child.wait()?;
// NOTE: tfg does not handle resize correctly and when the screen becomes smaller it fails
// NOTE: flameshow does not handle resize correctly and when the screen becomes smaller it fails
// with _curses.error in addwstr(), and even ignoring this is not enough, since there will
// be no correct re-draw anyway.
// And this means that it will not have status WIFSIGNALED, since on SIGWINCH it will
// eventually exit(1).
//
// So what we can do for tfg right now is to re-exec it after SIGWINCH.
// So what we can do for flameshow right now is to re-exec it after SIGWINCH.
if !result.success() {
return Err(Error::msg(format!(
"Error while executing chdig-tfg: {:?} (Note, tfg cannot handle screen changes correctly, have you resizing your terminal?)",
"Error while executing chdig-flameshow: {:?} (Note, flameshow cannot handle screen changes correctly, have you resizing your terminal?)",
result
)));
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn fuzzy_actions(actions: Vec<ActionDescription>) -> Option<String> {
let out = Skim::run_with(&options, Some(rx));
// FIXME:
// - skim breaks resizing
// - skim + tfg hung
// - skim + flameshow hung

if out.is_none() {
return None;
Expand Down

0 comments on commit 6dc4d43

Please sign in to comment.