Recent

Author Topic: passing parameters to gdb  (Read 20478 times)

scribly

  • Jr. Member
  • **
  • Posts: 81
passing parameters to gdb
« on: February 26, 2010, 08:22:11 am »
I'm trying to pass the command line parameter
Code: [Select]
--eval-command="set disassembly-flavor intel"
to gdb so the assembler output is in a syntax I am more used to

running it from the command prompt works fine, and just doing "set disassembly-flavor intel" in the gdb session works as well. But I can't seem to manage to get lazarus to pass it on to gdb. Is there a specific format that debugger_startup_options needs to have ?

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2645
Re: passing parameters to gdb
« Reply #1 on: February 26, 2010, 11:31:39 am »
how do you pass it to gdb in lazarus ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

scribly

  • Jr. Member
  • **
  • Posts: 81
Re: passing parameters to gdb
« Reply #2 on: February 26, 2010, 02:25:28 pm »
in environment->options->debugger I tried setting debugger_startup_options to:
Code: [Select]
set disassembly-flavor intel

Code: [Select]
disassembly-flavor intel

and
Code: [Select]
--eval-command="set disassembly-flavor intel"
none have worked

I also have tried changing the executable path from the normal gdb.exe to "gdb.exe --eval-command="set disassembly-flavor intel"" but then it fails saying it's not a valid file

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2645
Re: passing parameters to gdb
« Reply #3 on: February 27, 2010, 05:13:09 pm »
Code: [Select]
--eval-command="set disassembly-flavor intel"

allmost there, its
Code: [Select]
-eval-command="set disassembly-flavor intel"
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

scribly

  • Jr. Member
  • **
  • Posts: 81
Re: passing parameters to gdb
« Reply #4 on: February 27, 2010, 08:59:10 pm »
Thanks, in the end it looks like '--eval-command="set disassembly-flavor intel"' was correct after all, but because gdb doesn't get restarted between debug sessions, the change in parameter didn't get passed on

I did find that these settings aren't saved, so for now I've just hardcoded this parameter into gdbmidebugger.pp
« Last Edit: February 27, 2010, 09:42:24 pm by scribly »

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2645
Re: passing parameters to gdb
« Reply #5 on: February 28, 2010, 12:43:32 pm »
no, it was not correct, look at the difference between -- and -

--eval-command (wrong)

vs.

-eval-command (correct)
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

scribly

  • Jr. Member
  • **
  • Posts: 81
Re: passing parameters to gdb
« Reply #6 on: February 28, 2010, 01:03:29 pm »
Both methods seem to work properly.
gdb help output:
Code: [Select]
 --eval-command=COMMAND, -ex
                     Execute a single GDB command.
                     May be used multiple times and in conjunction
                     with --command.
« Last Edit: February 28, 2010, 01:05:17 pm by scribly »

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2645
Re: passing parameters to gdb
« Reply #7 on: February 28, 2010, 03:11:02 pm »
On my gdb (6.8 ) the one with -- resulted in an error and was not in the docs (gdb.pdf).

Storing the extra commandline is indeed a todo. I've been thinking to add a switchable asm syntax, but I haven't found a nice way yet (i like intel asm too). A quick soulutions would be debugger options, but those are only used when the debugger is started.
« Last Edit: February 28, 2010, 03:13:23 pm by Marc »
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Ahi

  • New Member
  • *
  • Posts: 10
Re: passing parameters to gdb
« Reply #8 on: March 11, 2010, 09:27:06 am »
Both methods seem to work properly.
gdb help output:
Code: [Select]
 --eval-command=COMMAND, -ex
                     Execute a single GDB command.
                     May be used multiple times and in conjunction
                     with --command.


Have you found out a way to actually make lazarus to use the intel syntax for a disassembly ?

I tried entering:

-eval-command="set disassembly-flavor intel"

into the environment->options->debugger -> debugger_startup_options

but:

1) they do not take effect immediately

2) they are not being saved to disk, so if you close and restart lazarus, this setting is lost

so the only way seems to be:

restart lazarus -> set this option BEFORE using the debugger.

But even this attempt did not work.

Instead I got this error message:

Debugger

Initialization output:

"Undefined command: \"\".  Try \"help\".\n"

[OK]


or do you need to modify the source and recompile lazarus to make this change apply ?

btw: could there be another way ?

Is it somehow possible to make gdb always execute some textfile's content as command immediately when gdb is started ?

That way, if it's possible, it could be done outside of lazarus but it would still apply.

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2645
Re: passing parameters to gdb
« Reply #9 on: March 11, 2010, 09:45:49 am »
Yes, I get that error too if i use --eval...  use -eval...
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

Ahi

  • New Member
  • *
  • Posts: 10
Re: passing parameters to gdb
« Reply #10 on: March 11, 2010, 10:01:53 am »
Yes, I get that error too if i use --eval...  use -eval...

Code: [Select]
-eval-command="set disassembly-flavor intel"
is exactly the line I did put into that environment->options->debugger -> debugger_startup_options

so this problem remains unsolved ...

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2645
Re: passing parameters to gdb
« Reply #11 on: March 11, 2010, 01:21:11 pm »
it sure worked for me. Can you try with single quotes instead of double ? I cannot remember what I used
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

scribly

  • Jr. Member
  • **
  • Posts: 81
Re: passing parameters to gdb
« Reply #12 on: March 14, 2010, 06:26:49 pm »
It might be worth mentioning that I use gdb version 7.0.50

as for the problem of not working immediately, open the taskmanager and close gdb, or even better just hardcode it into gdbmidebugger.pp (don't forget to rebuild)

Also, look at the registers to see if it's intel assembly, because some of the opcode names are still written in a weird way. e.g "movabs" , which should just be a "mov", but the registers will be using normal intel syntax

Quote
"Undefined command: \"\".
and could of course be a matter of passing the wrong parameter (e.g placing -eval-command between quotes while you really shouldn't)

Quote
Is it somehow possible to make gdb always execute some textfile's content as command immediately when gdb is started ?
Yes,
gd command parameter:
Code: [Select]
"--command=FILE, -x Execute GDB commands from FILE.But obviously, this brings us back to the parameter passing problem

edit:
I just experimented a bit with it on the command prompt:
Code: [Select]
gdb --eval-command='set disassembly-flavor intel'gives: Undefined command: "".  Try "help".

but
Code: [Select]
gdb --eval-command="set disassembly-flavor intel"works fine
« Last Edit: March 14, 2010, 06:39:54 pm by scribly »

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2645
Re: passing parameters to gdb
« Reply #13 on: March 15, 2010, 09:03:56 am »
edit:
I just experimented a bit with it on the command prompt:
Code: [Select]
gdb --eval-command='set disassembly-flavor intel'gives: Undefined command: "".  Try "help".

but
Code: [Select]
gdb --eval-command="set disassembly-flavor intel"works fine

This is how your shell the ' interprets, this doesn't have to be the same as TProcess interprets them.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

 

TinyPortal © 2005-2018