01 December 2020, 20:09 | #1 |
Returning fan!
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,434
|
Getting VBCC and Enforcer to Play Together
Hi all!
I read a lot of discussions (here, here, here, and here...) and docs. but I still can't get VBCC and Enforcer to play together on my Amiga When my C code causes an Enforcer hit (not that often! ), Enforcer doesn't give me the hunk and offset information needed to find the line causing the hit. Because I have this information with LawBreaker, I think that I'm not compiling/linking "right"... I compile my C code with VBCC v0.8j and the flags:
What am I missing here? Cheers! PS. I tried Hunk and BDebug too... Hunk shows some hunks (code and data) but BDebug tells me that there are no symbols to pick a line to put a breakpoint... Last edited by tygre; 01 December 2020 at 20:19. Reason: Typos; More info. |
01 December 2020, 20:28 | #2 |
Registered User
Join Date: Apr 2005
Location: digital hell, Germany, after 1984, but worse
Posts: 3,365
|
Sorry, I didn't check your problem very well and I don't use C compilers with debug options, but do you have SegTracker running?
http://aminet.net/package/dev/debug/SegTracker |
01 December 2020, 20:31 | #3 | |
Returning fan!
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,434
|
Hi PeterK!
Quote:
Yes, I do have SegTracker and I think that the combo SegTracker/Enforcer works well because I get the hunk/offset from Enforcer when running LawBreak... Or am I wrong? Cheers! |
|
02 December 2020, 11:40 | #4 | ||||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
They don't even need to play together. It's already sufficient if you get the hunk-offsets from your hits via Enforcer/SegTracker (or MuForce with the appropriate option).
Quote:
Quote:
Although, the compiler shouldn't have any influence on Segtracker reporting your section-offsets or not. I admit I prefered to use MuForce over the last years, but I remember that Enforcer always worked as well. Quote:
Looking at the LDFLAGS: do you link with vlink yourself, or do you use the vc frontend? When calling vlink then watch your options, so you don't strip the debugging information again. Quote:
Now I'm confused about your actual problem. Is it that SegTracker doesn't report any offsets when a hit happens, or is it that your FindHit-tool doesn't see any debugging information in the executable, or both? Any FindHit-tool, which also works with SAS/C, should be able to translate the information from SegTracker into a source line. I also wrote such a tool, many years ago, which you find here: http://sun.hasenbraten.de/~frank/projects/download/FindHunkOffset.lha |
||||
02 December 2020, 15:46 | #5 | ||
Returning fan!
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,434
|
Hi Phx!
Thanks for you answer and your advice Quote:
Code:
Name: "Background CLI" CLI: "AmiModRadio" Hunk 0000 Offset 00049CF2 But, when I use FindHit on the executable (AmiModRadio) with the given offset (0:49CF2), FindHit says that "the object is of incorrect type" (translated from French). Does this mean that the hunks were stripped or that they are not the "right" ones? I use vc to link my code, so could that be the reason why hunks are stripped/mistyped? Though, I can't see anything on the command line that would explain that the hunks are stripped: Code:
vbcc:bin/vc -lmieee -cpp-comments -I... -I... -I... -I... -I... -L... -L... -L... -lamiga -lmiami -lposix -Bamigahunk -o bin/vbcc-classic/debug/AmiModRadio o/vbcc-classic/debug/... o/vbcc-classic/debug/... o/vbcc-classic/debug/... What am I missing? Should I use explicitly vlink? With what "default" options? Quote:
Cheers! Last edited by tygre; 02 December 2020 at 16:00. Reason: Typos; More info. |
||
02 December 2020, 16:41 | #6 | ||||
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Quote:
vbcc, or more precisely, the vc-frontend calling vlink, outputs these hunks by default, because it makes the executable much shorter. On the other hand, when you call vc with -g option, then it will automatically disable this feature, because I knew that many debuggers are too stupid to understand it. So I still suspect that you forgot -g while linking with vc, or stripped the executable... Quote:
Quote:
Quote:
|
||||
02 December 2020, 19:28 | #7 | |
Returning fan!
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,434
|
Quote:
I didn't realise that the -g option was necessary in both the compilation and linking phase, what a n00b! I added the -g option to the linking phase and I can now use FindHit or FindHunkOffset... Let's the debugging begin |
|
02 December 2020, 21:31 | #8 |
Returning fan!
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,434
|
PS. To follow-up, I have yet-another question about using SegTracker+Enforcer: I have hits in a task that I create from the main task but Enforcer doesn't report hunk and offset for this task...
Is that expected? Or am I missing something else? If that's normal, how can I pinpoint the line(s) causing the hits? |
02 December 2020, 21:46 | #9 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
Never tried that myself. Not sure. I guess that SegTracker needs a real process, which has a valid pr_SegList pointing to the loaded segments (sections) of an executable file.
|
02 December 2020, 22:09 | #10 | |
Returning fan!
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,434
|
Quote:
Would you know of any ways with SegTracker or alternatives to get them to work with tasks? |
|
04 December 2020, 14:17 | #11 |
Returning fan!
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,434
|
Hi Phx and all!
Would you have any suggestion how to debug a task that I start from the main task? The Enforcer hits happen only when the two tasks run "in parallel", not when I remove the second task and run my code "sequentially" (So I know that must have something to do with sharing some variables but hard to find which one and in which conditions! ) Cheers! |
04 December 2020, 15:47 | #12 |
Total Chaos forever!
Join Date: Aug 2007
Location: Waterville, MN, USA
Age: 49
Posts: 2,186
|
Are you semaphore protecting the shared resources? Not doing so results in undefined behavior. Sharing variables should be done in a "mutex".
|
04 December 2020, 16:16 | #13 |
Returning fan!
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,434
|
No, I'm not yet
I'd like to know first what variables are causing troubles... Any idea maybe to get SegTracker or something else to give me the hunk/offset? |
04 December 2020, 19:07 | #14 | |
bye
Join Date: Jun 2016
Location: Some / Where
Posts: 680
|
Quote:
How do you start your threads? Maybe you could set the seglist for your threads? Code:
newProc = CreateNewProcTags(NP_Entry, (ULONG )startProc, NP_FreeSeglist, 0, ...); newProc->pr_SegList = mainProc->pr_SegList; |
|
05 December 2020, 02:01 | #15 |
Returning fan!
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,434
|
Hi Bebbo and thank you for your suggestion!
I tried but, even with a valid seglist from the main process (I checked), assigning it to the new process just crashes my Amiga I must miss some checks or something? Best! |
05 December 2020, 14:09 | #16 |
Natteravn
Join Date: Nov 2009
Location: Herford / Germany
Posts: 2,496
|
What you say is confusing (again).
First you wrote that you want to debug a new Task (which likely runs from the same context as your main Process?), but now it seems to be a full Process? Or did you make it a process now? This is an important difference. Also you wrote earlier that Enforcer shows illegal memory accesses from this new Task (or Process). What made you sure about that, when it runs the code from the main process? Does it show a different task id? And now there are no Enforcer hits anymore, but the program crashes the machine immediately? Has that always been the case, or as a result of trying to implement Bebbo's suggestion (which I think is a good one)? Maybe you just did a mistake there. When the crash is easily reproducible you should be able to narrow it down. |
05 December 2020, 16:18 | #17 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,216
|
*cough* pr_SegList is probably not what you think what it is. In particular, this is *not* a pointer to the seglist of the process. It is a pointer to an array of segments that are used by the BCPL runtime "binder" to fill the GlobVec, and as such it is not particularly useful for anything nowadays. This pointer should better not be touched or read by anything. SegTracker, in particular, does not get its information from here, but from its own database that is patched into the system loader, aka "LoadSeg" and "UnloadSeg". |
05 December 2020, 17:10 | #18 | |||
Returning fan!
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,434
|
Hi Phx!
Sorry about that! Thanks to bear with me Quote:
Code:
_player_listener_task = (struct Task *)CreateNewProcTags( NP_Entry, &_player_listener_loop, NP_Priority, 1, NP_Name, LISTENER_NAME, NP_Output, Output(), NP_CloseOutput, FALSE, TAG_DONE); Quote:
Quote:
Cheers! Last edited by tygre; 06 December 2020 at 00:25. Reason: Typos |
|||
05 December 2020, 17:27 | #19 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,216
|
As stated before, this line cannot work. In fact, it will cause a double-memory release of the seglist array. This array is better left alone.
|
05 December 2020, 17:34 | #20 | |
Returning fan!
Join Date: Jan 2011
Location: Montréal, QC, Canada
Posts: 1,434
|
Hi Thomas!
Quote:
How could I "trace" the code responsible for the Enforcer hits in this new process then? Is there a way? (Besides printfs...) Maybe if it was a real task, it would be "linked" to the main process and the question would be moot? Cheers! Last edited by tygre; 05 December 2020 at 17:37. Reason: More details |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Enforcer with WinUAE ? | Lord Riton | support.WinUAE | 11 | 26 September 2017 19:12 |
Let's play: Ivan drago - justice enforcer game (rocky iv) | ZEUSDAZ | Retrogaming General Discussion | 0 | 14 February 2017 21:02 |
enforcer with FS-UAE | Lazycow | support.FS-UAE | 8 | 29 November 2015 20:22 |
Enforcer | mritter0 | Coders. General | 6 | 15 July 2014 16:09 |
MMu and Enforcer | Maur "Mef" Fontana | support.Apps | 0 | 19 May 2002 00:50 |
|
|