public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Unable to trace assembler in GDB 14.2 on Solaris 11.3/sparc
@ 2024-03-16 14:50 john o goyo
       [not found] ` <8f334a7b-b0d8-4bee-b58a-d09526c6b0ab@redhat.com>
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: john o goyo @ 2024-03-16 14:50 UTC (permalink / raw)
  To: gdb

I am learning Sparc assembler (mostly through Paul's book and various 
tutorials).  I built GDB 14.2 on Solaris 11.3/sparc and can debug C code 
with no problem.

Here is my test assembler code (hello.s):

/*
  *  Calling printf via assembler.
  *
  */
         .section ".data"
hello:  .asciz "Hello, World!\n"

         .global main
         .align 4
main:
         save %sp,-96,%sp

         set  hello,%o0
         call printf
         nop

         mov  0,%i0
         ret
         restore

Compiled and linked via "gcc -g hello.s", the resulting a.out executes 
as expected.

Here is what happens in GDB:

GNU gdb (GDB) 14.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later 
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "sparcv9-sun-solaris2.11".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
     <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.out...
(No debugging symbols found in a.out)
(gdb) b main
Function "main" not defined.
Make breakpoint pending on future shared library load? (y or [n])


This is contradiction to what both Paul's book and tutorials state. They 
state that a breakpoint should be set at main.

Assistance requested, thank you.

Sincerely,
john

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

* Re: Unable to trace assembler in GDB 14.2 on Solaris 11.3/sparc
       [not found] ` <8f334a7b-b0d8-4bee-b58a-d09526c6b0ab@redhat.com>
@ 2024-03-18 15:12   ` john o goyo
  0 siblings, 0 replies; 5+ messages in thread
From: john o goyo @ 2024-03-18 15:12 UTC (permalink / raw)
  To: Andrew Haley; +Cc: gdb

Greetings, Andrew.

On 2024-03-18 05:41, Andrew Haley wrote:
> On 3/16/24 14:50, john o goyo wrote:
>> Assistance requested, thank you.
>
> Does Solaris call it _main, not main ?
>
Solaris calls it main.

=> nm a.out | grep -i main
[81]    |    134368|         0|NOTY |GLOB |0    |20     |main

The (old) tutorial I am reading uses gdb 4.16 and it can set a 
breakpoint on main.

Sincerely,
john


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

* Re: Unable to trace assembler in GDB 14.2 on Solaris 11.3/sparc [Solved]
  2024-03-16 14:50 Unable to trace assembler in GDB 14.2 on Solaris 11.3/sparc john o goyo
       [not found] ` <8f334a7b-b0d8-4bee-b58a-d09526c6b0ab@redhat.com>
@ 2024-03-20 22:33 ` john o goyo
  2024-03-21 16:29 ` Unable to trace assembler in GDB 14.2 on Solaris 11.3/sparc Tom Tromey
  2 siblings, 0 replies; 5+ messages in thread
From: john o goyo @ 2024-03-20 22:33 UTC (permalink / raw)
  To: gdb

The following works (thanks to 
https://stackoverflow.com/questions/44040235/using-gdb-to-find-exactly-where-the-error-occurs-sparc-assembly):

1. In gdb, "layout asm" runs TUI with the startup code on display.
2. Set breakpoint on _start.
3. Nexti until you reach the appropriate call, then issue stepi.
4. You are now at your code.

Some odd things here.  When TUI starts up, your code is displayed with 
no labels, despite compiling with "-g".  The startup code has labels.

For reference, here is the assembler.

/*
  *  Calling printf via assembler.
  *
  */
         .section ".data"
hello:  .asciz "Hello, World!\n"

         .global main
         .align 4
main:
         save %sp,-96,%sp

         set  hello,%o0
         call printf
         nop

         mov  0,%i0
         ret
         restore


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

* Re: Unable to trace assembler in GDB 14.2 on Solaris 11.3/sparc
  2024-03-16 14:50 Unable to trace assembler in GDB 14.2 on Solaris 11.3/sparc john o goyo
       [not found] ` <8f334a7b-b0d8-4bee-b58a-d09526c6b0ab@redhat.com>
  2024-03-20 22:33 ` Unable to trace assembler in GDB 14.2 on Solaris 11.3/sparc [Solved] john o goyo
@ 2024-03-21 16:29 ` Tom Tromey
  2024-03-21 17:27   ` Unable to trace assembler in GDB 14.2 on Solaris 11.3/sparc [SOLVED] john o goyo
  2 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2024-03-21 16:29 UTC (permalink / raw)
  To: john o goyo; +Cc: gdb

>>>>> john o goyo <jog37@riddermarkfarm.ca> writes:

I didn't want to let this go unanswered, but I was hoping someone more
familiar with Solaris would reply.

> I am learning Sparc assembler (mostly through Paul's book and various
> tutorials).  I built GDB 14.2 on Solaris 11.3/sparc and can debug C
> code with no problem.

>         .section ".data"
> hello:  .asciz "Hello, World!\n"

>         .global main
>         .align 4
> main:

Does main end up in .data here?  If so that could be the issue.

Normally this kind of thing should work ok, as far as I know.

Maybe dumping the minimal symbols ("maint print msymbols") would be
informative.

Tom

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

* Re: Unable to trace assembler in GDB 14.2 on Solaris 11.3/sparc [SOLVED]
  2024-03-21 16:29 ` Unable to trace assembler in GDB 14.2 on Solaris 11.3/sparc Tom Tromey
@ 2024-03-21 17:27   ` john o goyo
  0 siblings, 0 replies; 5+ messages in thread
From: john o goyo @ 2024-03-21 17:27 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb

Greetings, Tom.

On 2024-03-21 12:29, Tom Tromey wrote:
> I didn't want to let this go unanswered, but I was hoping someone more
> familiar with Solaris would reply.
>
>> I am learning Sparc assembler (mostly through Paul's book and various
>> tutorials).  I built GDB 14.2 on Solaris 11.3/sparc and can debug C
>> code with no problem.
>>          .section ".data"
>> hello:  .asciz "Hello, World!\n"
>>          .global main
>>          .align 4
>> main:
> Does main end up in .data here?  If so that could be the issue.
Yes -- that was exactly my mistake.  I added .section ".text" before the 
.global main and now main shows up as it should.

Thank you very much!

john

>
> Normally this kind of thing should work ok, as far as I know.
>
> Maybe dumping the minimal symbols ("maint print msymbols") would be
> informative.
>
> Tom


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

end of thread, other threads:[~2024-03-21 17:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-16 14:50 Unable to trace assembler in GDB 14.2 on Solaris 11.3/sparc john o goyo
     [not found] ` <8f334a7b-b0d8-4bee-b58a-d09526c6b0ab@redhat.com>
2024-03-18 15:12   ` john o goyo
2024-03-20 22:33 ` Unable to trace assembler in GDB 14.2 on Solaris 11.3/sparc [Solved] john o goyo
2024-03-21 16:29 ` Unable to trace assembler in GDB 14.2 on Solaris 11.3/sparc Tom Tromey
2024-03-21 17:27   ` Unable to trace assembler in GDB 14.2 on Solaris 11.3/sparc [SOLVED] john o goyo

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).