Skip to content

First approach to show source files #41

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mfont-bz17
Copy link

I did a first approach to show source files in a window, we talked some time ago about this but we didn't continue... maybe now we can retake it

@mfont-bz17 mfont-bz17 marked this pull request as draft July 11, 2024 17:09
@j6t
Copy link
Owner

j6t commented Jul 13, 2024

Thank you for your contribution. I still have your previous round in my repository.

What is the goal of having a list of source files? To offer a list of files to open instead of having to search them in the file system?

Here is a list of things you should consider to change:

  • Do not use new for objects that are deleted in the same scope.
  • Please follow the naming conventions: pathList instead of path_list.
  • Use range-for whenever possible.
  • Consider using QString::fromUtf8 instead of fromLatin1, because non-western coders do use their own script to name files; let's assume they store them with UTF8-encoded names. What do you think? Or does GDB have a preference?
  • You don't need to put my name in the copyright line, should you prefer your name.
  • Indentation in the codebase is unusual (4 notches per level, but still use tabs for every 8 spaces). Please stick to it nevertheless.

@mfont-bz17
Copy link
Author

What is the goal of having a list of source files? To offer a list of files to open instead of having to search them in the file system?

Yes, and it was in the TODO list in the website

imatge

* Consider using `QString::fromUtf8` instead of `fromLatin1`, because non-western coders do use their own script to name files; let's assume they store them with UTF8-encoded names. What do you think? Or does GDB have a preference?

I did some test in my computer (GNU/Linux) and are stored in UTF-8 in the ELF file. I think that in Unix systems is the standard, so then we can assume that are stored in UTF-8.

* Indentation in the codebase is unusual (4 notches per level, but still use tabs for every 8 spaces). Please stick to it nevertheless.

Do you have some .clangformat file to apply directly?

@j6t
Copy link
Owner

j6t commented Jul 17, 2024

Do you have some .clangformat file to apply directly?

No, but it should amount to

TabWidth: 8
IndentWidth: 4
UseTab: Always
# or: UseTab: ForIndentation

Let me know if this works and if so which editor you are using.

Would it be possible to split the commits somehow so that there is not one single commit that adds everything. For example:

  1. Collect names from the executable into an internal data structure (BTW, why is it a single string, shouldn't it be a list of strings?)
  2. Add the user interface.
  3. Add filtering of system paths.

Please do not pile "oops, I made an error"-commits on top of other commits; rewrite the original commit instead, so that it looks as if you made it perfect on the first try.

@mfont-bz17
Copy link
Author

mfont-bz17 commented Jul 17, 2024

Let me know if this works and if so which editor you are using.

I use Vim editor. I did some tests to get the best .clang-format based on the current files and for now I got this.

 TabWidth: 8
 IndentWidth: 4
 UseTab: ForIndentation
 AlignTrailingComments: true
 PointerAlignment: Left
 BreakBeforeBraces: Custom
 BraceWrapping:
   AfterControlStatement: Always
   AfterStruct: true
   AfterFunction: true

To check and decide.

AfterControlStatement
In some place of the code we have a new line in brace wrapping control statement but in other not.
For example gdbdriver.cpp:110

         if (pos >= 0) {
             int major = re.cap(1).toInt();
             int minor = re.cap(2).toInt();
             if (major > 7 || (major == 7 && minor >= 1))
             {
                 disass = "disassemble %s, %s\n";
             }
         }

https://clang.llvm.org/docs/ClangFormatStyleOptions.html#bracewrapping

AlignTrailingComments
In newer versions there are more options to tune.
https://clang.llvm.org/docs/ClangFormatStyleOptions.html#aligntrailingcomments

Check it and if it's okay push the .clang-format.

Would it be possible to split the commits somehow so that there is not one single commit that adds everything. For example:

1. Collect names from the executable into an internal data structure (BTW, why is it a single string, shouldn't it be a list of strings?)

If you prefer we can do the split in gdbdriver.cpp Gdb Driver::parseInfoSources to transform it to a list instead of doing in srcfileswindow.cpp.

2. Add the user interface.

3. Add filtering of system paths.

I'll try to do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants