Git Product home page Git Product logo

disaster's Issues

Support compile_commands.json

Disaster looks like a nice tool and the only one of its kind for emacs. However, it seems to only support Make and default compilation. If you are working with a large project that does not use Make which is increasingly common, it seems like there is no way to use it.

compile_commands.json is probably at present the closest thing to a standard way in C++ community to describe the compilation flags for a project. In addition to being used by all of the clang static analyzer tools, it can be generated automatically by both CMake and ninja, as well as from Make using Bear. Furthermore it's the format of choice for other very popular emacs C++ tools like rtags and emacs-ycmd.

Any interest in adding support?

Symbol's value as variable is void: c-mode-base-map

Warning (initialization): An error occurred while loading `/home/agauniyal/.emacs.d/init.el':

Symbol's value as variable is void: c-mode-base-map

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the `--debug-init' option to view a complete error backtrace.

Doesn't fully integrate with autotools build rules

Let's say autotools creates a makefile with this rule:

smash_unittest-lol_test.o: src/lol_test.cc
    # blah blah

Because lol_test.cc is listed in smash_unittest_SOURCES. The problem is that disaster tries to make src/lol_test.o which makes with a generic rule that excludes the per program flags from things like smash_unittest_CPPFLAGS.

This must be fixed.

Can disaster be customized?

I want to read flags from a .clang_complete file instead of running make on a Makefile. Can that be done?.

Alternatively, is there a way to define flags for disaster on a project basis?

I want to run default CC of C++ with custom flags like: -std=c++1y O3

Great Package, BTW!

Couldn’t find corresponding assembly line

