English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. C/C++

 
 
Thread Tools
Old 22 December 2019, 17:47   #1201
JuanLuis
Registered User
 
Join Date: Dec 2018
Location: Málaga
Posts: 45
Quote:
Originally Posted by jotd View Post
can you show your build script (makefile/shell file?)
I have tried following options:

Assembler: gas -statistics -a --error-unresolved-symbols main.s
Linker: without options

Trying to pass --error-unresolved-symbols to linker:

Assembler: gas -statistics -a main.s
Linker: ld -Wl,--error-unresolved-symbols

In both cases --error-unresolved-symbols option is not recognized. GAS man says that this option should produce an error instead of a warning message.

By the way, you can see all the executed commands in build_msg.txt attached file.
JuanLuis is offline  
Old 30 December 2019, 17:13   #1202
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 60
Debug using gdbserver and VSCode?

As this toolchain meanwhile produces really dense and fast code, and coding in Linux with VSCode is more fun than I wanted to admit, the next logical step for me would be to start a debugging session directly from VSCode. But I don’t know if this possible, yet.

I’m thinking of
  • On debug start FS-UAE getting started
  • FS-UAE starting a gdbserver with the created binary as target
  • VSCode connects to this gdbserver
  • VSCode can step trough the source code

So, has anybody here made some experiences with this so far?
thyslo is offline  
Old 30 December 2019, 19:29   #1203
jotd
This cat is no more
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 48
Posts: 3,533
I've used GnatProgrammingStudio with m68k-amigaos-gdb and WinUAE and debug works okay. Sometimes it doesn't find local variables, but it was very helpful when I developped my game, since display was completely taken by the game, so printing debug stuff was complicated...

