Code Monkey home page Code Monkey logo

Comments (4)

andreas-kupries avatar andreas-kupries commented on August 27, 2024

How does still having the #line directives break the debugging ?

  • For the templates in helper packages (like "class" and iassoc") it should be trivial to have them drop the directive from the output based on the state of 'config lines' (Have to check if this config can be queried outside of the critcl core).
  • You are correct that generated before setting the config will not capture the proper setting, like in Initialize (Have to check what that code is). It might be possible to remove the directives after the fact, just before compilation.
  • Not sure about the SHOW_LINES ... Have to check if that actually works, and also if using this would require changing the line numbers.

Will investigate.

from critcl.

medranocalvo avatar medranocalvo commented on August 27, 2024

All lines below the #line get mapped to the file indicated in the directive. For example, the following program:

package require critcl 3.1.12;

::critcl::tcl 8.6;
::critcl::config force 1;   # Recompile.
::critcl::config keepsrc 1; # Keep sources.
::critcl::config lines 0;   # Lines reference generated source.

::critcl::cproc ::twice {int i} int {
    return i * 2;
}

::critcl::load;

Has the following #line directives:

/* Generated by critcl on Thu Feb 12 08:07:32 CET 2015
 * source: /tmp/critclline.tcl
 * binary: /tmp/_cache/v3112_324a96ccbd71d1afcc6a66e991bec9c2_pic.o
 */

#include "tcl.h"

/* ---------------------------------------------------------------------- */

#define ns__twice2 "::twice"
static int c__twice2(int i)
{
return i * 2;
}

static int
tcl__twice2(ClientData cd, Tcl_Interp *interp, int oc, Tcl_Obj *CONST ov[])
{
  int _i;
  int rv;
  if (oc != 2) {
    Tcl_WrongNumArgs(interp, 1, ov, "i");
    return TCL_ERROR;
  }

  /* (int i) - - -- --- ----- -------- */
    {
#line 4700 "critcl.tcl"
    if (Tcl_GetIntFromObj(interp, ov[1], &_i) != TCL_OK) return TCL_ERROR; }

  /* Call - - -- --- ----- -------- */
  rv = c__twice2(_i);

#line 4794 "critcl.tcl"
    Tcl_SetObjResult(interp, Tcl_NewIntObj(rv));
    return TCL_OK;
}

/* ---------------------------------------------------------------------- */

# line 1 "MyInitTclStubs"

#if USE_TCL_STUBS
   const TclStubs *tclStubsPtr;
   const TclPlatStubs *tclPlatStubsPtr;
  const struct TclIntStubs *tclIntStubsPtr;
  const struct TclIntPlatStubs *tclIntPlatStubsPtr;

  static int
  MyInitTclStubs (Tcl_Interp *ip)
  {
    typedef struct {
      char *result;
      Tcl_FreeProc *freeProc;
      int errorLine;
      TclStubs *stubTable;
    } HeadOfInterp;

    HeadOfInterp *hoi = (HeadOfInterp*) ip;

    if (hoi->stubTable == NULL || hoi->stubTable->magic != TCL_STUB_MAGIC) {
      hoi->result = "This extension requires stubs-support.";
      hoi->freeProc = TCL_STATIC;
      return 0;
    }

    tclStubsPtr = hoi->stubTable;

    if (Tcl_PkgRequire(ip, "Tcl", "8.6", 0) == NULL) {
      tclStubsPtr = NULL;
      return 0;
    }

    if (tclStubsPtr->hooks != NULL) {
    tclPlatStubsPtr = tclStubsPtr->hooks->tclPlatStubs;
    tclIntStubsPtr = tclStubsPtr->hooks->tclIntStubs;
    tclIntPlatStubsPtr = tclStubsPtr->hooks->tclIntPlatStubs;
    }

    return 1;
  }
#endif

#ifdef __cplusplus
extern "C" {
#endif

DLLEXPORT int
Critclline_Init(Tcl_Interp *ip)
{
#if USE_TCL_STUBS
  if (!MyInitTclStubs(ip)) return TCL_ERROR;
#endif


  Tcl_CreateObjCommand(ip, ns__twice2, tcl__twice2, NULL, 0);
  return TCL_OK;
}
#ifdef __cplusplus
}
#endif

When debugging it with GDB, no source ever comes up for some parts, as "critcl.tcl" is not found. By the way: it would be best to have critcl output the full path to the file in the #line directive, both for critcl.tcl and for the tcl files, so that one does not need to configure the source path on the debugger.

Regarding the SHOW_LINES you can ignore it, it was intended as a simplest-thing-that-could-work suggestion.

Thank you very much for having a look at this.

Best regards,
Adrián Medraño Calvo.

from critcl.

andreas-kupries avatar andreas-kupries commented on August 27, 2024

Fixed with four commits. Unfortunately tagged as 'Issue 50', so github will have linked them there.
The relevant commits are

This looks to be done.

from critcl.

medranocalvo avatar medranocalvo commented on August 27, 2024

Wonderful! Thank you very much!

from critcl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.