-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tricore gdb crash when fopen is used in source #1
Comments
confirmed, please be aware that qemu semishosting is disabled if a connection to gdb is detected. the semihosting of the gdbclient is then used. Both are nearly identical. I will upload a patch in the corresponding https://github.com/volumit/gdb-tricore. |
fix for issue volumit/tricore_gcc940_linux_bins#1
It doesn't crash in my test after this fix. Reproduce steps:
cd gdb-tricore
git clean -x -f -d && git submodule foreach --recursive git clean -x -f -d
git pull
CC=gcc-9 ./configure --host=x86_64-linux-gnu --target=tricore-elf --program-prefix=tricore-elf --disable-nls --disable-itcl --disable-tk --disable-tcl --disable-winsup --disable-gdbtk --disable-libgui --disable-rda --disable-sid --disable-sim --disable-newlib --disable-libgloss --disable-gas --disable-ld --disable-binutils --disable-gprof --disable-source-highlight --with-system-zlib --prefix=$INSTALL_PREFIX --disable-werror --with-python
make -j $(nproc)
$TRICORE_GCC_PATH/tricore-elf-gcc -g -Wall -o build/test_read_file.elf $(pwd)/test_read_file.c /// @file test_read_file.c, utf-8 encoding
#include <stdio.h>
char buffer[100];
int main() {
const char *path = __FILE__;
FILE *f = fopen(path, "rb");
if (f) {
fseek(f, 0, SEEK_END);
long length = ftell(f);
fseek(f, 0, SEEK_SET);
length = length < ((int)sizeof(buffer)) ? length : sizeof(buffer);
fread(buffer, 1, length, f);
fclose(f);
printf("file content is: \n");
for (int i = 0; i < length; i++) {
printf("%x", buffer[i]);
}
printf("\n");
}
return 0;
}
$TRICORE_QEMU_PATH/qemu-system-tricore -display none -M tricore_tsim161 -semihosting -kernel build/test_read_file.elf
file content in byte is:
2f000ffffffd6ffffff850ffffff806520746573745f72650645f66696c652e63a23696e636c756465203c737464696f2e685890ffffffd00000000065725b3130305d3baa696e74206d61696e2829207ba2020636f6e73742063666666666666363668203d20
$TRICORE_QEMU_PATH/qemu-system-tricore -display none -M tricore_tsim161 -S -s -semihosting -kernel build/test_read_file.elf run gdb
The printed content with gdb is different with the content without gdb. |
I can not act daily, do you have more items which I should correct. Please can you continue with qemu semihosting without gdb invocation and tell me if further functional errors are happen. The qemu semihosting was used inside the gcc testsuite, which I nailed down to zero fails. It could be that the gdb testsuite has here some gaps. But I have to check. I would to collect all issues from your usage and and fix them in one correction one session. I will also then check if there is a gap in the testsuite of gdb and why it was not covered there. Well prepared easy for me to reproduce. Like to work with you! |
Haha, thank you very much! I also like to work with you: a technical excellent expert. Just one more question about C++ part: $TRICORE_GCC_PATH/tricore-elf-g++ -std=gnu++17 -o build/cpp_demo.elf cpp_demo.cpp
cpp_demo.cpp: In function 'int main()':
cpp_demo.cpp:6:26: error: 'to_string' is not a member of 'std'; did you mean 'u32string'?
6 | std::string str = std::to_string(1);
| ^~~~~~~~~
| u32string #include <string>
int main() {
std::string str = std::to_string(1);
return 0;
} Technically it's not a big problem because this problem can be solved by define _GLIBCXX_USE_C99_STDIO manually. #define _GLIBCXX_USE_C99_STDIO 1
#include <string>
int main() {
std::string str = std::to_string(1);
return 0;
} But on user experience point of view, when user see error message "'to_string' is not a member of 'std'", it's not straight forward to know he is missing a _GLIBCXX_USE_C99_STDIO. |
Update about fread got wrong content:
|
thanks for pointing it out, will fix it at the weekend, depending how complex it is. |
for _GLIBCXX_USE_C99_STDLIB, I do not know actually, surprising that the libstdc++ testsuite is not failing, but let me check as well. In theory it is not an issue to add a define, but then I will move away from the gcc9.4.0 fork and touching the base, so please let me check. |
I can confirm, and opened several tickets for the findings. Actually it looks like that I have to touch gcc, gdb and qemu. Binutils and Newlib are seeming to be unaffected. |
Thank you very much for your help! |
By the way, another question, --semihosting-cmdline option is not supported now. Is this possible to pass arguments to main function? |
see here. |
Environment:
uname -a Linux ubuntu 5.15.0-25-generic #25-Ubuntu SMP Wed Mar 30 15:54:22 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Reproduce steps:
$TRICORE_GCC_PATH/tricore-elf-gcc -g -Wall -o build/c_demo.elf c_demo.c
$TRICORE_QEMU_PATH/qemu-system-tricore -display none -M tricore_tsim161 -semihosting -S -s -kernel build/c_demo.elf
The text was updated successfully, but these errors were encountered: