public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* How to use compile & execute function in GDB
@ 2015-04-15  5:45 高国胜
  2015-04-15 15:48 ` Jan Kratochvil
  0 siblings, 1 reply; 3+ messages in thread
From: 高国胜 @ 2015-04-15  5:45 UTC (permalink / raw)
  To: gdb

I have install gcc-5.0, and copy libcc1.so to current work space.
When I try the compile & execute function in gdb, The following error occurred:

(gdb) b main
Breakpoint 1 at 0x80483dd: file test.c, line 5.
(gdb) r
Starting program: /home/guosheng_gao/gdb-7.9/obj/test

Breakpoint 1, main () at test.c:5
5         a = 1;
(gdb) compile code int z=5;c=z;
cc1: error: unrecognized command line option "-std=gnu11"
cc1: error: unrecognized command line option "-fplugin=libcc1plugin"
cc1: error: unrecognized command line option "-fplugin-arg-libcc1plugin-fd=6"
Compilation failed.
(gdb)

Any advices will be wonderful!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to use compile & execute function in GDB
  2015-04-15  5:45 How to use compile & execute function in GDB 高国胜
@ 2015-04-15 15:48 ` Jan Kratochvil
       [not found]   ` <0CEE46EB9C50E44486A861D738D3E20645F9C2E0@rsex2.realsil.com.cn>
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2015-04-15 15:48 UTC (permalink / raw)
  To: 高国胜; +Cc: gdb, Phil Muldoon

On Wed, 15 Apr 2015 07:45:19 +0200, 高国胜 wrote:
> I have install gcc-5.0, and copy libcc1.so to current work space.

GDB apparently found libcc1.so but the gcc commmand GDB found is not gcc-5.0,
otherwise it would not complain for '-std=gnu11' etc.

GDB does not search for 'cc' or 'gcc', it uses more complicated pattern:
	https://sourceware.org/gdb/current/onlinedocs/gdb/Compiling-and-Injecting-Code.html#Compiling-and-Injecting-Code
	17.7.3 Compiler search for the compile command
For example on my system it found (not easy to find out, used 'strace -f -p'
for running GDB during the 'compile code' command):
	/usr/lib64/ccache/x86_64-redhat-linux-gcc

I will add there some debug output + filename-enforcing commands.


Thanks for testing compile,
Jan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: 答复: How to use compile & execute function in GDB
       [not found]   ` <0CEE46EB9C50E44486A861D738D3E20645F9C2E0@rsex2.realsil.com.cn>
@ 2015-04-16 11:34     ` Jan Kratochvil
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2015-04-16 11:34 UTC (permalink / raw)
  To: 高国胜; +Cc: gdb, Phil Muldoon

On Thu, 16 Apr 2015 05:35:04 +0200, 高国胜 wrote:
> Ok,it works now. 

Great.


> Can the compile & execute function be used for cross debugging in embed
> system?

You do not say the target triple.  It requires gdbarch_infcall_mmap() which is
currently implemented only by linux-tdep.c, by looking up the "mmap64" symbol.
If you do not have it you should get
	This target does not support inferior memory allocation by mmap.
or
	evaluation of this expression requires the program to have a function "mmap64".

Either your target uses linux-tdep.c and it is enough to provide suitable
"mmap64" function in your target inferior or you need to implement appropriate
gdbarch_infcall_mmap() in your tdep GDB file.


Jan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-16 11:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-15  5:45 How to use compile & execute function in GDB 高国胜
2015-04-15 15:48 ` Jan Kratochvil
     [not found]   ` <0CEE46EB9C50E44486A861D738D3E20645F9C2E0@rsex2.realsil.com.cn>
2015-04-16 11:34     ` 答复: " Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).