Build & link with "-g" (and also "-noixemul" else you'll have issues/crashes with C lib). Link with "-Wl,--amiga-debug-hunk -ldebug"

Enable "bsdsocket.library" from "expansion" tab.

Startup sequence containing smth like

Code:
stack 30000
assign ENV: RAM:
bgdbserver name_of_your_exe
Boot and wait for segments to be loaded

now run a debug script (gdb)

Code:
file name_of_your_exe
target remote :2345
wait for gdb prompt. Now put breakpoints and continue.

Last edited by jotd; 30 December 2019 at 19:55.
jotd is offline  
Old 30 December 2019, 23:55   #1204
arti
Registered User

 
Join Date: Jul 2008
Location: Poland
Posts: 560
You could redirect debug from UAE with -serlog parameter and kprintf.
Then run name_of_your_exe > ser:.
arti is offline  
Old 31 December 2019, 17:48   #1205
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 60
Thanks for your hints, I'll take them as a starting point when trying it with VSCode:-)
thyslo is offline  
Old 02 January 2020, 19:29   #1206
bebbo
botcher

 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 447
Quote:
Originally Posted by JuanLuis View Post
I attach a couple of files. main.s is the assembler program with an error.

--- main.s ---
...
msg:
.ascii "Calculando numeros primos, espere por favor..."
dc.b LF
msg_end: /* msg_end is defined here */

msg_length = msg_ed - msg /* There is a mistake. It should be msg_end instead of msg_ed */
...

this will yield now

Code:
Error: invalid operands (*UND* and .text sections) for `-' when setting `msg_length'

should be live soon
bebbo is offline  
Old 03 January 2020, 18:18   #1207
JuanLuis
Registered User
 
Join Date: Dec 2018
Location: Málaga
Posts: 45
Quote:
Originally Posted by bebbo View Post
this will yield now

Code:
Error: invalid operands (*UND* and .text sections) for `-' when setting `msg_length'

should be live soon
Thanks Bebbo. Whatever type of error it's enough for me. If there isn't error for undefined symbols, I have to take a look on compiling results even if compilation is successful and this is annoying.

Will it be needed to specify "--error-unresolved-symbols" option to get that message in next gas / ld version? Where will it be the change, in linker?
JuanLuis is offline  
Old 03 January 2020, 18:23   #1208
JuanLuis
Registered User
 
Join Date: Dec 2018
Location: Málaga
Posts: 45
An additional error I have seen it's argv is broken. In GCC 6.5.0b argv[n] returns null string when argument n exists. That worked fine in GCC 6.4.0 but there is something broken in 6.5.0b with line arguments.

This problem is not important for me. Take it as a minor error report.
JuanLuis is offline  
Old 03 January 2020, 20:16   #1209
alkis
Registered User

 
Join Date: Dec 2010
Location: Athens/Greece
Age: 49
Posts: 511
Quote:
Originally Posted by JuanLuis View Post
An additional error I have seen it's argv is broken. In GCC 6.5.0b argv[n] returns null string when argument n exists. That worked fine in GCC 6.4.0 but there is something broken in 6.5.0b with line arguments.

This problem is not important for me. Take it as a minor error report.
Umm, argument n is n-1 as C/C++ is zero indexed.
alkis is offline  
Old 03 January 2020, 20:19   #1210
alkis
Registered User

 
Join Date: Dec 2010
Location: Athens/Greece
Age: 49
Posts: 511
Quote:
Originally Posted by JuanLuis View Post
Will it be needed to specify "--error-unresolved-symbols" option to get that message in next gas / ld version? Where will it be the change, in linker?
Doesn't need any flags.

Code:
m68k-amigaos-gcc -o foo main.s
main.s: Assembler messages:
main.s: Error: invalid operands (*UND* and .text sections) for `-' when setting `msg_length'
alex[1]@debxvm test$ m68k-amigaos-as main.s
main.s: Assembler messages:
main.s: Error: invalid operands (*UND* and .text sections) for `-' when setting `msg_length'
alkis is offline  
Old 03 January 2020, 20:22   #1211
JuanLuis
Registered User
 
Join Date: Dec 2018
Location: Málaga
Posts: 45
Ok, I'll do a git pull of gcc code.

Thanks.
JuanLuis is offline  
Old 16 January 2020, 12:33   #1212
thyslo
Registered User
 
Join Date: Apr 2018
Location: Germany
Posts: 60
I had partial success with debugging in VSCode. I can set breakpoints and step through the code, but variables aren't displayed properly, yet.

E.g. an uninitialized member variable is pointing to something random, ok. Then there's a line of code where this variable is set to NULL. When I step over it still points to the same something random.

Then I re-read te thread post and found that I've missed an hint:

Quote:
Originally Posted by jotd View Post
Link with "-Wl,--amiga-debug-hunk -ldebug"
I added these options to the makefile. But after 'make debug' the created binary has the same size and content as before.

So I'm wondering if there's something wrong in the makefile:

Code:
# Setting up application name and directories
APPNAME=MyNewApp
APPNAME_DEBUG=MyNewApp_Debug

SRC_ROOT=src

OBJ_DIR=obj_release
OBJ_DIR_DEBUG=obj_debug

# Change some values for debug build
ifeq ($(BUILD),debug)
OBJ_DIR=$(OBJ_DIR_DEBUG)
APPNAME=$(APPNAME_DEBUG)
endif

# Specify the files and includes
DEPS=$(SRC_ROOT)/exampleclass.h

_OBJ=$(SRC_ROOT)/main.cpp \
                /exampleclass.cpp
 
INCLUDE=-I$(SRC_ROOT)

# Setting up compiler, flags and tools
CXX=/opt/amiga/bin/m68k-amigaos-c++
CXXFLAGS=-Wall -Wno-unused-function -fomit-frame-pointer -fno-rtti -fno-exceptions -noixemul
LD=/opt/amiga/bin/m68k-amigaos-ld
LDFLAGS=

ifeq ($(BUILD),debug)
# "Debug" build - no optimization, and debugging symbols
CXXFLAGS += -O0 -g -Wl,--amiga-debug-hunk -ldebug
#LDFLAGS += -Wl,--amiga-debug-hunk -ldebug
else
# "Release" build - optimization and no debug symbols
CXXFLAGS += -Os -s
endif

# Replace prefix SRC_ROOT with OBJ_DIR for object file target
OBJ=$(patsubst $(SRC_ROOT)/%,$(OBJ_DIR)/%,$(_OBJ))

# Building the .o files
# Note: the mkdir line creates the needed subdirectories in OB_DIR 
$(OBJ_DIR)/%.o: $(SRC_ROOT)/%.cpp $(DEPS)
	mkdir -p $(@D)
	$(CXX) $(CXXFLAGS) $(INCLUDE) -c -o $@ $< 


$(APPNAME): $(OBJ)
	$(CXX) $(CXXFLAGS) $(INCLUDE) -o $@ $^

release:
	make

debug:
	make "BUILD=debug"

# Cleaning build directory and executable
.PHONY: clean
clean:
	rm -rf $(OBJ_DIR) $(OBJ_DIR_DEBUG) $(APPNAME) $(APPNAME_DEBUG)
Anybody got an idea?
thyslo is offline  
Old 17 January 2020, 01:09   #1213
JuanLuis
Registered User
 
Join Date: Dec 2018
Location: Málaga
Posts: 45
Quote:
Originally Posted by alkis View Post
Umm, argument n is n-1 as C/C++ is zero indexed.
Alkis, I apologize for my poor explanation of the problem. I meant If you invoke the program with n arguments, main funciton sees these arguments argv[0] ... argv[n-1] as null. This worked fine in gcc 6.4.0, but it doesn't in gcc 6.5.0. Anyway there are other ways to pass arguments.

There are more important things like debugging. I prefer a comfortable debugging support than fixing minor issues.

Thanks for the answers.
JuanLuis is offline  
Old 17 January 2020, 16:58   #1214
alkis
Registered User

 
Join Date: Dec 2010
Location: Athens/Greece
Age: 49
Posts: 511
Code:
#include <stdio.h>

int main(int argc, char *argv[])
{
  for(int i=0; i<argc; ++i)
    printf("Arg #%d -> \"%s\"\n", i, argv[i]);
  return 0;
}
this as args.cpp
compiled with
m68k-amigaos-g++ -mcrt=nix13 -Os -w -s args.cpp -o args

with this compiler
m68k-amigaos-g++ --version
m68k-amigaos-g++ (GCC) 6.5.0b 191023121710
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

produces an executable that runs correctly on (emulated) a500 & a1200
(i.e. argv[] is not null)
alkis is offline  
Old 17 January 2020, 19:05   #1215
jotd
This cat is no more
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 48
Posts: 3,533
mcrt=nix13 is that kickstart 1.3 ? Is architecture 68000 by default?

I'd like to create a 68000-compatible executable, and why not for kickstart 1.3 too.
jotd is offline  
Old 17 January 2020, 19:26   #1216
alkis
Registered User

 
Join Date: Dec 2010
Location: Athens/Greece
Age: 49
Posts: 511
Quote:
Originally Posted by jotd View Post
mcrt=nix13 is that kickstart 1.3 ? Is architecture 68000 by default?

I'd like to create a 68000-compatible executable, and why not for kickstart 1.3 too.
Yes, mcrt=nix13 if for kickstart 1.3. By default is for 68000
You can further specify cpu with -m68020 -m68030 etc
alkis is offline  
Old 18 January 2020, 06:49   #1217
JuanLuis
Registered User
 
Join Date: Dec 2018
Location: Málaga
Posts: 45
Quote:
Originally Posted by alkis View Post
Code:
#include <stdio.h>

int main(int argc, char *argv[])
{
  for(int i=0; i<argc; ++i)
    printf("Arg #%d -> \"%s\"\n", i, argv[i]);
  return 0;
}
this as args.cpp
compiled with
m68k-amigaos-g++ -mcrt=nix13 -Os -w -s args.cpp -o args

with this compiler
m68k-amigaos-g++ --version
m68k-amigaos-g++ (GCC) 6.5.0b 191023121710
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

produces an executable that runs correctly on (emulated) a500 & a1200
(i.e. argv[] is not null)
That program output following result (image is on the end of my post):
[IMG]ArgsTestOutput.jpg[/IMG]

The code was:
Code:
#include <stdio.h>

/*
 * 
 */
int main(int argc, char** argv) {
    for (int i = 0; i < argc; i++)
        printf("Arg #%d -> \"%s\"\n", i, argv[i]);
                
    return 0;
}
Compiler version (called Amiga_Cygwin64_Bebbo2-Windows in my Netbeans configuration):

m68k-amigaos-g++ (GCC) 6.5.0b 191023121710
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Building output:
Code:
cd 'C:\Users\Juan Luis\Documents\NetBeansProjects\ArgsTest'
D:\cygwin64\bin\make.exe -f Makefile CONF=Debug clean
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .clean-conf
make[1]: se entra en el directorio '/cygdrive/c/Users/Juan Luis/Documents/NetBeansProjects/ArgsTest'
rm -f -r build/Debug
make[1]: se sale del directorio '/cygdrive/c/Users/Juan Luis/Documents/NetBeansProjects/ArgsTest'

CLEAN SUCCESSFUL (total time: 476ms)
cd 'C:\Users\Juan Luis\Documents\NetBeansProjects\ArgsTest'
D:\cygwin64\bin\make.exe -f Makefile CONF=Debug
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf
make[1]: se entra en el directorio '/cygdrive/c/Users/Juan Luis/Documents/NetBeansProjects/ArgsTest'
"/usr/bin/make"  -f nbproject/Makefile-Debug.mk dist/Debug/Amiga_Cygwin64_Bebbo2-Windows/argstest.exe
make[2]: se entra en el directorio '/cygdrive/c/Users/Juan Luis/Documents/NetBeansProjects/ArgsTest'
mkdir -p build/Debug/Amiga_Cygwin64_Bebbo2-Windows
rm -f "build/Debug/Amiga_Cygwin64_Bebbo2-Windows/main.o.d"
m68k-amigaos-g++    -c -g -std=c++14 -MMD -MP -MF "build/Debug/Amiga_Cygwin64_Bebbo2-Windows/main.o.d" -o build/Debug/Amiga_Cygwin64_Bebbo2-Windows/main.o main.cpp
mkdir -p dist/Debug/Amiga_Cygwin64_Bebbo2-Windows
m68k-amigaos-g++     -o dist/Debug/Amiga_Cygwin64_Bebbo2-Windows/argstest build/Debug/Amiga_Cygwin64_Bebbo2-Windows/main.o 
make[2]: se sale del directorio '/cygdrive/c/Users/Juan Luis/Documents/NetBeansProjects/ArgsTest'
make[1]: se sale del directorio '/cygdrive/c/Users/Juan Luis/Documents/NetBeansProjects/ArgsTest'

BUILD SUCCESSFUL (total time: 1s)
- Must I link with any static library?
- Is there any problem on my gcc building?
Attached Thumbnails
Click image for larger version

Name:	ArgsTestOutput.jpg
Views:	31
Size:	179.6 KB
ID:	65934  

Last edited by JuanLuis; 18 January 2020 at 06:58.
JuanLuis is offline  
Old 18 January 2020, 11:01   #1218
bebbo
botcher

 
Join Date: Jun 2016
Location: Hamburg/Germany
Posts: 447
Quote:
Originally Posted by JuanLuis View Post
...
Building output:
Code:
...
m68k-amigaos-g++    -c -g -std=c++14 -MMD -MP -MF "build/Debug
...
m68k-amigaos-g++     -o dist/Debug/Amiga_Cygwin64_Bebbo2-Windows
...
- Must I link with any static library?

- Is there any problem on my gcc building?

you must use -noixemul or one of -mcrt=nix13, -mcrt=nix20, -mcrt=clib2


The default libraries are not that good... and you may create a ticket here: https://github.com/bebbo/newlib-cygwin/issues
bebbo is offline  
Old 18 January 2020, 11:54   #1219
jotd
This cat is no more
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 48
Posts: 3,533
I confirm that without -noixemul it just crashed without reason. But replacing -noixemul by -mcrt=nix13 works also very well. Also the amigaincludes are different and kick13 compatible (got an error with OpenWindowTags)

=> exactly what you need for legacy Amigas.

Thanks again bebbo for this great compiler. I couldn't have completed my game project without it.
jotd is offline  
Old 19 January 2020, 15:21   #1220
JuanLuis
Registered User
 
Join Date: Dec 2018
Location: Málaga
Posts: 45
Quote:
Originally Posted by bebbo View Post
you must use -noixemul or one of -mcrt=nix13, -mcrt=nix20, -mcrt=clib2


The default libraries are not that good... and you may create a ticket here: https://github.com/bebbo/newlib-cygwin/issues
It works fine with -noixemul.

What option is better?

-noixemul or -mcrt ...?

Thanks for your help.
Attached Thumbnails
Click image for larger version

Name:	ArgsTestOutput-Good.jpg
Views:	39
Size:	181.4 KB
ID:	65940  
JuanLuis is offline  
 


Currently Active Users Viewing This Thread: 2 (0 members and 2 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
New GCC based dev toolchain for AmigaOS 3.x cla Coders. Releases 8 24 December 2017 11:18
Issue with photon/xxxx WinUAE Toolchain arpz Coders. Asm / Hardware 2 26 September 2015 23:33
New 68k gcc toolchain arti Coders. C/C++ 17 31 July 2015 04:59
Hannibal's WinUAE Demo Toolchain 5 Bobic Amiga scene 1 23 July 2015 22:04
From gcc to vbcc. Cowcat Coders. General 9 06 June 2014 15:45

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:37.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Page generated in 0.14065 seconds with 16 queries