Author Topic: Linux Debugger!??  (Read 28931 times)

Offline tarek89

  • Jr. Member
  • *
  • Posts: 20
Linux Debugger!??
« on: April 26, 2011, 04:25:26 PM »
i need a debugging tool for linux 64 bit OS, i am writing 32 bit intel 8086 linux assembly
i tried gdb but nasm -g function didnt output the right core file to be used in gdb

So any debugging tool i can use??

thanks in advance

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Linux Debugger!??
« Reply #1 on: April 26, 2011, 06:38:15 PM »
Well... I consider gdb somewhat "unfriendly", but I think the "right" thing to do is wrestle with it and learn to use it. (I'm workin' on that... slowly) A configuration file (.gdbinit) may help. I'll see what I can find... the late Chuck Crayne posted one that works for both 32 and 64-bit, which is probably what you want. I'm "sure" I downloaded that, but can't find it at the moment.

Nasm's "-g" switch emits "stabs" format debug info. "-F dwarf" emits "dwarf" format debug info, which is what gdb uses natively. To be honest, I've never been able to notice any difference, but it was one of Chuck's last contributions to Nasm, so use it! Also, a "nop" right after the "_start:" label helps...

If what you're after is a "core dump", they are disabled by default in Linux(!). Enable with "ulimit -c (size)". I don't know how to use a "core dump". Any hints, anybody?

Since I don't "like" gdb too much, what I sometimes use is a fork of Patrick Alken's "ALD" (Assembly Language Debugger), written by Terry Loveall. The interface is similar to dos' DEBUG. Since his "coughing up a furball" page seems to have disappeared...

http://home.myfairpoint.net/fbkotler/debug-0.0.21.tgz

ALD itself is on SourceForge:

http://ald.sourceforge.net/

Jeff Owens has a debugger as part of his package of "linuxasmtools", too. I'll see if I can find a good home for that, too. Hmmm, I've got one called "EDB, too - no recollection of what that is... One of these days, I've gotta get organized!!!

See if "-F dwarf" and/or "ulimit -c" will help you... we'll talk more...

Best,
Frank

(this isn't the "good" gdbinit... copy it to ~/.gdbinit to use)


Offline tarek89

  • Jr. Member
  • *
  • Posts: 20
Re: Linux Debugger!??
« Reply #2 on: April 26, 2011, 06:58:15 PM »
Thanks for your friendly reply =)

while waiting for i searched the web and found DDD uses GDB but with a little gui interfaces and i used the -F dwarf function and it works hell great

but lemme ask a silly question, what does nop directive do??


again and again i would like to thank you for helping us in here

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Linux Debugger!??
« Reply #3 on: April 26, 2011, 07:10:20 PM »
You're welcome! Folks helped me when I was getting started (still do!), so I try to "pass it on".

nop = no operation. It's opcode 90h which is literally "xchg eax, eax".

Best,
Frank


Offline tarek89

  • Jr. Member
  • *
  • Posts: 20
Re: Linux Debugger!??
« Reply #4 on: April 26, 2011, 07:15:54 PM »
am starting then and i will need more help sooner or later =D

thank you !

Offline Bryant Keller

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 360
  • Country: us
    • About Bryant Keller
Re: Linux Debugger!??
« Reply #5 on: April 27, 2011, 04:09:32 AM »
Hmmm, I've got one called "EDB, too - no recollection of what that is... One of these days, I've gotta get organized!!!

I didn't much like CodeF00's EDB. It had a GREAT user interface, looked almost like my favorite windows debugger (ollyDBG), but I remember it used to crash a lot while I was working with it. I'm not explicitly saying that it'll crash for anyone else, in fact *almost* everything I use crashes at some point in time (usually due to me sticking my nose where it doesn't belong, lol). Also it might be a little bit better now, i see it's available in the Fedora stable repo's so that might be something to check into.

I am, however, a huge GDB fan. I use GDB for debugging on Windows, Linux, BSD, and even for MCUs using GDB-Server. GDB's ability to work on so many environments means i don't have to relearn commands for whatever processor I'm using. In fact, if you change the syntax to intel in your .gdbinit file, it's probably my favorite all around debugger. Although to be honest, I don't really use the GDB disassembler feature as much as you'd think, I tend to use objdump for looking over the source and use GDB to trace execution and monitor register/memory changes during execution.


I guess if you're just starting out, I would say give EDB a try. It's really "pretty" and windowsish for the novice. Then later on I would suggest moving over to something like Insight (or if you need something a little more universal, try DDD). And once you start getting away from the graphical environments, you can move onto GDB. :)

