All of lore.kernel.org
 help / color / mirror / Atom feed
* debug makefile based c-helloworld application
@ 2020-05-28 16:28 cschmidt
  0 siblings, 0 replies; only message in thread
From: cschmidt @ 2020-05-28 16:28 UTC (permalink / raw)
  To: yocto

I try to debug a simple helloworld program but i can't see the source 
code. My approach:


hello.c

```

#include<stdio.h>

int main() {
   printf("Hello World\n");
   return 0;
}

```

hellome.bb

```

#
# This file was derived from the 'Hello World!' example recipe in the
# Yocto Project Development Manual.
#
SUMMARY = "Simple helloworld application"
LICENSE = "CLOSED"


SRC_URI = "file://hello.c"

S = "${WORKDIR}"

TARGET_CC_ARCH += "${LDFLAGS}"

do_compile() {
   ${CC} hello.c -o -g -O0 hello
}

do_install() {
   install -d ${D}${bindir}
   install -m 0755 hello ${D}${bindir}
}

```

Makefile

```
SOURCES=hello.c
OBJECTS=$(SOURCES:.c=.o)
EXEC=hello

#EXTRACFLAGS=-ansi

all: $(SOURCES) $(EXEC)

$(EXEC): $(OBJECTS)
     $(CC) $(CFLAGS) $(EXTRACFLAGS) $(OBJECTS) -o $@

%.o : %c
     $(CC) $(CFLAGS) $(EXTRACFLAGS) -c $<

install:
     install $(EXEC) $(DESTDIR)/usr/bin

clean:
     rm -rf *.o $(EXEC)
```


local.conf

```

....

IMAGE_INSTALL_append = " hellome hellome-dbg hellome-dev"

EXTRA_IMAGE_FEATURES += "\
       dbg-pkgs \
       tools-debug \
       debug-tweaks \
       dev-pkgs"


# Specifies to build packages with debugging information
DEBUG_BUILD = "1"

# Do not remove debug symbols
INHIBIT_PACKAGE_STRIP = "1"

```


on the target:

```

root@qemuarm:~# hello
Hello World

root@qemuarm:~# gdb /usr/bin/hello

Reading symbols from /usr/bin/hello...
(gdb) b main
Breakpoint 1 at 0x518
(gdb) r
Starting program: /usr/bin/hello

Breakpoint 1, 0x00400518 in main ()
(gdb) list
1       longjmp.c: No such file or directory.
(gdb) list 1
file: "../setjmp/longjmp.c", line number: 1, symbol: "???"
1       ../setjmp/longjmp.c: No such file or directory.
file: "longjmp.c", line number: 1, symbol: "???"
1       longjmp.c: No such file or directory.
```



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-28 16:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-28 16:28 debug makefile based c-helloworld application cschmidt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.