26 June 2021, 14:54 | #41 | ||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
|
Quote:
Although I would have hoped that TextEdit can still be built with the near model for best performance. There is probably just a __savedsmissing somewhere? Quote:
__savedsdoes not only restore A4 for the current program's context, but it also saves its previous value and restores it on exit. The example you linked above shows that, and other compilers (like vbcc) behave exactly the same. This shouldn't be a problem for TextEdit, when calling a hook. A4 will be unmodified after the call. |
||
26 June 2021, 15:03 | #42 | |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 721
|
Quote:
https://gitlab.com/boemann/texteditf...example.c#L129 this call is in TextEdit's code which expect near model and HighlightSetFormat is missing __saveds |
|
26 June 2021, 15:56 | #43 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
|
Quote:
HighlightSetFormat()is a new function of texteditor.library, so I thought it was safe. But when this call somehow ends in the original TextEdit context, then you are right! And then this function (or the function in TextEdit which is called by it) would need fixing with __saveds. You're absolutely correct. |
|
26 June 2021, 15:57 | #44 | |
Camilla, AmigaOS Dev.
Join Date: Mar 2020
Location: Frederiksberg
Posts: 329
|
Quote:
The HightLightSetFormat is a library function in the texteditor.gadget library and not part of TextEdit (the program). And although that function is not __saveds either it doesn't actually use any global values in the texteditor.gadget (there aren't any) |
|
26 June 2021, 15:59 | #45 | |
Camilla, AmigaOS Dev.
Join Date: Mar 2020
Location: Frederiksberg
Posts: 329
|
Quote:
|
|
26 June 2021, 16:08 | #46 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
|
Looks like a real mystery then. I would be curious to debug that.
Maybe guy lateur comes up with some new information. |
26 June 2021, 16:33 | #47 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 721
|
How many instances do those plugins get? Multiple? Is plugin considered "resident" or does it get loaded separately for each time? Cause we might hit another problem that way...
|
26 June 2021, 16:46 | #48 |
Camilla, AmigaOS Dev.
Join Date: Mar 2020
Location: Frederiksberg
Posts: 329
|
It is loaded once by TextEdit, and as far as settings is concerned there should be only one setting.
The highlighter however can be called by many different texteditor.gadgets (if you have more than one file open) and you can also make no assumption about the order of the lines it is called on. |
26 June 2021, 17:51 | #49 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 721
|
gcc's note on __saveds
Please do not use this attribute in pure executables. This is because several invocations of pure executables can run concurrently, each one having its own data section, and there is no way to find out to which of these sections should ‘a4’ be set. (Couldn't tell from previous response, if plugin is loadseg'd once for all instances or once for each instance, so I don't know if this is relevant) |
26 June 2021, 17:56 | #50 |
Camilla, AmigaOS Dev.
Join Date: Mar 2020
Location: Frederiksberg
Posts: 329
|
ah no TextEdit is not pure
|
26 June 2021, 19:13 | #51 | |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
|
Quote:
__savedsin such executables, and it works with SAS/C and vbcc. |
|
27 June 2021, 12:29 | #52 |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Ok, I did some more testing, and something quite weird is going on. As suggested, I'm trying to build the most basic plugin that gets detected by TextEdit without crashing it or bringing the whole system down. I've not succeeded so far.
I've attached my code (entire masterfolder). It includes the object files, the resulting plugin and the output from make(which I've also pasted below). As before, the whole system freezes as soon as TextEdit is started. Here's the init()function: Code:
static void init(APTR userData) { //openLibs(); struct Filetype *fType = (struct Filetype *)userData; //struct Hook *hook = (struct Hook *)AllocVec(sizeof(struct Hook), MEMF_CLEAR); //fType->pluginData = (ULONG)1234567; // any number or pointer of our choosing //fType->highlighterHook = hook; fType->typeName = "example"; fType->autoFileTypes = "example"; //fType->terminate = terminate; //fType->settingsTitle = settingsTitle; //fType->settingsGadget = settingsGadget; //fType->processGadgetUp = processGadgetUp; //fType->setSettingsFromGUI = setSettingsFromGUI; //fType->setGUIFromSettings = setGUIFromSettings; //fType->applySettings = applySettings; //fType->saveSettings = saveHighlightSettings; //fType->loadSettings = loadHighlightSettings; //fType->disposeGadgets = disposeGadgets; fType->name = "Example"; //hook->h_Entry = (ULONG (*)()) highlightBlock; //hook->h_SubEntry = NULL; //hook->h_Data = 1234567; } make: Code:
vc -nostdlib -c99 -c example.c >{ warning 68 in line 107 of "example.c": redeclaration of var <saveHighlightSettings> with new type >{ warning 123 in line 107 of "example.c": formal parameters conflict with parameter-type-list >{ warning 68 in line 114 of "example.c": redeclaration of var <loadHighlightSettings> with new type >{ warning 123 in line 114 of "example.c": formal parameters conflict with parameter-type-list >ULONG __saveds __asm highlightBlock( warning 54 in line 120 of "example.c": ; expected >ULONG __saveds __asm highlightBlock( warning 67 in line 120 of "example.c": type defaults to int >ULONG __saveds __asm highlightBlock(register __a0 struct warning 57 in line 120 of "example.c": , expected >ULONG __saveds __asm highlightBlock(register __a0 struct Hook *h,register __a2 warning 57 in line 120 of "example.c": , expected >ULONG __saveds __asm highlightBlock(register __a0 struct Hook *h,register __a2 warning 57 in line 120 of "example.c": , expected vc -nostdlib -lamiga -ldebug -o exampleplugin pluginheader.o example.o fType->pluginData, then also assigning all functions that return nothing or NULL, then assigning all functions, and finally also uncommenting openLibs(). Everything gives the same result, ie the system freezes as soon as TextEdit is started. For completeness, here's the output from smake(Camilla's example, built using SAS/C, which does work as expected): Code:
makedir tagfiles sc idlen=64 comnest streq strmerge nostkchk optimize opttime cpu=any debug=symbolflush noopt params=register strsect=code mccons data=far IDIR=NDK32:Include_H pluginheader.c Using options file "scoptions" SAS/C Amiga Compiler 6.58 Copyright (c) 1988-1995 SAS Institute Inc. Compiler Phase 1 for "pluginheader.c" No errors; No warnings; No user suppressed warnings Compiler Phase 2 for "pluginheader.c" Module size P=00000000 D=00000000 U=00000000 C=00000000 F=00000024 UF=0000000C sc idlen=64 comnest streq strmerge nostkchk optimize opttime cpu=any debug=symbolflush noopt params=register strsect=code mccons data=far IDIR=NDK32:Include_H example.c Using options file "scoptions" SAS/C Amiga Compiler 6.58 Copyright (c) 1988-1995 SAS Institute Inc. Compiler Phase 1 for "example.c" example.c 107 Warning 93: no reference to identifier "fType" example.c 114 Warning 93: no reference to identifier "fType" ==================== UWORD end = strlen[33;7m([0mtext); example.c 125 Warning 100: no prototype declared for function "strlen" ==================== hook->h_Data = 1234567[33;7m;[0m example.c 171 Warning 225: pointer type mismatch "void *" does not match "int" No errors; 4 warnings; No user suppressed warnings Compiler Phase 2 for "example.c" Module size P=00000242 D=00000000 U=00000000 C=00000000 F=00000014 UF=00000000 slink pluginheader.o example.o to exampleplugin.debug lib lib:scnb.lib NDK32:lib/amiga.lib NDK32:lib/debug.lib assert.lib addsym smallcode noicons batch smalldata map exampleplugin.map,fhx fwidth 32 pwidth 32 swidth 32 Slink - Version 6.58 Copyright (c) 1988-1995 SAS Institute, Inc. All Rights Reserved. SLINK Complete - Maximum code size = 668 ($0000029c) bytes Final output file size = 29228 ($0000722c) bytes slink exampleplugin.debug to exampleplugin noicons nodebug Slink - Version 6.58 Copyright (c) 1988-1995 SAS Institute, Inc. All Rights Reserved. SLINK Complete - Maximum code size = 668 ($0000029c) bytes Final output file size = 808 ($00000328) bytes I'm just mentioning this because this means debugging this may not be as straightforward for me ATM as we had originally hoped. We can still do the trap #0approach, of course, but I'd prefer to have some more specific instructions on where to put those and how to proceed with that before trying that. I'd rather not spend another afternoon turning my Vampire off and on again without having anything to show for it afterward. I'm kinda hoping you guys spot something in the output of makethat might tell us what the problem might be.. |
27 June 2021, 14:12 | #53 | |||||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,537
|
Quote:
Anyway, it is essential to find out whether init()is called at all or whether it even returns before the problem occurs. Quote:
Filetypestructure before the call. So it should be ok to leave most of its fields uninitialised (Camilla, please correct me). Or are there any fields which absolutely require a value? Like the hook pointer? Quote:
highlightBlock()function, like Bubbob told you. Although it doesn't matter as the hook isn't even used. Quote:
__asm("\ttrap\t#0");as the first instruction in your init(). Then we know that TextEdit has called it, as soon as you see a Software Failure #80000020. Otherwise TextEdit has already problems with loading the plugin or processing the header. I guess TextEdit uses LoadSeg()to read and relocate a plugin into memory'? Quote:
|
|||||
27 June 2021, 14:39 | #54 | ||
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Quote:
Quote:
Ok, will do, I'll report back asap. |
||
27 June 2021, 15:43 | #55 |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 721
|
why is openlibs commented out?
Libraries should be opened before anything else. Also, could I ask something. On the example plugin that works, with sas/c run scopts and switch startup code to 'nostartup", clean, build, check that it still works please. Thanks |
27 June 2021, 16:27 | #56 |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
I've been checking when the Guru/Software Failure turns into a system freeze. Starting from Camilla's source, I always have to add an
#include <string.h>, because otherwise I get an undefined reference to strlen(). If that's the only change I make, I get a Guru: Program failed (error #80000006), or sometimes Program failed (error #8000000A). ATM it's unclear to me what causes the either one or the other error to show up. BTW, on the Vampire, it's not an actual Guru Meditation screen; it's just a Software Failuredialog window, like this: The next thing I do (at least, from now on ) is change the signature of the highlightBlock() function. That still results in a Software Failure, not a hang. However, if I then put the call to openLibs()at the top of the init()function (which seems like the smart thing to do), the system hangs when I start TextEdit. So I'm assuming calling AllocVec()before opening any libraries leads to the Software Failure. The above implies that the init()function does indeed get called, which is confirmed by the trap #0check. If I put that at the top of the init() function, I indeed get Software Failure #80000020: Next step will be to see how far down I can put the trap before the system hangs again. |
27 June 2021, 16:40 | #57 | ||
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Quote:
init()function untouched. As you may have read above, though, it seems that's not really an option, unfortunately. Quote:
SCOPTIONSfile? Sorry, total SAS/C noob here.. |
||
27 June 2021, 16:51 | #58 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 681
|
Quote:
off topic - but regarding saveds and resident: You are free to store a4 in the tc_UserData and provide your function to use that. But since the name contains 'user' I won't make gcc use that by default. |
|
27 June 2021, 19:39 | #59 | |
Registered User
Join Date: Dec 2010
Location: Athens/Greece
Age: 53
Posts: 721
|
Quote:
type scopts and hit enter A gui should pop out. Press button "Linker options..." You should see (in say middle 'column') something like startup=c, keep pressing that button till it says NoStartup Press ok, that will go to previous setup and there press Save. Now clean, build, check. |
|
27 June 2021, 20:42 | #60 | |
Registered User
Join Date: May 2017
Location: Belgium
Age: 50
Posts: 334
|
Quote:
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
AmigaOS 3.2 TextEdit - black text on black background? | Warty | support.Apps | 7 | 08 June 2021 17:30 |
gedit asm syntax highlighting plugin? | grond | Coders. Asm / Hardware | 0 | 19 May 2020 13:06 |
VBCC assembler linking syntax? | NovaCoder | Coders. General | 2 | 20 May 2011 03:04 |
CLI Syntax | Greaser | New to Emulation or Amiga scene | 1 | 08 October 2006 10:14 |
SynTax Disks (old) | andreas | request.Old Rare Games | 1 | 19 July 2003 04:02 |
|
|