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

Modularize gdbinit #6

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open

Modularize gdbinit #6

wants to merge 25 commits into from

Conversation

dholm
Copy link

@dholm dholm commented Oct 21, 2012

The old layout is difficult to maintain due to the size of gdbinit and the fact that it is difficult to identify various components. The file has now been broken up into multiple submodules which are loaded by the main gdbinit file. .gdb and .gdbinit has to be symbolically linked to the users home directory for this to work.

dholm and others added 7 commits October 21, 2012 15:30
The old layout is difficult to maintain due to the size of gdbinit and the fact that it is difficult to identify various components. The file has now been broken up into multiple submodules which are loaded by the main gdbinit file. .gdb and .gdbinit has to be symbolically linked to the users home directory for this to work.
Reindented code so that every module follows the same syntax.
Attempt to autodetect the target architecture and set up the global flags accordingly. This will make it unneccessary to try to figure this out manually and hardcode the values in .gdbinit.
Restructures the architecture-specific code to never assume that a
certain architecture is being used. Adds a $MIPS global that when set to
1 identifies that the debugged target is MIPS.

Also breaks out the script for detecting a target and places it as a
bash-script in the .gdb-directory to make it easier to debug.
When passing an expression containing spaces as an argument to a GDB
command it will be interpreted as multiple arguments even when enclosed
in parentheses. In order to follow the general coding style these
arguments are broken out and set in local variables that are then
passed as arguments instead.
Having the ChangeLog in the .gdbinit-file now that it has been
modularized made little sense since the user will need a .gdb-directory
anyway. Moved the ChangeLog into a file of the same name and reflowed it
so that it can be read without going bonkers.
Since hooks are general and there might be commands defined in multiple
modules that need to install something into the same hook they have been
moved to the .gdbinit-file instead.
@dholm
Copy link
Author

dholm commented Oct 22, 2012

I have added support for MIPS64 now as well.

dholm and others added 6 commits October 22, 2012 19:07
Updates the README to contain a list of contributors to gdbinit. Also
adds documentation on many of the commands that it defines.
Copy the solution used for mips to ensure that only registers that are valid
will be printed. I.e. if a register is set to "void" print zero instead of
bailing out.
The commands were a bit difficult to read, hopefully this will make the
documentation a little better.
Renames the GDB command files to separate them from the shell scripts
etc. Also, this makes it easier for the editor to figure out what
indentation, syntaxt highlighting etc to use.

Also renames the CPU-specific modules to cpu-<architecture>.gdb to make
it more obvious that they are submodules to cpu.gdb.
@gdbinit
Copy link
Owner

gdbinit commented Oct 28, 2012

Hello,
Thanks for your work, pretty cool!
I have been thinking about this and I'm not sure if it's the best solution. I really like the fact that it's a single file so it's easy to transfer between machines.
I'm thinking about using your work to improve the single file.
I will definitely merge the MIPS stuff :-)

Thanks!

@dholm
Copy link
Author

dholm commented Oct 31, 2012

I agree the single file has its benefits but I found it a bit difficult to maintain. One idea I had was to have it split up for development and then have a Makefile that would merge them into one file for release but I never got round to that.

Looking forward to your work on the script! :D

@cooljeanius
Copy link

I would also prefer to see it modularized

cooljeanius and others added 4 commits May 7, 2013 02:23
- the old `gdbinit-MacsBug-without-plugin` file that Apple ships with
their gdb
- the `kgmacros` that Apple ships with their kernel debug kit
found some more .gdb files in Apple's version of gdb
@cooljeanius
Copy link

As you can see from these last commits, I find it easier to submit pull requests to @dholm's fork instead of this one, because dholm's is modularized, and this one isn't. If this repo were modularized, too, it would be easier for people to submit other pull requests to it, too. (although if that's by design and you don't want pull requests, then feel free to ignore)

@gdbinit
Copy link
Owner

gdbinit commented May 12, 2013

I'm still not sold to the modularize idea. Need to rethink about it since gdb is phased out by Apple and lldb is the future.

@cooljeanius
Copy link

Just because Apple says that lldb is the future doesn't mean that everyone has to switch to it. It's not like the FSF version of gdb for OS X is going anywhere...

Also, I don't see how gdb being phased out in favor of lldb has anything to do with whether or not to modularize this.

@gdbinit
Copy link
Owner

gdbinit commented May 12, 2013

Well, I will make the switch as soon as I find time to evaluate and write a gdbinit equivalent to lldb.
FSF version was (is?) crap last time I tried in OS X.

Gdb being phased out is connected because I'm not sure if it's worth the time to modularize and improve some areas.

@tyilo
Copy link
Contributor

tyilo commented May 12, 2013

Isn't lldb less functional than gdb?

@gdbinit
Copy link
Owner

gdbinit commented May 13, 2013

From what I have been hearing that's not true anymore. For most stuff it was already ok last time I tested it.
I just can't work without gdbinit or something similar :-)

@dholm
Copy link
Author

dholm commented May 13, 2013

Soon after I started using gdbinit I noticed several interoperability issues when using it together with different versions of GDB. For instance the way GDB represents registers with unknown values varied among versions and many times would cause the scripts to crash when displaying data.

As an experiment I started rewriting just the context display as a GDB Python module so that I could make it more resilient to the problem with registers. This started out as a hack but pretty soon I ended up with something that was actually quite good and had a lot of nice features, the problem being that it was still a big hack. Since I realized people might find it useful I set out to refactor it into something better but then things got in the way and it took me much longer than it should have to finish the refactoring. Seeing your discussion today convinced me I should just release what I have so far and finish up the last few pieces whenever I can.

The code is all here on github, https://github.com/dholm/voidwalker

Since Apple's GDB is ancient you will have to install something newer (and sadly without their modifications). Personally I am using GDB 7.6 from homebrew-dupes. By default this version links against your system Python so either apply this patch: dholm/homebrew-dupes@4e84580 or make sure you use a version of pip associated with /usr/bin/python and not your homebrewed one when installing the requirement (FlowUI, which originally was part of (void)walker but I decided to split it into its own project).

Even though (void)walker started out as a GDB hack I redesigned it so that it would not be too tightly coupled with GDB's API for the purpose of being able to port it over to lldb one day. All the GDB specific code lives within backends/gdb and in the best of worlds those are the only parts that would need to be ported to get it to work in another debugger. The reality might not be so simple though depending on what features are exposed through the lldb Python API.

jszakmeister and others added 2 commits June 6, 2013 22:54
Unfortunately, gdb under Snow Leopard doesn't give a useful doublet.  So
let's go the extra step and grab the osabi and use it to determine what
processor we're using and the size.
Attempt to detect the correct processor type under Snow Leopard's gdb.
@cooljeanius
Copy link

Since Apple's GDB is ancient you will have to install something newer (and sadly without their modifications).

This is why I started my own version, btw: https://github.com/cooljeanius/apple-gdb-1824 (although I've broken it and could use some help fixing 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.

6 participants