• @[email protected]
      link
      fedilink
      English
      38
      edit-2
      1 year ago

      Yes. It’s a surprisingly bad debugger the more you think about it. I use it largely in assembly and it loves to spit out random errors about memory it tried to access based on the current register state. The shortcuts are kind of dumb.

      It certainly works but I wouldn’t call it a pleasure to use.

      Ex: try disp x/1i $eip often just doesn’t work.

      • TunaCowboy
        link
        fedilink
        61 year ago

        I use gdb with great success for x64, rv64, and c:

        info registers rip or just setup tui:

        # ~/.config/gdb/gdbinit:
        tui new-layout default regs 1 {-horizontal src 1 asm 1} 2 status 0 cmd 1
        tui layout default
        tui enable
        
      • @[email protected]
        link
        fedilink
        21 year ago

        I honestly vastly prefer using IDA and Windows specific tools (x64dbg) over gdb. IDA can interface with gdb so it can act as a frontend which can be handy for visualization.

  • @[email protected]
    link
    fedilink
    1391 year ago

    Except the C++ “Core dumped” line is telling you it just wrote a file out with the full state of the program at the time of the crash, you can load it up and see where it crashed and then go and look at what every local variable was at the time of the crash.

    Pretty sure you can even step backwards in time with a good debugger to find out exactly how you got to the state you’re currently in.

            • ⸻ Ban DHMO 🇦🇺 ⸻
              link
              fedilink
              English
              111 year ago

              When you apply for a home loan or a passport:

              “Unfortunately we will have to reject your application”

              “Why?”

              “We have received several reports of failed sudo attempts and segmentation faults”

      • Elsie
        link
        fedilink
        221 year ago

        I believe it’s /var/lib/apport/coredump on Ubuntu.

        • @[email protected]
          link
          fedilink
          591 year ago

          imagine if it, like, told you this so you didn’t have to find out about it via a post on lemmy

              • @[email protected]
                link
                fedilink
                51 year ago

                I love gdb! I recently had to do a debug and wow its so cool! On gentoo I can compile everything with symbols and source and can do a complete stack trace.

              • @[email protected]
                link
                fedilink
                21 year ago

                Am I the only one in this thread who uses VSCode + GDB together? The inspection panes and ability to breakpoint and hover over variables to drill down in them is just great, seems like everyone should set up their own c_cpp_properties.json && tasks.json files and give it a try.

              • @[email protected]
                link
                fedilink
                51 year ago

                …unless you build the executable with optimizations that remove the stack frame. Good luck debugging that sucker!

          • @[email protected]
            link
            fedilink
            English
            91 year ago

            Imagine if you knew the most basic foundational features of the language you were using.

            Next we’ll teach you about this neat thing called the compiler.

            • Russ
              link
              fedilink
              English
              111 year ago

              I’m not a C/C++ dev, but isn’t apport Ubuntu’s crash reporter? Why would dumps be going into there?

              Though on a rhetorical thought, I am aware of systemd’s coredumptctl so perhaps its collecting dumps the same way systemd does.

              • @[email protected]
                link
                fedilink
                English
                11
                edit-2
                1 year ago

                https://wiki.ubuntu.com/Apport

                It intentionally acts as an intercept for such things, so that core dumps can be nicely packaged up and sent to maintainers in a GUI-friendly way so maintainers can get valuable debugging information even from non-tech-savvy users. If you’re running something on the terminal, it won’t be intercepted and the core dump will be put in the working directory of the binary, but if you executed it through the GUI it will.

                Assuming, of course, you turn crash interception on- it’s off by default since it might contain sensitive info. Apport itself is always on and running to handle Ubuntu errors, but the crash interception needs enabled.

                • Russ
                  link
                  fedilink
                  English
                  71 year ago

                  Ah I see, that’s actually pretty cool - thanks!

  • voxel
    link
    fedilink
    28
    edit-2
    1 year ago
    gdb ./fuck
    r
    where
    

    you should get a complete stack trace (complete with values of some function arguments)

    • @[email protected]
      link
      fedilink
      29
      edit-2
      1 year ago

      The one thing I can say about java; the kinds of people who like Java tend to really like Java. Everyone else just leaves them to it.

      • @[email protected]
        link
        fedilink
        English
        161 year ago

        And the people hating on it somehow never used any version above 8, which is 10 years old and EOL.

        • @[email protected]
          link
          fedilink
          41 year ago

          Oh I’m firmly in the second camp. They can use whatever version they like, as long as I don’t have to go near it.

          • Tom
            link
            fedilink
            41 year ago

            Having used PHP and Java extensively in my career, it’s always entertaining to read what people think about these languages.

            • @[email protected]
              link
              fedilink
              31 year ago

              I haven’t touched PHP since college, so about a decade, but back then I compared it to a very disorganized but well equipped toolbox. Everything you need to do your projects is there, but it’s scattered through 12 different unorganized drawers and cubbies, there’s an annoying mix of metric and imperial stuff, plus some random bits and bobs you inherited from your grandfather that you have no idea what they do.

        • @[email protected]
          link
          fedilink
          51 year ago

          I’ve used Java 21 pretty extensively, and it’s still comically bad compared to various alternatives, even apples-to-apples alternatives like C#. The only reason to use Java is that you’ve already been using Java.

          • @[email protected]
            link
            fedilink
            English
            41 year ago

            it’s still comically bad compared to various alternatives, even apples-to-apples alternatives like C#.

            I’d be interested to hear why. IMO Java has the superior ecosystem, runtime(s!), and community. The best part is that you don’t even HAVE to use java to access all this - you can just use kotlin, groovy, scala,… instead.

            In terms of the language itself, while it (still) lacks some more modern language features, it has improved massively in that area as well, and they’re improving at a significant rate still. It also suffers from similar issues as PHP, where it has some old APIs that they don’t want to get rid of (yet?), but overall it’s a solid language.

    • @[email protected]
      link
      fedilink
      21
      edit-2
      1 year ago

      Java is a traditional and conservative language, which has its strong upsides, like the syntax being familiar to many people who haven’t used the language before. It’s a language that brought us the JVM, gave a job to many people and established fundamentals for other languages to inspire and improve on. If you don’t like Java, you can just use another language for the JVM, like Scala, Kotlin or Clojure.

      • @[email protected]
        link
        fedilink
        English
        81 year ago

        and inspired C#, which is pretty rad! (humble opinion… preparing for downvotes because I don’t get the feeling lemmy is where M$ devs hang out)

      • Doc Avid Mornington
        link
        fedilink
        English
        21 year ago

        You only named one upside, I can’t think of any other, and C-like syntax is pretty common, so it’s not much of an upside. It’s at least debatable whether the JVM is a good thing at all - the majority of languages get along perfectly well without it, and there’s no reason to believe the ones that do target it wouldn’t be doing just fine if it didn’t exist. It’s weird to say Java gave a job to anybody - the demand to have software written resulted in programmers being hired; if Java hadn’t been pushed on the market by Sun, it would have just been another language. Java didn’t establish any fundamentals at all, it just borrowed from other places. While all three of the other languages you mention are interesting, for sure, I’m not sure why somebody who doesn’t like Java should limit themselves to JVM languages.

  • @[email protected]
    link
    fedilink
    371 year ago

    This C++ message has an urgency vibes to it:

    “Segmentation fault!! Drop the Nuclear Reactor quick!!”

  • @[email protected]
    link
    fedilink
    English
    171 year ago

    I know this is supposed to be humorous, but there’s a reason why these languages can, and are doing what they’re doing.

    Core dumps are also worth learning about, they’re really helpful if you understand them.

  • @[email protected]
    link
    fedilink
    English
    5
    edit-2
    1 year ago

    C#: Time for a treasure hunt! Find the Null Reference Exception. Here’s a map. X marks the spot.

    • Kogasa
      link
      fedilink
      61 year ago

      C# tells you the call site/method name and line number right at the top. It’s only really annoying when you have aggregate exceptions, which sometimes occur because someone async’d wrong

      • @[email protected]
        link
        fedilink
        English
        21 year ago

        Actually getting there is the other part. It’s not like java where you can go down the chain if the problem isn’t where it says it is.

  • Subverb
    link
    fedilink
    251 year ago

    Nevermind that the C++ program is two orders of magnitude faster when completed.

    I would love to learn and use Rust but I’m a embedded systems guy. Everything of consequence is C and C++.

    • @[email protected]
      link
      fedilink
      English
      131 year ago

      This right here - C++ iirc is used mostly for microprocessor code in an industry setting, where EXTENSIVE testing is done so that bloated code doesn’t need to constantly check for programmer errors every single time, i.e. where execution speed is prioritized over programmer development time. And whenever that is not the case, well, as OP pointed out, other higher-level languages also exist (implication: to choose from).

      • @[email protected]
        link
        fedilink
        61 year ago

        I also currently use it for a new project since all needed 3rd party libraries are from a very specific domain and the project has a deadline, so writing and testing wrappers for Rust that would provide me with any meaningful advantages down the road are too costly to budget for before the deadline.

        That could become part of a future refactoring, though.

      • @[email protected]
        link
        fedilink
        351 year ago

        C++ iirc is used mostly for microprocessor code

        lol no, it’s used almost everywhere where performance is important and people want(ed) OOP, from tiny projects to web browsers (Chrome, Firefox) to game engines (Unreal, CryEngine). Many of these are hugely complex and do encounter segfaults on a somewhat frequent basis.

        Saying C++ is mostly used for embedded applications is like saying C# is mostly used for scripting games, i.e. it doesn’t nearly cover all the use cases.

        higher-level languages also exist

        This depends on your definition of “higher-level”, but many people would argue that C++ is on a similar level to Java or C# in terms of abstraction. The latter two do, however, have a garbage collector, which vastly simplifies memory management for the programmer(generally anyway).

    • Turun
      link
      fedilink
      21 year ago

      Compilation: top row, runtime: button row.

    • caseyweederman
      link
      fedilink
      81 year ago

      Rust: this garbage code is beneath me, come back when you have your shit together.

          • asudox
            link
            fedilink
            2
            edit-2
            1 year ago

            Runtime errors are rare? Interesting. I guess it depends on how much error handling the dev additionally wants to do.

          • Turun
            link
            fedilink
            51 year ago

            I have a graphical application that crashes regularly when I switch between displays with Ctrl+alt+number. Something in the winit stack does not like it.

    • @[email protected]
      link
      fedilink
      31 year ago

      If only I could show segfaul stack tracetrough looped macros.

      It breaks VSCode (it would be hilarious if I wasn’t the author of said macros).