Running M-x disaster keeps printing the same in all C source files (haven't tried others).

It's using the default objdump command:

objdump -d -M att -Sl --no-show-raw-insn

I tried changing mode to nasm, tried changing the objdump command a bit, but nothing.

Those gray comments that appear on the screenshots are not generated for me, only headers for functions:

image

This is the message log:

Running: make -k -C <PATH>/file.o
make: Entering directory '<PATH>'
cc    -c -o file.o file.c
make: Leaving directory '<PATH>'
Running: objdump -d -M att -Sl --no-show-raw-insn <PATH>/file.o
Couldn’t find corresponding assembly line.

Support different architecture

It would be great to add support for others architecture, such as arm for instance.
One could imagine a setting for the prefix, (and an easy way to toggle from one to another) to call the appropriate version of objdump.

Support under Mac OS

It looks like objdump is not supported or now replaced as binutils/gobjdump. How to make objdump running under Mac OS like the demo does? thx

Disaster is not currently working on all M Mac family

Hi @abougouffa I seen that you are the new maintainer.
I'm trying to run disaster on a M1 Mac and there is no way that I can compile with the current flags.
GCC doesn't support yet the native comp for M chips family, I created a simple patch for this and I would like to create a Pull Request.

Support C++11

By passing -std=c++11 to c++. I doubt this will break much, and many people are working with C++11 now.

Supported file extensions

It checks the file's extension in disaster, but the range of supported extensions is narrow.
According to the regular expression in the code, it contains .c .cpp .cc,
but also contains false-positives like .cp .ccp. I checked these cases with the latest source.
Also it would be great to include extensions .cxx .c++ because cc-mode supports these.

Mixed source/assembly on Mac OS X?

Hi there,

somehow I can't get mixed source/assembly on Mac OS X to work, at least not using gobjdump or otool. Is there a 'canonical' way to do this? If not, the following kludge more-or-less works if gdb has been compiled with Python support (v3 in this case, also using use-package to load disaster):

== .gdbinit part

python
import re
class DisassembleLine(gdb.Command):

    """Disassemble around given line specification."""

    def __init__(self):
        super(DisassembleLine, self).__init__(
            "disassemble-line", gdb.COMMAND_USER)

    def address_for_line(self, linespec):
        lineinfo = gdb.execute('info line ' + linespec, to_string=True)
        address_match = re.match('.* starts at address (.*?) ', lineinfo)
        if address_match is None:
            return None
        else:
            return address_match.group(1)

    def invoke(self, arg, from_tty):
        address = self.address_for_line(arg)
        if address is None:
            print("Error: location {0} could not be found".format(arg))
        else:
            print(gdb.execute('disassemble /m ' + address, to_string=True))

DisassembleLine()
end

== elisp part

(use-package disaster
  :config (progn
            (add-c-hook (lambda () (local-set-key (kbd "C-c C-d") 'disaster)))
            (defadvice disaster (before disaster-point-gdb-to-function)
              (setq disaster-objdump
                    (format "gdb --batch -ex \"disassemble-line %s:%s\""
                            (file-name-nondirectory buffer-file-truename)
                            (line-number-at-pos (point))))
            (ad-activate 'disaster)))

If there is a better way, please tell me; if not, maybe this workaround could find its way into the disaster repo for the convenience of my fellow Mac users?
best,
Sebastian

question wrt doom emacs installation instructions

Hi,

I tried adding disaster.el to my doom emacs.

I did the following

In a first try I added only this:

(package! disaster
  :recipe (:host github :repo "jart/disaster"))

to package.el

An ran "doom sync"

I then read the rest of the readme and added

(use-package! disaster
  :commands (disaster)
  :init
  ;; If you prefer viewing assembly code in `nasm-mode` instead of `asm-mode`
  (setq disaster-assembly-mode 'nasm-mode)

  (map! :localleader
        :map (c++-mode-map c-mode-map fortran-mode-map)
        :desc "Disaster" "d" #'disaster))

to config.el and ran "doom sync" again.

C-c d did not work afterwards, but M-x disaster showed some activity. However my cmake based project did not compile.

I then found a disaster.el installed in the doom config:

$:~/.emacs.d$ fdfind -uuu disaster.el ~/.emacs.d/
/home/frank/.emacs.d/.local/straight/build-28.2/disaster/disaster.el
/home/frank/.emacs.d/.local/straight/build-28.2/disaster/disaster.elc
/home/frank/.emacs.d/.local/straight/repos/disaster/disaster.el

Which did not have the date of today. Instead it was from a week (2023-02-07 ) ago. At this date I probably re-installed/re-compiled doom, but was not aware that disaster.el existed. I do not know why it is in my doom setup. I did not enable it knowingly before today (2023-02-12).

Anyway the problem now is that the code installed is an old release of disaster.el:

$ diff -Naur .emacs.d/.local/straight/repos/disaster/disaster.el projects/disaster/disaster.el  | head
--- .emacs.d/.local/straight/repos/disaster/disaster.el	2023-02-07 10:34:37.567169426 +0100
+++ projects/disaster/disaster.el	2023-02-12 10:58:04.009570458 +0100
@@ -1,11 +1,14 @@
-;;; disaster.el --- Disassemble C/C++ code under cursor in Emacs
+;;; disaster.el --- Disassemble C, C++ or Fortran code under cursor -*- lexical-binding: t; -*-
 
-;; Copyright (C) 2013 Justine Tunney.
+;; Copyright (C) 2013-2022 Justine Tunney.
 
 ;; Author: Justine Tunney <[email protected]>
$ git -C ~/.emacs.d/.local/straight/repos/disaster log
commit 10a785facc60d89d78e0d5177985ab1af1741bb4 (grafted, HEAD -> master)
Author: Huang Ying <[email protected]>
Date:   Tue Oct 17 05:52:38 2017 +0800

    Support separate build root directory (#18)
    
    Many build systems support to use a build root directory that is
    different from the project source code root directory.  This patch is
    to support that.

Could you please hint howto fix the situation ? Is disaster.el now a default component of doom emacs?
My doom-emacs n https://github.com/doomemacs/doomemacs is at commit e96624926d724aff98e862221422cd7124a99c19

~/.emacs.d$ rg disaster
bin/doom:68:;;   disasterous side-effects.
modules/lang/cc/packages.el:9:(package! disaster :pin "10a785facc60d89d78e0d5177985ab1af1741bb4")
modules/lang/cc/README.org:36:- [[doom-package:disaster]]
profiles/README.org:43:rollback/snapshot traversal for disaster recovery purposes.
docs/faq.org:92:- No disaster recovery ::

However the old version does not seem to work with cmake well...

integration with cmake-ide

Hello,

I'm using cmake-ide plugin to build my project.
Is there any way to configure disaster to use compilation commands from cmake-ide and ask cmake-ide to compile files?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.