EDB - http://www.codef00.com/projects
Insight - http://sourceware.org/insight
GNU DDD - http://www.gnu.org/software/ddd

About Bryant Keller
bkeller@about.me

Offline brethren

  • Jr. Member
  • *
  • Posts: 28
Re: Linux Debugger!??
« Reply #6 on: April 27, 2011, 09:12:14 PM »
Quote
but lemme ask a silly question, what does nop directive do??

breakpoints don't seem to work properly when debugging asm using gdb. putting a nop as the first instruction seems to fix this issue.

i've had this problem debugging 32bit apps using gdb, the solution came from jeff duntemanns asm book
« Last Edit: April 27, 2011, 09:13:55 PM by brethren »

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: Linux Debugger!??
« Reply #7 on: May 09, 2011, 09:48:03 PM »
Ah, yes - that's the answer he was looking for! Thanks, Brethren!

FWIW, I put Jeff Owens' "linuxasmtools" on my website:

http://home.myfairpoint.net/fbkotler/asmtools-0.9.69.tar.gz

This includes two debuggers - AsmBug and MiniBug. I think AsmBug requires an xterm, MiniBug will run in a console (don't really remember). I think the best thing is "learn gdb", but these are alternatives. The real "gem" in this package (IMO) is the help file for sys_calls - links to example code for each one, even! There's an IDE, libraries, and miscellaneous tools and examples. All written in Nasm. I can't blame Jeff for getting discouraged and abandoning it. I don't think many people were using it - not even me! Tremendous resource, though - if nothing else, it's a ton of example code! :)

I hope someone will find this useful - shame to let it go to waste!

Best,
Frank


Offline tarek89

  • Jr. Member
  • *
  • Posts: 20
Re: Linux Debugger!??
« Reply #8 on: May 21, 2011, 08:44:30 AM »
Thank you all for your great help i tried DDD and looks cool for me despite i cant view my memory reserved data but still it solves alot

Thank you all =)

Offline JoeCoder

  • Jr. Member
  • *
  • Posts: 72
  • Country: by
Re: Linux Debugger!??
« Reply #9 on: July 04, 2011, 08:05:59 AM »
I have been using insight and ddd which are both gui front ends to gdb. I am having a lot of problems and that says something about these two pieces of "code" since I am just starting out with x86 and shouldn't be able to do anything bad. But I found code that runs differently whether using insight or without a debugger. In insight I get SIGILL or segfault and without it the code runs. I realize that is no proof of anything, but still if it's a real segfault or sigill it should be recognized without the debugger, but it's not.

I can't get gdb to do what I want which at this point is mostly just to deref pointers and display the data. I don't know if gdb is broken or just the front ends but this is pretty discouraging. Is the situation on Windows any better? Do they have a gui debugger that just works?

I guess I have to go and find some gdb tutorials and figure some stuff out because I cannot find problems in my tiny pieces of code without tripping over some front end bug. ddd seems more stable but I can't get it to deref pointers for displaying memory. Anybody know how? thanks.
If you can't code it in assembly, it can't be coded!

Offline JoeCoder

  • Jr. Member
  • *
  • Posts: 72
  • Country: by
Re: Linux Debugger!??
« Reply #10 on: July 04, 2011, 01:27:09 PM »
As a follow up to my prior post, the failure in the insight front-end to gdb was caused by some leftover incorrect settings in .gdbtkinit. I was wondering how all the breakpoints get saved even though you do a new build (not a good idea IMHO) and I found it keeps everything for all the sessions you've ever had in this file. I was getting segfaults and sigill's all over the place for no apparent reason. When I deleted the session data (do a find on "session") in .gdbtkinit I got a clean session and everything worked as it should. I think this pile of code needs some work but anyway there is a solution if you have weird stuff going on when you use insight that you can't blame on anything else...try deleting your session data and starting again. Also I found in a web search a lot of problems in the current release of insight and people recommend pulling a copy from cvs. I did that and it works alot better than the release version but still has problems like the one I mentioned. insight is more friendly when it comes to displaying data than ddd though, at least for me at this point and it helps to use it if you go through Duntemann's books because that's what he uses for his examples. I will be going through the ddd manual when I have more time because it seems to be a nice front end and a little more stable than insight.
« Last Edit: July 04, 2011, 01:49:44 PM by JoeCoder »
If you can't code it in assembly, it can't be coded!